我正在尝试使用Java连接我的jobtracker 下面显示的是我正在尝试执行的程序
public static void main(String args[]) throws IOException {
Configuration conf = new Configuration();
conf.addResource(new Path(
"/home/user/hadoop-1.0.3/conf/core-site.xml"));
conf.addResource(new Path(
"/home/user/hadoop-1.0.3/conf/hdfs-site.xml"));
conf.addResource(new Path(
"/home/user/hadoop-1.0.3/conf/mapred-site.xml"));
InetSocketAddress jobtracker = new InetSocketAddress("localhost", 50030);
JobClient jobClient = new JobClient(jobtracker, conf);
jobClient.setConf(conf);
JobStatus[] jobs = jobClient.jobsToComplete();
for (int i = 0; i < jobs.length; i++) {
JobStatus js = jobs[i];
if (js.getRunState() == JobStatus.RUNNING) {
JobID jobId = js.getJobID();
System.out.println(jobId);
}
}
这是我得到的例外。 即使我尝试用127.0.0.1替换localhost也不行 。同样的错误。
Exception in thread "main" java.io.IOException: Call to localhost/127.0.0.1:50030 failed on local exception: java.io.EOFException
at org.apache.hadoop.ipc.Client.wrapException(Client.java:1107)
at org.apache.hadoop.ipc.Client.call(Client.java:1075)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:225)
at org.apache.hadoop.mapred.$Proxy1.getProtocolVersion(Unknown Source)
at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:396)
at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:379)
at org.apache.hadoop.mapred.JobClient.createRPCProxy(JobClient.java:480)
at org.apache.hadoop.mapred.JobClient.<init>(JobClient.java:534)
at com.tcs.nextgen.searchablemetadata.executor.factory.JobChecker.main(JobChecker.java:34)
Caused by: java.io.EOFException
at java.io.DataInputStream.readInt(DataInputStream.java:375)
at org.apache.hadoop.ipc.Client$Connection.receiveResponse(Client.java:811)
at org.apache.hadoop.ipc.Client$Connection.run(Client.java:749)
我添加了与hadoop相关的所有罐子。 我无法理解为什么“/”在localhost / 127.0.0.1:50030之间进行
答案 0 :(得分:5)
您是否尝试过实际的jobtracker端口号,而不是http端口(50030)。
尝试在mapred.job.tracker
属性下的$ HADOOP_HOME / conf / mapred-site.xml中列出的端口号。这是我的伪mapred-site.xml conf
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
如果查看JobTracker.getAddress(Configuration)
方法,如果没有明确指定jobtracker主机/端口,则可以看到它使用此属性:
public static InetSocketAddress getAddress(Configuration conf) {
String jobTrackerStr =
conf.get("mapred.job.tracker", "localhost:8012");
return NetUtils.createSocketAddr(jobTrackerStr);
}