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);
}
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;
}
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();
}
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);
}
}
}
}
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);
}
Aggregations