use of com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.WorkerDoneRequest in project angel by Tencent.
the class PSManagerTest method testPSDone.
@SuppressWarnings("unchecked")
@Test
public void testPSDone() throws Exception {
try {
AngelApplicationMaster angelAppMaster = LocalClusterContext.get().getMaster().getAppMaster();
ParameterServer ps = LocalClusterContext.get().getPS(psAttempt0Id).getPS();
Location masterLoc = ps.getMasterLocation();
TConnection connection = TConnectionManager.getConnection(ps.getConf());
MasterProtocol master = connection.getMasterService(masterLoc.getIp(), masterLoc.getPort());
WorkerDoneRequest workerRequest = WorkerDoneRequest.newBuilder().setWorkerAttemptId(ProtobufUtil.convertToIdProto(worker0Attempt0Id)).build();
WorkerDoneResponse workerResponse = master.workerDone(null, workerRequest);
assertEquals(workerResponse.getCommand(), WorkerCommandProto.W_SUCCESS);
Thread.sleep(5000);
angelAppMaster.getAppContext().getEventHandler().handle(new AppEvent(AppEventType.COMMIT));
PSDoneRequest request = PSDoneRequest.newBuilder().setPsAttemptId(ProtobufUtil.convertToIdProto(psAttempt0Id)).build();
master.psDone(null, request);
Thread.sleep(5000);
ParameterServerManager psManager = angelAppMaster.getAppContext().getParameterServerManager();
AMParameterServer amPs = psManager.getParameterServer(psId);
PSAttempt psAttempt = amPs.getPSAttempt(psAttempt0Id);
assertEquals(psAttempt.getInternalState(), PSAttemptStateInternal.SUCCESS);
assertTrue(amPs.getState() == AMParameterServerState.SUCCESS);
assertEquals(amPs.getNextAttemptNumber(), 1);
assertNull(amPs.getRunningAttemptId());
assertEquals(amPs.getSuccessAttemptId(), psAttempt0Id);
assertEquals(amPs.getPSAttempts().size(), 1);
} catch (Exception x) {
LOG.error("run testPSDone failed ", x);
throw x;
}
}
Aggregations