JobTracker源码修改
JobTracker source code modification
我是一名学习MapReduce研究的学生。现在,我设计了一个MapReduce调度消息。我将实现该算法。为了验证算法,我在原来的Hadoop代码上添加了一些打印信息,例如JobTracker.java,FairScheduler.java,等等......但是,重新编译代码后,打印信息没有显示在显示器。我无法验证算法的正确性。
例如src/mapred/org/apache/hadoop/mapred/JobTracker.java中的修改代码如下
...
public static JobTracker startTracker(JobConf conf
) throws IOException,
InterruptedException { System.out.println("Hello! World!!!");
return startTracker(conf, generateNewIdentifier()); }
public static JobTracker startTracker(JobConf conf, String identifier) throws IOException, InterruptedException { System.out.println("Hello! World!!!"); return startTracker(conf, identifier, false); }
public static JobTracker startTracker(JobConf conf, String identifier, boolean initialize) throws IOException, InterruptedException { System.out.println("Hello! World!!!"); DefaultMetricsSystem.initialize("JobTracker");
JobTracker result = null;
while (true) {
System.out.println("Hello! World!!!");
try {
result = new JobTracker(conf, identifier);
result.taskScheduler.setTaskTrackerManager(result);
break;
} catch (VersionMismatch e) {
throw e;
} catch (BindException e) {
throw e;
} catch (UnknownHostException e) {
throw e;
} catch (AccessControlException ace) {
// in case of jobtracker not having right access
// bail out
throw ace;
} catch (IOException e) {
LOG.warn("Error starting tracker: " +
StringUtils.stringifyException(e));
}
Thread.sleep(1000);
}
if (result != null) {
System.out.println("Hello! World!!!");
JobEndNotifier.startNotifier();
MBeans.register("JobTracker", "JobTrackerInfo", result);
if(initialize == true) {
System.out.println("Hello! World!!!");
result.setSafeModeInternal(SafeModeAction.SAFEMODE_ENTER);
result.initializeFilesystem();
result.setSafeModeInternal(SafeModeAction.SAFEMODE_LEAVE);
result.initialize();
}
}
return result; }
...
我编译了修改后的代码,并用命令替换了原来的 Hadoop:
cd $HADOOP_HOME
ant
mv build/hadoop-client-1.2.2-SNAPSHOT.jar hadoop-client-1.2.1.jar
mv build/hadoop-core-1.2.2-SNAPSHOT.jar hadoop-core-1.2.1.jar
mv build/hadoop-minicluster-1.2.2-SNAPSHOT.jar hadoop-minicluster-1.2.1.jar
mv build/hadoop-tools-1.2.2-SNAPSHOT.jar hadoop-tools-1.2.1.jar
然后,我启动了新版本的Hadoop。
它没有在我的显示器上显示任何 "Hello! World!!!" 消息。
有知道原因的请指教。在编译或执行时,是否需要添加一些参数?
非常感谢。
默认情况下,Hadoop 守护程序的输出在 $HADOOP_HOME/logs 文件夹下的 *.out 中捕获。您应该能够在那里找到输出消息。
我是一名学习MapReduce研究的学生。现在,我设计了一个MapReduce调度消息。我将实现该算法。为了验证算法,我在原来的Hadoop代码上添加了一些打印信息,例如JobTracker.java,FairScheduler.java,等等......但是,重新编译代码后,打印信息没有显示在显示器。我无法验证算法的正确性。
例如src/mapred/org/apache/hadoop/mapred/JobTracker.java中的修改代码如下
...
public static JobTracker startTracker(JobConf conf
) throws IOException,
InterruptedException { System.out.println("Hello! World!!!");
return startTracker(conf, generateNewIdentifier()); }
public static JobTracker startTracker(JobConf conf, String identifier) throws IOException, InterruptedException { System.out.println("Hello! World!!!"); return startTracker(conf, identifier, false); }
public static JobTracker startTracker(JobConf conf, String identifier, boolean initialize) throws IOException, InterruptedException { System.out.println("Hello! World!!!"); DefaultMetricsSystem.initialize("JobTracker");
JobTracker result = null;
while (true) {
System.out.println("Hello! World!!!");
try {
result = new JobTracker(conf, identifier);
result.taskScheduler.setTaskTrackerManager(result);
break;
} catch (VersionMismatch e) {
throw e;
} catch (BindException e) {
throw e;
} catch (UnknownHostException e) {
throw e;
} catch (AccessControlException ace) {
// in case of jobtracker not having right access
// bail out
throw ace;
} catch (IOException e) {
LOG.warn("Error starting tracker: " +
StringUtils.stringifyException(e));
}
Thread.sleep(1000);
}
if (result != null) {
System.out.println("Hello! World!!!");
JobEndNotifier.startNotifier();
MBeans.register("JobTracker", "JobTrackerInfo", result);
if(initialize == true) {
System.out.println("Hello! World!!!");
result.setSafeModeInternal(SafeModeAction.SAFEMODE_ENTER);
result.initializeFilesystem();
result.setSafeModeInternal(SafeModeAction.SAFEMODE_LEAVE);
result.initialize();
}
}
return result; }
...
我编译了修改后的代码,并用命令替换了原来的 Hadoop:
cd $HADOOP_HOME
ant
mv build/hadoop-client-1.2.2-SNAPSHOT.jar hadoop-client-1.2.1.jar
mv build/hadoop-core-1.2.2-SNAPSHOT.jar hadoop-core-1.2.1.jar
mv build/hadoop-minicluster-1.2.2-SNAPSHOT.jar hadoop-minicluster-1.2.1.jar
mv build/hadoop-tools-1.2.2-SNAPSHOT.jar hadoop-tools-1.2.1.jar
然后,我启动了新版本的Hadoop。 它没有在我的显示器上显示任何 "Hello! World!!!" 消息。
有知道原因的请指教。在编译或执行时,是否需要添加一些参数? 非常感谢。
默认情况下,Hadoop 守护程序的输出在 $HADOOP_HOME/logs 文件夹下的 *.out 中捕获。您应该能够在那里找到输出消息。