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