Search in sources :

Example 1 with WorkerAttemptIdProto

use of com.tencent.angel.protobuf.generated.MLProtos.WorkerAttemptIdProto in project angel by Tencent.

the class ProtobufUtil method buildWorkerMetaProto.

private static WorkerMetaInfoProto buildWorkerMetaProto(AMWorker worker) {
    WorkerMetaInfoProto.Builder builder = WorkerMetaInfoProto.newBuilder();
    WorkerAttempt attempt = worker.getRunningAttempt();
    WorkerAttemptIdProto workerAttemptIdProto = convertToIdProto(attempt.getId());
    Location location = attempt.getLocation();
    WorkerLocationProto.Builder locBuilder = WorkerLocationProto.newBuilder();
    locBuilder.setWorkerAttemptId(workerAttemptIdProto);
    if (location != null) {
        locBuilder.setLocation(buildLocation(location));
    }
    builder.setWorkerLocation(locBuilder.build());
    TaskMetaInfoProto.Builder taskMetaBuilder = TaskMetaInfoProto.newBuilder();
    MatrixClock.Builder clockBuilder = MatrixClock.newBuilder();
    for (Entry<TaskId, AMTask> taskEntry : attempt.getTaskMap().entrySet()) {
        AMTask task = taskEntry.getValue();
        taskMetaBuilder.setTaskId(convertToIdProto(taskEntry.getKey()));
        taskMetaBuilder.setIteration(task.getIteration());
        Int2IntOpenHashMap matrixClocks = task.getMatrixClocks();
        for (it.unimi.dsi.fastutil.ints.Int2IntMap.Entry clockEntry : matrixClocks.int2IntEntrySet()) {
            taskMetaBuilder.addMatrixClock(clockBuilder.setMatrixId(clockEntry.getIntKey()).setClock(clockEntry.getIntValue()).build());
        }
        builder.addTasks(taskMetaBuilder.build());
        LOG.debug("task meta=" + taskMetaBuilder.build());
    }
    return builder.build();
}
Also used : WorkerMetaInfoProto(com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.WorkerMetaInfoProto) TaskId(com.tencent.angel.worker.task.TaskId) Int2IntOpenHashMap(it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap) TaskMetaInfoProto(com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.TaskMetaInfoProto) MatrixClock(com.tencent.angel.protobuf.generated.MLProtos.MatrixClock) WorkerAttempt(com.tencent.angel.master.worker.attempt.WorkerAttempt) WorkerAttemptIdProto(com.tencent.angel.protobuf.generated.MLProtos.WorkerAttemptIdProto) WorkerLocationProto(com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.WorkerLocationProto) AMTask(com.tencent.angel.master.task.AMTask) PSLocation(com.tencent.angel.ps.server.data.PSLocation) Location(com.tencent.angel.common.location.Location)

Example 2 with WorkerAttemptIdProto

use of com.tencent.angel.protobuf.generated.MLProtos.WorkerAttemptIdProto in project angel by Tencent.

the class ProtobufUtil method convertToIdProto.

public static WorkerAttemptIdProto convertToIdProto(WorkerAttemptId id) {
    WorkerAttemptIdProto idProto = workerAttemptIdToProtoMap.get(id);
    if (idProto == null) {
        idProto = WorkerAttemptIdProto.newBuilder().setWorkerId(convertToIdProto(id.getWorkerId())).setAttemptIndex(id.getIndex()).build();
        workerAttemptIdToProtoMap.put(id, idProto);
    }
    return idProto;
}
Also used : WorkerAttemptIdProto(com.tencent.angel.protobuf.generated.MLProtos.WorkerAttemptIdProto)

Aggregations

WorkerAttemptIdProto (com.tencent.angel.protobuf.generated.MLProtos.WorkerAttemptIdProto)2 Location (com.tencent.angel.common.location.Location)1 AMTask (com.tencent.angel.master.task.AMTask)1 WorkerAttempt (com.tencent.angel.master.worker.attempt.WorkerAttempt)1 MatrixClock (com.tencent.angel.protobuf.generated.MLProtos.MatrixClock)1 TaskMetaInfoProto (com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.TaskMetaInfoProto)1 WorkerLocationProto (com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.WorkerLocationProto)1 WorkerMetaInfoProto (com.tencent.angel.protobuf.generated.WorkerMasterServiceProtos.WorkerMetaInfoProto)1 PSLocation (com.tencent.angel.ps.server.data.PSLocation)1 TaskId (com.tencent.angel.worker.task.TaskId)1 Int2IntOpenHashMap (it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap)1