First Implementation Experiment Towards Hadoop Compute Server

In order to implement the compute server, I decided to break it down into several phases. The client would be the TaskTracker and the server would be the ChildJVM.  (1) The initial research into the socket APIs and how we can use it to pass task relevant information to the (2) Using one JVM, establish a connection from the TaskTracker to the ChildJVM and pass in task relevant arguments. (3) Have multiple slots, but execute tasks for different JVMs(with different JVMIds) in the same JVM. This post is focusing on Phase 2.

Since we are just using one slot, there will not be multiple JVMIds. We don’t have to worry about that. We need to locate change the TaskTracker, so that it launches a new ChildJVM, but then immediately establishes a connection to the ChildJVM. The ChildJVM waits for the TaskTracker to establish a connection and read in task relevant information from the TaskTracker, and start executing the task. To the outside, everything should be working just fine. We are only changing the mechanism that task relevant arguments are passed into the ChildJVM.

To do this, we first identify the location/locations the TaskTracker launches a new ChildJVM. Currently we are seeing code in, runChild() method, shown below

public void runChild(JvmEnv env) throws IOException, InterruptedException{

int exitCode = 0;

try {


TaskRunner runner = jvmToRunningTask.get(jvmId);

if (runner != null) {

Task task = runner.getTask();

//Launch the task controller to run task JVM

String user = task.getUser();

TaskAttemptID taskAttemptId = task.getTaskID();

String taskAttemptIdStr = task.isTaskCleanupTask() ?

(taskAttemptId.toString() + TaskTracker.TASK_CLEANUP_SUFFIX) :


exitCode = tracker.getTaskController().launchTask(user,

jvmId.jobId.toString(), taskAttemptIdStr, env.setup,

env.vargs, env.workDir, env.stdout.toString(),



} catch (IOException ioe) {

// do nothing

// error and output are appropriately redirected

} finally { // handle the exit code

// although the process has exited before we get here,

// make sure the entire process group has also been killed.


updateOnJvmExit(jvmId, exitCode);"JVM : " + jvmId + " exited with exit code " + exitCode

+ ". Number of tasks it ran: " + numTasksRan);

deleteWorkDir(tracker, firstTask);



This block of code is called within


void launchJvmAndWait(List <String> setup, Vector<String> vargs, File stdout,

File stderr, long logSize, File workDir)

throws InterruptedException, IOException {

jvmManager.launchJvm(this, jvmManager.constructJvmEnv(setup, vargs, stdout,

stderr, logSize, workDir, conf));

synchronized (lock) {

while (!done) {





If this is the only location that is being called when launching a new ChildJVM, we are going to try to add a block of code that connects to the ChildJVM and pass in relevant task information.

On the ChildJVM side, we need to modify the main function. Instead of doing the parsing for TaskAttemptID and jvmIdInt, we wait for it to be passed in through the socket from TaskTracker. Once we have the information, we continue execution.

public static void main(String[] args) throws Throwable {

LOG.debug("Child starting");


final JobConf defaultConf = new JobConf();

String host = args[0];

int port = Integer.parseInt(args[1]);

final InetSocketAddress address = NetUtils.makeSocketAddr(host, port);

final TaskAttemptID firstTaskid = TaskAttemptID.forName(args[2]);

final String logLocation = args[3];

final int SLEEP_LONGER_COUNT = 5;

int jvmIdInt = Integer.parseInt(args[4]);

JVMId jvmId = new JVMId(firstTaskid.getJobID(),firstTaskid.isMap(),jvmIdInt);

String prefix = firstTaskid.isMap() ? "MapTask" : "ReduceTask";

This entry was posted in Hadoop Research, HJ-Hadoop Improvements, Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s