Search in sources :

Example 1 with GlobalTask

use of com.alibaba.otter.node.etl.common.task.GlobalTask in project otter by alibaba.

the class OtterController method stop.

public void stop() throws Throwable {
    for (Map<StageType, GlobalTask> tasks : controllers.values()) {
        for (GlobalTask task : tasks.values()) {
            try {
                task.shutdown();
            } catch (Exception e) {
                logger.error("##shutdown task error!", e);
            }
        }
    }
    try {
        Long nid = configClientService.currentNode().getId();
        arbitrateManageService.nodeEvent().destory(Long.valueOf(nid));
    } catch (Exception e) {
        logger.error("##destory node error!", e);
    }
    try {
        arbitrateEventService.toolEvent().release();
    } catch (Exception e) {
        logger.error("##destory arbitrate error!", e);
    }
    try {
        // 通知manager停止当前node
        nodeTaskService.stopNode();
    } catch (Exception e) {
        logger.error("##stop node error!", e);
    }
    try {
        OtterContextLocator.close();
    } catch (Exception e) {
        logger.error("##cloes spring error!", e);
    }
    // 关闭zookeeper
    ZooKeeperClient.destory();
}
Also used : StageType(com.alibaba.otter.shared.common.model.config.enums.StageType) GlobalTask(com.alibaba.otter.node.etl.common.task.GlobalTask) ConfigException(com.alibaba.otter.shared.common.model.config.ConfigException)

Example 2 with GlobalTask

use of com.alibaba.otter.node.etl.common.task.GlobalTask in project otter by alibaba.

the class OtterController method stopTask.

private void stopTask(Map<StageType, GlobalTask> tasks, StageType taskType) {
    GlobalTask task = tasks.remove(taskType);
    if (task != null) {
        task.shutdown();
        logger.info("INFO ## taskName = {} has shutdown", taskType);
    } else {
        logger.info("INFo ## taskName = {} is not started", taskType);
    }
}
Also used : GlobalTask(com.alibaba.otter.node.etl.common.task.GlobalTask)

Example 3 with GlobalTask

use of com.alibaba.otter.node.etl.common.task.GlobalTask in project otter by alibaba.

the class OtterController method startPipeline.

// ===================== helper method ======================
public void startPipeline(NodeTask nodeTask) {
    Long pipelineId = nodeTask.getPipeline().getId();
    releasePipeline(pipelineId);
    Map<StageType, GlobalTask> tasks = controllers.get(pipelineId);
    // 处理具体的任务命令
    List<StageType> stage = nodeTask.getStage();
    List<TaskEvent> event = nodeTask.getEvent();
    for (int i = 0; i < stage.size(); i++) {
        StageType stageType = stage.get(i);
        TaskEvent taskEvent = event.get(i);
        if (taskEvent.isCreate()) {
            startTask(nodeTask.getPipeline(), tasks, stageType);
        } else {
            stopTask(tasks, stageType);
        }
    }
}
Also used : StageType(com.alibaba.otter.shared.common.model.config.enums.StageType) TaskEvent(com.alibaba.otter.node.common.config.model.NodeTask.TaskEvent) GlobalTask(com.alibaba.otter.node.etl.common.task.GlobalTask)

Example 4 with GlobalTask

use of com.alibaba.otter.node.etl.common.task.GlobalTask in project otter by alibaba.

the class OtterController method startTask.

private void startTask(Pipeline pipeline, Map<StageType, GlobalTask> tasks, StageType taskType) {
    if (tasks.get(taskType) != null && tasks.get(taskType).isAlive()) {
        logger.warn("WARN ## this task = {} has started", taskType);
    }
    GlobalTask task = null;
    if (taskType.isSelect()) {
        task = new SelectTask(pipeline.getId());
    } else if (taskType.isExtract()) {
        task = new ExtractTask(pipeline.getId());
    } else if (taskType.isTransform()) {
        task = new TransformTask(pipeline.getId());
    } else if (taskType.isLoad()) {
        task = new LoadTask(pipeline.getId());
    }
    if (task != null) {
        // 注入一下spring资源
        OtterContextLocator.autowire(task);
        task.start();
        tasks.put(taskType, task);
        logger.info("INFO ## start this task = {} success", taskType.toString());
    }
}
Also used : LoadTask(com.alibaba.otter.node.etl.load.LoadTask) ExtractTask(com.alibaba.otter.node.etl.extract.ExtractTask) TransformTask(com.alibaba.otter.node.etl.transform.TransformTask) GlobalTask(com.alibaba.otter.node.etl.common.task.GlobalTask) SelectTask(com.alibaba.otter.node.etl.select.SelectTask)

Example 5 with GlobalTask

use of com.alibaba.otter.node.etl.common.task.GlobalTask in project otter by alibaba.

the class OtterController method stopPipeline.

private void stopPipeline(Long pipelineId, Map<StageType, GlobalTask> tasks) {
    for (GlobalTask task : tasks.values()) {
        try {
            task.shutdown();
        } catch (Exception e) {
            logger.error("## stop s/e/t/l task error!", e);
        } finally {
            tasks.remove(task);
        }
    }
    // close other resources.
    try {
        // sleep 5s,等待S.E.T.L释放线程
        Thread.sleep(1 * 1000);
    } catch (InterruptedException e) {
        logger.error("ERROR ## ", e);
    }
    // 释放资源
    releasePipeline(pipelineId);
    arbitrateEventService.toolEvent().release(pipelineId);
}
Also used : GlobalTask(com.alibaba.otter.node.etl.common.task.GlobalTask) ConfigException(com.alibaba.otter.shared.common.model.config.ConfigException)

Aggregations

GlobalTask (com.alibaba.otter.node.etl.common.task.GlobalTask)6 StageType (com.alibaba.otter.shared.common.model.config.enums.StageType)3 ConfigException (com.alibaba.otter.shared.common.model.config.ConfigException)2 NodeTask (com.alibaba.otter.node.common.config.model.NodeTask)1 TaskEvent (com.alibaba.otter.node.common.config.model.NodeTask.TaskEvent)1 ExtractTask (com.alibaba.otter.node.etl.extract.ExtractTask)1 LoadTask (com.alibaba.otter.node.etl.load.LoadTask)1 SelectTask (com.alibaba.otter.node.etl.select.SelectTask)1 TransformTask (com.alibaba.otter.node.etl.transform.TransformTask)1