use of com.tencent.angel.protobuf.generated.PSMasterServiceProtos.GetTaskMatrixClockResponse in project angel by Tencent.
the class MasterService method getTaskMatrixClocks.
/**
* get clock of all matrices for all task
*
* @param controller rpc controller of protobuf
* @param request contains task id
*/
@Override
public GetTaskMatrixClockResponse getTaskMatrixClocks(RpcController controller, GetTaskMatrixClockRequest request) throws ServiceException {
AMTaskManager taskManager = context.getTaskManager();
Collection<AMTask> tasks = taskManager.getTasks();
GetTaskMatrixClockResponse.Builder builder = GetTaskMatrixClockResponse.newBuilder();
TaskMatrixClock.Builder taskBuilder = TaskMatrixClock.newBuilder();
MatrixClock.Builder matrixClockBuilder = MatrixClock.newBuilder();
Int2IntOpenHashMap matrixClocks = null;
for (AMTask task : tasks) {
taskBuilder.setTaskId(ProtobufUtil.convertToIdProto(task.getTaskId()));
matrixClocks = task.getMatrixClocks();
for (it.unimi.dsi.fastutil.ints.Int2IntMap.Entry entry : matrixClocks.int2IntEntrySet()) {
taskBuilder.addMatrixClocks(matrixClockBuilder.setMatrixId(entry.getIntKey()).setClock(entry.getIntValue()).build());
}
builder.addTaskMatrixClocks(taskBuilder.build());
taskBuilder.clear();
}
return builder.build();
}
Aggregations