Search in sources :

Example 11 with Location

use of com.tencent.angel.common.location.Location in project angel by Tencent.

the class MasterClient method register.

/**
 * Register to Master
 *
 * @throws IOException
 * @throws ServiceException
 */
public void register() throws IOException, ServiceException {
    PSRegisterRequest.Builder regBuilder = PSRegisterRequest.newBuilder();
    regBuilder.setPsAttemptId(ProtobufUtil.convertToIdProto(context.getPSAttemptId()));
    try {
        Location location = new Location(InetAddress.getLocalHost().getHostAddress(), context.getPsService().getPort());
        regBuilder.setLocation(ProtobufUtil.convertLocation(location));
    } catch (UnknownHostException eop) {
        LOG.error("UnknownHostException: " + eop);
        throw new IOException(eop);
    }
    masterProxy.psRegister(null, regBuilder.build());
}
Also used : UnknownHostException(java.net.UnknownHostException) IOException(java.io.IOException) PSLocation(com.tencent.angel.ps.server.data.PSLocation) PartitionLocation(com.tencent.angel.ml.matrix.PartitionLocation) Location(com.tencent.angel.common.location.Location)

Example 12 with Location

use of com.tencent.angel.common.location.Location in project angel by Tencent.

the class MasterService method psRegister.

/**
 * response for parameter server register.
 *
 * @param controller rpc controller of protobuf
 * @param request register request
 */
@SuppressWarnings("unchecked")
@Override
public PSRegisterResponse psRegister(RpcController controller, PSRegisterRequest request) throws ServiceException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("receive ps register request. request=" + request);
    }
    PSAttemptId psAttemptId = ProtobufUtil.convertToId(request.getPsAttemptId());
    PSRegisterResponse.Builder resBuilder = PSRegisterResponse.newBuilder();
    // if psAttemptId is not in monitor set, just return a PSCOMMAND_SHUTDOWN command.
    if (!context.getParameterServerManager().isAlive(psAttemptId)) {
        LOG.info(psAttemptId + " doesn't exists!");
        resBuilder.setPsCommand(PSCommandProto.PSCOMMAND_SHUTDOWN);
    } else {
        context.getParameterServerManager().alive(psAttemptId);
        context.getEventHandler().handle(new PSAttemptRegisterEvent(psAttemptId, new Location(request.getLocation().getIp(), request.getLocation().getPort())));
        LOG.info(psAttemptId + " is registered now!");
        resBuilder.setPsCommand(PSCommandProto.PSCOMMAND_OK);
    }
    LOG.info(psAttemptId + " register finished!");
    return resBuilder.build();
}
Also used : PSAttemptRegisterEvent(com.tencent.angel.master.ps.attempt.PSAttemptRegisterEvent) PSAttemptId(com.tencent.angel.ps.PSAttemptId) PSRegisterResponse(com.tencent.angel.protobuf.generated.PSMasterServiceProtos.PSRegisterResponse) PSLocation(com.tencent.angel.ps.server.data.PSLocation) Location(com.tencent.angel.common.location.Location)

Example 13 with Location

use of com.tencent.angel.common.location.Location in project angel by Tencent.

the class MasterService method getPartLocation.

/**
 * Get locations for a partition
 */
@Override
public GetPartLocationResponse getPartLocation(RpcController controller, GetPartLocationRequest request) throws ServiceException {
    GetPartLocationResponse.Builder builder = GetPartLocationResponse.newBuilder();
    List<ParameterServerId> psIds = context.getMatrixMetaManager().getPss(request.getMatrixId(), request.getPartId());
    if (psIds != null) {
        int size = psIds.size();
        for (int i = 0; i < size; i++) {
            Location psLocation = context.getLocationManager().getPsLocation(psIds.get(i));
            if (psLocation == null) {
                builder.addLocations((PSLocationProto.newBuilder().setPsId(ProtobufUtil.convertToIdProto(psIds.get(i))).setPsStatus(PSStatus.PS_NOTREADY).build()));
            } else {
                builder.addLocations(ProtobufUtil.convertToPSLocProto(psIds.get(i), psLocation));
            }
        }
    }
    return builder.build();
}
Also used : GetPartLocationResponse(com.tencent.angel.protobuf.generated.MLProtos.GetPartLocationResponse) ParameterServerId(com.tencent.angel.ps.ParameterServerId) PSLocation(com.tencent.angel.ps.server.data.PSLocation) Location(com.tencent.angel.common.location.Location)

Example 14 with Location

use of com.tencent.angel.common.location.Location in project angel by Tencent.

the class MasterService method getPSLocation.

/**
 * get a specific parameter server location.
 *
 * @param controller rpc controller of protobuf
 * @param request parameter server id
 */
@Override
public GetPSLocationReponse getPSLocation(RpcController controller, GetPSLocationRequest request) throws ServiceException {
    GetPSLocationReponse.Builder resBuilder = GetPSLocationReponse.newBuilder();
    ParameterServerId psId = ProtobufUtil.convertToId(request.getPsId());
    Location psLocation = context.getLocationManager().getPsLocation(psId);
    if (psLocation == null) {
        resBuilder.setPsLocation(PSLocationProto.newBuilder().setPsId(request.getPsId()).setPsStatus(PSStatus.PS_NOTREADY).build());
    } else {
        resBuilder.setPsLocation(ProtobufUtil.convertToPSLocProto(psId, psLocation));
    }
    return resBuilder.build();
}
Also used : GetPSLocationReponse(com.tencent.angel.protobuf.generated.MLProtos.GetPSLocationReponse) ParameterServerId(com.tencent.angel.ps.ParameterServerId) PSLocation(com.tencent.angel.ps.server.data.PSLocation) Location(com.tencent.angel.common.location.Location)

Example 15 with Location

use of com.tencent.angel.common.location.Location in project angel by Tencent.

the class MasterService method serviceInit.

@Override
protected void serviceInit(Configuration conf) throws Exception {
    String ip;
    int servicePort;
    if (conf.get(AngelConf.ANGEL_DEPLOY_MODE, AngelConf.DEFAULT_ANGEL_DEPLOY_MODE).equals("KUBERNETES")) {
        ip = conf.get(AngelConf.ANGEL_KUBERNETES_MASTER_POD_IP);
        servicePort = conf.getInt(AngelConf.ANGEL_KUBERNETES_MASTER_PORT, AngelConf.DEFAULT_ANGEL_KUBERNETES_MASTER_PORT);
    } else {
        ip = NetUtils.getRealLocalIP();
        // choose a unused port
        servicePort = NetUtils.chooseAListenPort(conf);
    }
    LOG.info("listen ip:" + ip + ", port:" + servicePort);
    location = new Location(ip, servicePort);
    // start RPC server
    this.rpcServer = MLRPC.getServer(MasterService.class, this, new Class<?>[] { MasterProtocol.class }, ip, servicePort, conf);
    rpcServer.openServer();
    super.serviceInit(conf);
}
Also used : PSLocation(com.tencent.angel.ps.server.data.PSLocation) Location(com.tencent.angel.common.location.Location)

Aggregations

Location (com.tencent.angel.common.location.Location)38 TConnection (com.tencent.angel.ipc.TConnection)12 Test (org.junit.Test)12 PSLocation (com.tencent.angel.ps.server.data.PSLocation)10 IOException (java.io.IOException)10 Worker (com.tencent.angel.worker.Worker)9 PartitionLocation (com.tencent.angel.ml.matrix.PartitionLocation)6 ServiceException (com.google.protobuf.ServiceException)5 AngelException (com.tencent.angel.exception.AngelException)5 AMTaskManager (com.tencent.angel.master.task.AMTaskManager)5 ParameterServer (com.tencent.angel.ps.ParameterServer)5 ParameterServerId (com.tencent.angel.ps.ParameterServerId)5 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)5 AngelApplicationMaster (com.tencent.angel.master.AngelApplicationMaster)4 ParameterServerManager (com.tencent.angel.master.ps.ParameterServerManager)4 WorkerManager (com.tencent.angel.master.worker.WorkerManager)4 MasterClient (com.tencent.angel.psagent.client.MasterClient)4 Matcher (java.util.regex.Matcher)4 Pattern (java.util.regex.Pattern)4 MasterServiceTest (com.tencent.angel.master.MasterServiceTest)3