use of edu.iu.dsc.tws.common.net.tcp.request.RRClient in project twister2 by DSC-SPIDAL.
the class JMWorkerAgent method init.
/**
* initialize JMWorkerAgent
* wait until it connects to JobMaster
* return false, if it can not connect to JobMaster
*/
private void init() {
looper = new Progress();
ClientConnectHandler connectHandler = new ClientConnectHandler();
rrClient = new RRClient(jmAddress, jmPort, null, looper, thisWorker.getWorkerID(), connectHandler);
driverAgent = new JMDriverAgent(rrClient, thisWorker.getWorkerID());
statusUpdater = new JMWorkerStatusUpdater(rrClient, thisWorker.getWorkerID(), config);
// protocol buffer message registrations
ResponseMessageHandler handler = new ResponseMessageHandler();
rrClient.registerResponseHandler(JobMasterAPI.RegisterWorker.newBuilder(), handler);
rrClient.registerResponseHandler(JobMasterAPI.RegisterWorkerResponse.newBuilder(), handler);
rrClient.registerResponseHandler(JobMasterAPI.JobScaled.newBuilder(), handler);
rrClient.registerResponseHandler(JobMasterAPI.AllJoined.newBuilder(), handler);
// create checkpointing client
this.checkpointClient = new CheckpointingClientImpl(rrClient, CheckpointingContext.getRequestTimeout(config));
workerController = new JMWorkerController(config, thisWorker, numberOfWorkers, restartCount, rrClient, this.checkpointClient);
// try to connect to JobMaster
tryUntilConnected(CONNECTION_TRY_TIME_LIMIT);
if (!rrClient.isConnected()) {
throw new RuntimeException("JMWorkerAgent can not connect to Job Master. Exiting .....");
}
// initialize checkpointing client
this.checkpointClient.init();
}
Aggregations