Search in sources :

Example 1 with PSLocation

use of com.tencent.angel.ps.server.data.PSLocation in project angel by Tencent.

the class PSMatrixMetaManager method getPartLocation.

/**
 * Get partition location: includes stored pss and the location of the pss
 *
 * @param partitionKey partition information
 * @return partition location
 * @throws ServiceException
 */
public PartitionLocation getPartLocation(PartitionKey partitionKey) throws ServiceException {
    List<ParameterServerId> psIds = getPss(partitionKey);
    if (psIds == null) {
        return new PartitionLocation(new ArrayList<>());
    }
    int size = psIds.size();
    List<PSLocation> psLocs = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        psLocs.add(new PSLocation(psIds.get(i), context.getLocationManager().getPsLocation(psIds.get(i))));
    }
    return new PartitionLocation(psLocs);
}
Also used : PSLocation(com.tencent.angel.ps.server.data.PSLocation) ArrayList(java.util.ArrayList) ParameterServerId(com.tencent.angel.ps.ParameterServerId) PartitionLocation(com.tencent.angel.ml.matrix.PartitionLocation)

Example 2 with PSLocation

use of com.tencent.angel.ps.server.data.PSLocation 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 3 with PSLocation

use of com.tencent.angel.ps.server.data.PSLocation 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 4 with PSLocation

use of com.tencent.angel.ps.server.data.PSLocation in project angel by Tencent.

the class MasterClient method getPartLocation.

/**
 * Get the stored pss and the locations for a matrix partition
 *
 * @param matrixId matrix id
 * @param partId   partition id
 * @return the stored pss and the locations
 * @throws ServiceException
 */
public PartitionLocation getPartLocation(int matrixId, int partId) throws ServiceException {
    MLProtos.GetPartLocationResponse response = masterProxy.getPartLocation(null, MLProtos.GetPartLocationRequest.newBuilder().setMatrixId(matrixId).setPartId(partId).build());
    List<MLProtos.PSLocationProto> psLocsProto = response.getLocationsList();
    int size = psLocsProto.size();
    List<PSLocation> psLocs = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        psLocs.add(new PSLocation(ProtobufUtil.convertToId(psLocsProto.get(i).getPsId()), ProtobufUtil.convertToLocation(psLocsProto.get(i))));
    }
    return new PartitionLocation(psLocs);
}
Also used : PSLocation(com.tencent.angel.ps.server.data.PSLocation) MLProtos(com.tencent.angel.protobuf.generated.MLProtos) ArrayList(java.util.ArrayList) PartitionLocation(com.tencent.angel.ml.matrix.PartitionLocation)

Example 5 with PSLocation

use of com.tencent.angel.ps.server.data.PSLocation in project angel by Tencent.

the class PSAgentMatrixMetaManager method getPartLocation.

/**
 * Get partition location: includes stored pss and the location of the pss
 *
 * @param partitionKey partition information
 * @return partition location
 * @throws ServiceException
 */
public PartitionLocation getPartLocation(PartitionKey partitionKey) {
    List<ParameterServerId> psIds = getPss(partitionKey);
    if (psIds == null) {
        return new PartitionLocation(new ArrayList<>());
    }
    int size = psIds.size();
    List<PSLocation> psLocs = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        psLocs.add(new PSLocation(psIds.get(i), PSAgentContext.get().getLocationManager().getPsLocation(psIds.get(i))));
    }
    return new PartitionLocation(psLocs);
}
Also used : PSLocation(com.tencent.angel.ps.server.data.PSLocation) ParameterServerId(com.tencent.angel.ps.ParameterServerId) PartitionLocation(com.tencent.angel.ml.matrix.PartitionLocation)

Aggregations

PSLocation (com.tencent.angel.ps.server.data.PSLocation)10 ParameterServerId (com.tencent.angel.ps.ParameterServerId)6 PartitionLocation (com.tencent.angel.ml.matrix.PartitionLocation)5 Location (com.tencent.angel.common.location.Location)2 ArrayList (java.util.ArrayList)2 PartitionKey (com.tencent.angel.PartitionKey)1 MLProtos (com.tencent.angel.protobuf.generated.MLProtos)1 GetPSLocationReponse (com.tencent.angel.protobuf.generated.MLProtos.GetPSLocationReponse)1 GetPartLocationResponse (com.tencent.angel.protobuf.generated.MLProtos.GetPartLocationResponse)1 PSFailedReportProto (com.tencent.angel.protobuf.generated.MLProtos.PSFailedReportProto)1 RecoverPartKey (com.tencent.angel.ps.ha.RecoverPartKey)1 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1