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();
}
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);
}
}
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);
}
}
}
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());
}
}
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);
}
Aggregations