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