use of com.tencent.angel.worker.task.TaskManager in project angel by Tencent.
the class Worker method initAndStart.
/**
* Init and start Worker's components,run tasks through by {@link TaskManager}
*
* @throws Exception the exception
*/
public void initAndStart() throws Exception {
LOG.info("Init and start worker");
psAgent = new PSAgent(conf, masterLocation.getIp(), masterLocation.getPort(), workerAttemptId.getWorkerId().getIndex(), false, this);
dataBlockManager = new DataBlockManager();
taskManager = new TaskManager();
LOG.info("Init and start psagent for worker");
psAgent.initAndStart();
LOG.info("Init data block manager");
dataBlockManager.init();
LOG.info("Init and start worker rpc server");
workerService = new WorkerService();
workerService.start();
LOG.info("Init counter updater");
counterUpdater.initialize();
// init task manager and start tasks
masterClient = psAgent.getMasterClient();
// start heartbeat thread
LOG.info("Register to master and start the heartbeat thread");
startHeartbeatThread();
LOG.info("Get data splits from master");
workerGroup = masterClient.getWorkerGroupMetaInfo();
dataBlockManager.setSplitClassification(workerGroup.getSplits());
LOG.info("Init and start task manager and all task");
taskManager.init();
taskManager.startAllTasks(workerGroup.getWorkerRef(workerAttemptId.getWorkerId()).getTaskIdToContextMap());
workerInitFinishedFlag.set(true);
}
use of com.tencent.angel.worker.task.TaskManager in project angel by Tencent.
the class WorkerTest method testWorkerTaskManager.
@Test
public void testWorkerTaskManager() throws Exception {
try {
LOG.info("===========================testWorkerInitAndStart===============================");
localWorker = LocalClusterContext.get().getWorker(worker0Attempt0Id);
worker = localWorker.getWorker();
// test worker getActiveTaskNum
assertEquals(2, worker.getActiveTaskNum());
// test worker getTaskNum
assertEquals(2, worker.getTaskNum());
// test worker getTaskManager
TaskManager taskManager = worker.getTaskManager();
assertTrue(taskManager != null);
assertEquals(2, taskManager.getTaskCount());
Task task_0 = taskManager.getRunningTask().get(task0Id);
assertTrue(task_0 != null);
Task task_1 = taskManager.getRunningTask().get(task1Id);
assertTrue(task_1 != null);
assertTrue(taskManager.isAllTaskRunning());
} catch (Exception x) {
LOG.error("run testWorkerTaskManager failed ", x);
throw x;
}
}
Aggregations