Search in sources :

Example 1 with WorkerRegisterResponse

use of com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.WorkerRegisterResponse in project angel by Tencent.

the class MasterService method workerRegister.

/**
 * worker register to master
 *
 * @param controller rpc controller of protobuf
 * @param request contains worker attempt id, worker location
 */
@SuppressWarnings("unchecked")
@Override
public WorkerRegisterResponse workerRegister(RpcController controller, WorkerRegisterRequest request) throws ServiceException {
    WorkerRegisterResponse.Builder registerResponseBuilder = WorkerRegisterResponse.newBuilder();
    WorkerAttemptId workerAttemptId = ProtobufUtil.convertToId(request.getWorkerAttemptId());
    LOG.info("Worker " + workerAttemptId + " register, location=" + request.getLocation() + ", psagent id=" + request.getPsAgentId());
    // if worker attempt id is not in monitor set, we should shutdown it
    if (!context.getWorkerManager().isAlive(workerAttemptId)) {
        LOG.error("worker attempt " + workerAttemptId + " is not in running worker attempt set now, shutdown it");
        registerResponseBuilder.setCommand(WorkerCommandProto.W_SHUTDOWN);
    } else {
        context.getWorkerManager().alive(workerAttemptId);
        Location location = new Location(request.getLocation().getIp(), request.getLocation().getPort());
        context.getEventHandler().handle(new WorkerAttemptRegisterEvent(workerAttemptId, location));
        registerResponseBuilder.setCommand(WorkerCommandProto.W_SUCCESS);
        LOG.info("worker attempt " + workerAttemptId + " register finished!");
    }
    return registerResponseBuilder.build();
}
Also used : WorkerRegisterResponse(com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.WorkerRegisterResponse) WorkerAttemptId(com.tencent.angel.worker.WorkerAttemptId) WorkerAttemptRegisterEvent(com.tencent.angel.master.worker.attempt.WorkerAttemptRegisterEvent) PSLocation(com.tencent.angel.ps.server.data.PSLocation) Location(com.tencent.angel.common.location.Location)

Example 2 with WorkerRegisterResponse

use of com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.WorkerRegisterResponse in project angel by Tencent.

the class Worker method register.

/**
 * Register to {@link com.tencent.angel.master.AngelApplicationMaster}
 */
public void register() {
    LOG.info("Register to master");
    try {
        WorkerRegisterResponse response = masterClient.workerRegister();
        if (response.getCommand() == WorkerCommandProto.W_SHUTDOWN) {
            LOG.error("worker received shutdown command when register, to exit now!");
            System.exit(-1);
        }
        LOG.info("worker register finished!");
    // taskManager.assignTaskIds(response.getTaskidsList());
    } catch (Exception x) {
        LOG.fatal("register to appmaster error, worker will exit", x);
        workerExit(-1);
    }
}
Also used : WorkerRegisterResponse(com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.WorkerRegisterResponse) ServiceException(com.google.protobuf.ServiceException) IOException(java.io.IOException) YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException)

Aggregations

WorkerRegisterResponse (com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.WorkerRegisterResponse)2 ServiceException (com.google.protobuf.ServiceException)1 Location (com.tencent.angel.common.location.Location)1 WorkerAttemptRegisterEvent (com.tencent.angel.master.worker.attempt.WorkerAttemptRegisterEvent)1 PSLocation (com.tencent.angel.ps.server.data.PSLocation)1 WorkerAttemptId (com.tencent.angel.worker.WorkerAttemptId)1 IOException (java.io.IOException)1 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)1