Search in sources :

Example 1 with GetTaskMatrixClockResponse

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();
}
Also used : GetTaskMatrixClockResponse(com.tencent.angel.protobuf.generated.PSMasterServiceProtos.GetTaskMatrixClockResponse) TaskMatrixClock(com.tencent.angel.protobuf.generated.PSMasterServiceProtos.TaskMatrixClock) Int2IntOpenHashMap(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap) MatrixClock(com.tencent.angel.protobuf.generated.MLProtos.MatrixClock) TaskMatrixClock(com.tencent.angel.protobuf.generated.PSMasterServiceProtos.TaskMatrixClock) AMTaskManager(com.tencent.angel.master.task.AMTaskManager) AMTask(com.tencent.angel.master.task.AMTask)

Aggregations

AMTask (com.tencent.angel.master.task.AMTask)1 AMTaskManager (com.tencent.angel.master.task.AMTaskManager)1 MatrixClock (com.tencent.angel.protobuf.generated.MLProtos.MatrixClock)1 GetTaskMatrixClockResponse (com.tencent.angel.protobuf.generated.PSMasterServiceProtos.GetTaskMatrixClockResponse)1 TaskMatrixClock (com.tencent.angel.protobuf.generated.PSMasterServiceProtos.TaskMatrixClock)1 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1