Search in sources :

Example 1 with WorkerAttemptEvent

use of com.tencent.angel.master.worker.attempt.WorkerAttemptEvent in project angel by Tencent.

the class LocalContainerLauncher method launch.

@SuppressWarnings("unchecked")
private void launch(ContainerLauncherEvent event) {
    Id id = event.getId();
    if (id instanceof PSAttemptId) {
        LocalPS ps = new LocalPS((PSAttemptId) id, context.getMasterService().getLocation(), context.getConf());
        context.getEventHandler().handle(new PSAttemptEvent(PSAttemptEventType.PA_CONTAINER_LAUNCHED, (PSAttemptId) id));
        try {
            ps.start();
            LocalClusterContext.get().addPS((PSAttemptId) id, ps);
        } catch (Exception e) {
            LOG.error("launch ps failed.", e);
            context.getEventHandler().handle(new PSAttemptEvent(PSAttemptEventType.PA_CONTAINER_LAUNCH_FAILED, (PSAttemptId) id));
        }
    } else if (id instanceof PSAgentAttemptId) {
        context.getEventHandler().handle(new PSAgentAttemptEvent(PSAgentAttemptEventType.PSAGENT_ATTEMPT_CONTAINER_LAUNCHED, (PSAgentAttemptId) id));
    } else if (id instanceof WorkerAttemptId) {
        LocalWorker worker = new LocalWorker(context.getConf(), context.getApplicationId(), context.getUser(), (WorkerAttemptId) id, context.getMasterService().getLocation(), 0, false);
        context.getEventHandler().handle(new WorkerAttemptEvent(WorkerAttemptEventType.CONTAINER_LAUNCHED, (WorkerAttemptId) id));
        try {
            worker.start();
            LocalClusterContext.get().addWorker((WorkerAttemptId) id, worker);
        } catch (Exception e) {
            LOG.error("launch worker failed.", e);
            context.getEventHandler().handle(new WorkerAttemptEvent(WorkerAttemptEventType.CONTAINER_LAUNCH_FAILED, (WorkerAttemptId) id));
        }
    }
}
Also used : PSAttemptId(com.tencent.angel.ps.PSAttemptId) PSAgentAttemptEvent(com.tencent.angel.master.psagent.PSAgentAttemptEvent) WorkerAttemptId(com.tencent.angel.worker.WorkerAttemptId) LocalWorker(com.tencent.angel.localcluster.LocalWorker) LocalPS(com.tencent.angel.localcluster.LocalPS) PSAgentAttemptId(com.tencent.angel.psagent.PSAgentAttemptId) WorkerAttemptEvent(com.tencent.angel.master.worker.attempt.WorkerAttemptEvent) PSAttemptId(com.tencent.angel.ps.PSAttemptId) WorkerAttemptId(com.tencent.angel.worker.WorkerAttemptId) Id(com.tencent.angel.common.Id) PSAgentAttemptId(com.tencent.angel.psagent.PSAgentAttemptId) PSAttemptEvent(com.tencent.angel.master.ps.attempt.PSAttemptEvent)

Example 2 with WorkerAttemptEvent

use of com.tencent.angel.master.worker.attempt.WorkerAttemptEvent in project angel by Tencent.

the class AMWorker method addAndScheduleAttempt.

@SuppressWarnings("unchecked")
private void addAndScheduleAttempt() {
    WorkerAttempt attempt = null;
    writeLock.lock();
    try {
        // init a worker attempt for the worker
        attempt = createWorkerAttempt();
        for (TaskId taskId : taskIds) {
            AMTask task = context.getTaskManager().getTask(taskId);
            if (task != null) {
                task.resetCounters();
            }
        }
        attempts.put(attempt.getId(), attempt);
        LOG.info("scheduling " + attempt.getId());
        runningAttemptId = attempt.getId();
        lastAttemptId = attempt.getId();
    } finally {
        writeLock.unlock();
    }
    // schedule the worker attempt
    context.getEventHandler().handle(new WorkerAttemptEvent(WorkerAttemptEventType.SCHEDULE, attempt.getId()));
}
Also used : TaskId(com.tencent.angel.worker.task.TaskId) WorkerAttempt(com.tencent.angel.master.worker.attempt.WorkerAttempt) WorkerAttemptEvent(com.tencent.angel.master.worker.attempt.WorkerAttemptEvent) AMTask(com.tencent.angel.master.task.AMTask)

Aggregations

WorkerAttemptEvent (com.tencent.angel.master.worker.attempt.WorkerAttemptEvent)2 Id (com.tencent.angel.common.Id)1 LocalPS (com.tencent.angel.localcluster.LocalPS)1 LocalWorker (com.tencent.angel.localcluster.LocalWorker)1 PSAttemptEvent (com.tencent.angel.master.ps.attempt.PSAttemptEvent)1 PSAgentAttemptEvent (com.tencent.angel.master.psagent.PSAgentAttemptEvent)1 AMTask (com.tencent.angel.master.task.AMTask)1 WorkerAttempt (com.tencent.angel.master.worker.attempt.WorkerAttempt)1 PSAttemptId (com.tencent.angel.ps.PSAttemptId)1 PSAgentAttemptId (com.tencent.angel.psagent.PSAgentAttemptId)1 WorkerAttemptId (com.tencent.angel.worker.WorkerAttemptId)1 TaskId (com.tencent.angel.worker.task.TaskId)1