use of com.tencent.angel.worker.WorkerGroup in project angel by Tencent.
the class MasterClient method getWorkerGroupMetaInfo.
/**
* Get worker group information:workers and data splits, it will wait until the worker group is ready
*
* @return WorkerGroup worker group information
* @throws ClassNotFoundException split class not found
* @throws IOException deserialize data splits meta failed
* @throws ServiceException rpc failed
* @throws InterruptedException interrupted when wait for next try
*/
public WorkerGroup getWorkerGroupMetaInfo() throws ClassNotFoundException, IOException, ServiceException, InterruptedException {
GetWorkerGroupMetaInfoRequest request = GetWorkerGroupMetaInfoRequest.newBuilder().setWorkerAttemptId(WorkerContext.get().getWorkerAttemptIdProto()).build();
while (true) {
GetWorkerGroupMetaInfoResponse response = master.getWorkerGroupMetaInfo(null, request);
assert (response.getWorkerGroupStatus() != GetWorkerGroupMetaInfoResponse.WorkerGroupStatus.WORKERGROUP_EXITED);
LOG.debug("GetWorkerGroupMetaInfoResponse response=" + response);
if (response.getWorkerGroupStatus() == GetWorkerGroupMetaInfoResponse.WorkerGroupStatus.WORKERGROUP_OK) {
// Deserialize data splits meta
SplitClassification splits = null;
if (response.getWorkerGroupMeta().getSplitsCount() > 0) {
splits = ProtobufUtil.getSplitClassification(response.getWorkerGroupMeta().getSplitsList(), WorkerContext.get().getConf());
}
// Get workers
WorkerGroup group = new WorkerGroup(WorkerContext.get().getWorkerGroupId(), splits);
for (WorkerMetaInfoProto worker : response.getWorkerGroupMeta().getWorkersList()) {
WorkerRef workerRef = new WorkerRef(worker.getWorkerLocation().getWorkerAttemptId(), worker.getWorkerLocation().getLocation(), worker.getTasksList());
group.addWorkerRef(workerRef);
}
return group;
} else {
Thread.sleep(WorkerContext.get().getRequestSleepTimeMS());
}
}
}
Aggregations