I'm writing a mapper and would like to know if it is possible to get the nodename, where the mapper is running.
Asked
Active
Viewed 770 times
2 Answers
3
Hadoop automatically moves your MapReduce program to where your data is so I think you can just do getHostName() (if you're using Java that is) and it should return the name of the node on which your program is running.
java.net.InetAddress.getLocalHost().getHostName();
If you're using other languages such as Python, Ruby, etc. (i.e. using HadoopStreaming), the same idea holds true so you should be able to use the appropriate function/method available in those languages to get the host name.

Edenbauer
- 1,306
- 1
- 11
- 15
0
The configuration value fs.default.name
will most probably give you a URL to the namenode, and if you get an instance of the FileSystem (Filesystem.get(conf)
) you should be able to call the getUri()
method to get the same information.

Chris White
- 29,949
- 4
- 71
- 93