Search in sources :

Example 1 with CheckModelSavedResponse

use of com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.CheckModelSavedResponse in project angel by Tencent.

the class MasterService method checkModelSaved.

/**
 * Check save request is complete
 */
@Override
public CheckModelSavedResponse checkModelSaved(RpcController controller, CheckModelSavedRequest request) throws ServiceException {
    LOG.info("check model saved=" + request);
    ModelSaveResult result = context.getModelSaver().getModelSaveResult(request.getRequestId());
    if (result == null) {
        throw new ServiceException("can not find save request " + request.getRequestId());
    } else {
        CheckModelSavedResponse.Builder builder = CheckModelSavedResponse.newBuilder();
        builder.setStatus(result.getState().getStateId());
        if (result.getMessage() != null) {
            builder.setLog(result.getMessage());
        }
        return builder.build();
    }
}
Also used : CheckModelSavedResponse(com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.CheckModelSavedResponse) ServiceException(com.google.protobuf.ServiceException) ModelSaveResult(com.tencent.angel.model.ModelSaveResult)

Example 2 with CheckModelSavedResponse

use of com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.CheckModelSavedResponse in project angel by Tencent.

the class AngelClient method isSaveCompleted.

/**
 * Check a save request complete or not
 *
 * @param requestId save request id
 * @return true means complete
 */
private boolean isSaveCompleted(int requestId) throws AngelException {
    CheckModelSavedResponse response;
    try {
        response = master.checkModelSaved(null, CheckModelSavedRequest.newBuilder().setRequestId(requestId).build());
    } catch (Throwable x) {
        throw new AngelException("Check model save request failed ", x);
    }
    SaveState state = SaveState.valueOf(response.getStatus());
    if (state == SaveState.FAILED) {
        throw new AngelException("Model save falied " + response.getLog());
    } else if (state == SaveState.SUCCESS) {
        return true;
    } else {
        return false;
    }
}
Also used : AngelException(com.tencent.angel.exception.AngelException) CheckModelSavedResponse(com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.CheckModelSavedResponse) SaveState(com.tencent.angel.model.SaveState)

Aggregations

CheckModelSavedResponse (com.tencent.angel.protobuf.generated.ClientMasterServiceProtos.CheckModelSavedResponse)2 ServiceException (com.google.protobuf.ServiceException)1 AngelException (com.tencent.angel.exception.AngelException)1 ModelSaveResult (com.tencent.angel.model.ModelSaveResult)1 SaveState (com.tencent.angel.model.SaveState)1