use of com.tencent.angel.master.app.AppEvent in project angel by Tencent.
the class PSAgentManager method psAgentKilled.
@SuppressWarnings("unchecked")
private void psAgentKilled(PSAgentManagerEvent event) {
killedPSAgentMap.put(event.getPsAgentId(), psAgentMap.get(event.getPsAgentId()));
context.getEventHandler().handle(new AppEvent(context.getApplicationId(), AppEventType.KILL));
}
use of com.tencent.angel.master.app.AppEvent 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;
}
}
use of com.tencent.angel.master.app.AppEvent in project angel by Tencent.
the class MasterService method save.
/**
* Save model to files.
*
* @param controller rpc controller of protobuf
* @param request save request that contains all matrices need save
* @throws ServiceException some matrices do not exist or save operation is interrupted
*/
@SuppressWarnings("unchecked")
@Override
public SaveResponse save(RpcController controller, SaveRequest request) throws ServiceException {
List<String> needSaveMatrices = request.getMatrixNamesList();
List<Integer> matrixIds = new ArrayList<Integer>(needSaveMatrices.size());
AMMatrixMetaManager matrixMetaManager = context.getMatrixMetaManager();
int size = needSaveMatrices.size();
for (int i = 0; i < size; i++) {
MatrixMeta matrixMeta = matrixMetaManager.getMatrix(needSaveMatrices.get(i));
if (matrixMeta == null) {
throw new ServiceException("matrix " + needSaveMatrices.get(i) + " does not exist");
}
LOG.info("Need save matrix " + matrixMeta.getName());
matrixIds.add(matrixMeta.getId());
}
context.getEventHandler().handle(new CommitEvent(matrixIds));
context.getEventHandler().handle(new AppEvent(AppEventType.COMMIT));
return SaveResponse.newBuilder().build();
}
Aggregations