use of com.tencent.angel.master.worker.workergroup.AMWorkerGroupEvent in project angel by Tencent.
the class WorkerManager method initWorkers.
private void initWorkers() {
int base = 0;
// init all tasks , workers and worker groups and put them to the corresponding maps
for (int i = 0; i < workergroupNumber; i++) {
Map<WorkerId, AMWorker> workers = new HashMap<WorkerId, AMWorker>();
WorkerId leader = null;
WorkerGroupId groupId = new WorkerGroupId(i);
for (int j = 0; j < workersInGroup; j++) {
base = (i * workersInGroup + j) * taskNumberInEachWorker;
List<TaskId> taskIds = new ArrayList<TaskId>(taskNumberInEachWorker);
for (int k = 0; k < taskNumberInEachWorker && (base < totalTaskNumber); k++, base++) {
taskIds.add(new TaskId(base));
}
WorkerId workerId = new WorkerId(groupId, i * workersInGroup + j);
AMWorker worker = new AMWorker(workerId, context, taskIds);
workersMap.put(workerId, worker);
workers.put(workerId, worker);
if (j == 0) {
leader = workerId;
}
}
AMWorkerGroup group = new AMWorkerGroup(groupId, context, workers, leader, i);
for (WorkerId id : workers.keySet()) {
findWorkerGroupMap.put(id, group);
for (TaskId taskId : workers.get(id).getTaskIds()) {
taskIdToWorkerMap.put(taskId, workers.get(id));
}
}
workerGroupMap.put(groupId, group);
group.handle(new AMWorkerGroupEvent(AMWorkerGroupEventType.INIT, groupId));
}
LOG.info("to init taskClockManager!");
}
Aggregations