我使用 Hadoop 1.2.1 并尝试通过 java 客户端打印作业详细信息,但它没有打印任何内容,这是我的 java 代码
Configuration configuration = new Configuration();
configuration.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
configuration.addResource(new Path("/usr/local/hadoop/conf/hdfs-site.xml"));
configuration.addResource(new Path("/usr/local/hadoop/conf/mapred-site.xml"));
InetSocketAddress jobtracker = new InetSocketAddress("localhost", 54311);
JobClient jobClient;
jobClient = new JobClient(jobtracker, configuration);
jobClient.setConf(configuration);
JobStatus[] jobs = jobClient.getAllJobs();
System.out.println(jobs.length);//it is printing 0.
for (int i = 0; i < jobs.length; i++) {
JobStatus js = jobs[i];
JobID jobId = js.getJobID();
System.out.println(jobId);
}
But from job tracker history i can see three jobs. Here is the screen shot
Can any body tell me where am going wrong. I just want to print all the job details.
这是我的配置文件:
核心站点.xml
<configuration>
<property>
<name>hadoop.tmp.dir</name
<value>/data/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:54310</value>
<description>The name of the default file system. A URI whose</description>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:54310</value>
<description>The name of the default file system. A URI whose
scheme and authority determine the FileSystem implementation. The
uri's scheme determines the config property (fs.SCHEME.impl) naming
the FileSystem implementation class. The uri's authority is used to
determine the host, port, etc. for a filesystem.</description>
</property>
</configuration>
hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
<description>Default block replication. The actual number of replications can be specified when the file is created. The default is used if replication is not specified in create time.
</description>
</property>
</configuration>
mapred-site.xml
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:54311</value>
<description>The host and port that the MapReduce job tracker runs at. If "local", then jobs are run in-process as a single map and reduce task.
</description>
</property>
</configuration>