Search in sources :

Example 6 with PSLocation

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

the class MasterClient method getPartLocation.

/**
 * Get the pss and their locations that stored the partition
 *
 * @param matrixId matrix id
 * @param partId   partition id
 * @return the pss and their locations that stored the partition
 * @throws ServiceException
 */
public PartitionLocation getPartLocation(int matrixId, int partId) throws ServiceException {
    GetPartLocationResponse response = master.getPartLocation(null, GetPartLocationRequest.newBuilder().setMatrixId(matrixId).setPartId(partId).build());
    List<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) PartitionLocation(com.tencent.angel.ml.matrix.PartitionLocation)

Example 7 with PSLocation

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

the class ProtobufUtil method convert.

public static HashMap<PSLocation, Integer> convert(PSFailedReportsProto reportsProto) {
    HashMap<PSLocation, Integer> reports = new HashMap<>();
    List<PSFailedReportProto> reportList = reportsProto.getPsFailedReportsList();
    int size = reportList.size();
    for (int i = 0; i < size; i++) {
        reports.put(new PSLocation(convertToId(reportList.get(i).getPsLoc().getPsId()), convert(reportList.get(i).getPsLoc().getLocation())), reportList.get(i).getFailedCounter());
    }
    return reports;
}
Also used : PSLocation(com.tencent.angel.ps.server.data.PSLocation) Int2IntOpenHashMap(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) PSFailedReportProto(com.tencent.angel.protobuf.generated.MLProtos.PSFailedReportProto)

Example 8 with PSLocation

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

the class MasterService method psFailedReport.

@Override
public PSFailedReportResponse psFailedReport(RpcController controller, PSFailedReportRequest request) throws ServiceException {
    LOG.info("Receive client ps failed report " + request);
    PSLocation psLoc = ProtobufUtil.convert(request.getPsLoc());
    context.getParameterServerManager().psFailedReport(psLoc);
    return PSFailedReportResponse.newBuilder().build();
}
Also used : PSLocation(com.tencent.angel.ps.server.data.PSLocation)

Example 9 with PSLocation

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

the class AMMatrixMetaManager method handlePartReport.

private void handlePartReport(ParameterServerId psId, int matrixId, PartReport partReport) {
    ParameterServerId master = matrixMetaManager.getMasterPs(matrixId, partReport.partId);
    if (!psId.equals(master)) {
        MatrixMeta matrixMeta = matrixMetaManager.getMatrixMeta(matrixId);
        if (matrixMeta == null) {
            return;
        }
        matrixMeta.getPartitionMeta(partReport.partId).addReplicationPS(psId);
        if (partReport.state == PartitionState.INITIALIZING) {
            addNeedRecoverPart(master, new RecoverPartKey(new PartitionKey(matrixId, partReport.partId), new PSLocation(psId, context.getLocationManager().getPsLocation(psId))));
        } else if (partReport.state == PartitionState.READ_AND_WRITE) {
            ParameterServerId orignalMaster = matrixPartitionsOnPS.get(psId).get(matrixId).getPartitionMeta(partReport.partId).getMasterPs();
            if (orignalMaster.equals(psId)) {
                matrixMetaManager.getMatrixMeta(matrixId).getPartitionMeta(partReport.partId).makePsToMaster(psId);
            }
        }
    }
}
Also used : RecoverPartKey(com.tencent.angel.ps.ha.RecoverPartKey) PSLocation(com.tencent.angel.ps.server.data.PSLocation) PartitionKey(com.tencent.angel.PartitionKey) ParameterServerId(com.tencent.angel.ps.ParameterServerId)

Example 10 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
 * TODO: cache
 *
 * @param matrixId partition information
 * @param partId partition id
 * @return partition location
 * @throws ServiceException
 */
public PartitionLocation getPartLocation(int matrixId, int partId) {
    List<ParameterServerId> psIds = getPss(matrixId, partId);
    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