use of com.tencent.angel.master.ps.CommitEvent 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