int port = Integer.parseInt(args[1]);
InetSocketAddress address = new InetSocketAddress(host, port);
TaskAttemptID taskid = TaskAttemptID.forName(args[2]);
// //////////////////
BSPPeerProtocol umbilical = (BSPPeerProtocol) RPC.getProxy(
BSPPeerProtocol.class, HamaRPCProtocolVersion.versionID, address,
defaultConf);
final BSPTask task = (BSPTask) umbilical.getTask(taskid);
int peerPort = umbilical.getAssignedPortNum(taskid);
defaultConf.addResource(new Path(task.getJobFile()));
BSPJob job = new BSPJob(task.getJobID(), task.getJobFile());
defaultConf.set(Constants.PEER_HOST, args[3]);
if (null != args && 5 == args.length) {
defaultConf.setInt("bsp.checkpoint.port", Integer.parseInt(args[4]));
}
defaultConf.setInt(Constants.PEER_PORT, peerPort);
try {
// use job-specified working directory
FileSystem.get(job.getConf()).setWorkingDirectory(
job.getWorkingDirectory());
// instantiate and init our peer
@SuppressWarnings("rawtypes")
final BSPPeerImpl<?, ?, ?, ?, ?> bspPeer = new BSPPeerImpl(job,
defaultConf, taskid, umbilical, task.partition, task.splitClass,
task.split, task.getCounters());
task.run(job, bspPeer, umbilical); // run the task
} catch (FSError e) {
LOG.fatal("FSError from child", e);
umbilical.fsError(taskid, e.getMessage());
e.printStackTrace();
} catch (SyncException e) {
LOG.fatal("SyncError from child", e);
umbilical.fatalError(taskid, e.toString());
// Report back any failures, for diagnostic purposes
ByteArrayOutputStream baos = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(baos));
e.printStackTrace();