Search in sources :

Example 1 with PSAgent

use of com.tencent.angel.psagent.PSAgent in project angel by Tencent.

the class WorkerTest method testPsAgent.

@Test
public void testPsAgent() throws Exception {
    try {
        localWorker = LocalClusterContext.get().getWorker(worker0Attempt0Id);
        worker = localWorker.getWorker();
        // test psAgent
        PSAgent psAgent = worker.getPSAgent();
        assertTrue(psAgent != null);
        PSAgentAttemptId psAgentAttemptId = psAgent.getId();
        Assert.assertEquals(psAgentAttemptId.toString(), "PSAgentAttempt_0_0");
        assertEquals(psAgent.getMasterLocation(), worker.getMasterLocation());
    } catch (Exception x) {
        LOG.error("run testPsAgent failed ", x);
        throw x;
    }
}
Also used : PSAgentAttemptId(com.tencent.angel.psagent.PSAgentAttemptId) PSAgent(com.tencent.angel.psagent.PSAgent) IOException(java.io.IOException) MasterServiceTest(com.tencent.angel.master.MasterServiceTest)

Example 2 with PSAgent

use of com.tencent.angel.psagent.PSAgent 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);
}
Also used : TaskManager(com.tencent.angel.worker.task.TaskManager) DataBlockManager(com.tencent.angel.worker.storage.DataBlockManager) PSAgent(com.tencent.angel.psagent.PSAgent)

Aggregations

PSAgent (com.tencent.angel.psagent.PSAgent)2 MasterServiceTest (com.tencent.angel.master.MasterServiceTest)1 PSAgentAttemptId (com.tencent.angel.psagent.PSAgentAttemptId)1 DataBlockManager (com.tencent.angel.worker.storage.DataBlockManager)1 TaskManager (com.tencent.angel.worker.task.TaskManager)1 IOException (java.io.IOException)1