Search in sources :

Example 1 with GetAllPSLocationResponse

use of com.tencent.angel.protobuf.generated.MLProtos.GetAllPSLocationResponse in project angel by Tencent.

the class AngelClient method waitForAllPS.

protected void waitForAllPS(int psNumber) throws ServiceException, InterruptedException {
    boolean isAllPSReady = true;
    while (true) {
        GetAllPSLocationResponse response = master.getAllPSLocation(null, GetAllPSLocationRequest.newBuilder().build());
        List<PSLocationProto> psLocs = response.getPsLocationsList();
        int size = psLocs.size();
        if (size == psNumber) {
            isAllPSReady = true;
            for (int i = 0; i < size; i++) {
                if (psLocs.get(i).getPsStatus() == PSStatus.PS_NOTREADY) {
                    isAllPSReady = false;
                    break;
                }
            }
            if (isAllPSReady) {
                return;
            }
        }
        Thread.sleep(100);
    }
}
Also used : GetAllPSLocationResponse(com.tencent.angel.protobuf.generated.MLProtos.GetAllPSLocationResponse) PSLocationProto(com.tencent.angel.protobuf.generated.MLProtos.PSLocationProto)

Example 2 with GetAllPSLocationResponse

use of com.tencent.angel.protobuf.generated.MLProtos.GetAllPSLocationResponse in project angel by Tencent.

the class MasterService method getAllPSLocation.

/**
 * get all parameter server locations.
 *
 * @param controller rpc controller of protobuf
 */
@Override
public GetAllPSLocationResponse getAllPSLocation(RpcController controller, GetAllPSLocationRequest request) {
    GetAllPSLocationResponse.Builder resBuilder = GetAllPSLocationResponse.newBuilder();
    LocationManager locationManager = context.getLocationManager();
    ParameterServerId[] psIds = locationManager.getPsIds();
    for (int i = 0; i < psIds.length; i++) {
        resBuilder.addPsLocations(ProtobufUtil.convertToPSLocProto(psIds[i], locationManager.getPsLocation(psIds[i])));
    }
    return resBuilder.build();
}
Also used : LocationManager(com.tencent.angel.common.location.LocationManager) ParameterServerId(com.tencent.angel.ps.ParameterServerId) GetAllPSLocationResponse(com.tencent.angel.protobuf.generated.MLProtos.GetAllPSLocationResponse)

Aggregations

GetAllPSLocationResponse (com.tencent.angel.protobuf.generated.MLProtos.GetAllPSLocationResponse)2 LocationManager (com.tencent.angel.common.location.LocationManager)1 PSLocationProto (com.tencent.angel.protobuf.generated.MLProtos.PSLocationProto)1 ParameterServerId (com.tencent.angel.ps.ParameterServerId)1