Search in sources :

Example 1 with TISReactor

use of com.qlangtech.tis.fullbuild.taskflow.TISReactor in project tis by qlangtech.

the class DataFlowAppSource method executeDAG.

private ExecuteResult executeDAG(IExecChainContext execChainContext, SqlTaskNodeMeta.SqlDataFlowTopology topology, IDataProcessFeedback dataProcessFeedback, Map<String, TISReactor.TaskAndMilestone> taskMap) {
    final ExecuteResult[] faildResult = new ExecuteResult[1];
    try {
        TISReactor reactor = new TISReactor(execChainContext, taskMap);
        String dagSessionSpec = topology.getDAGSessionSpec();
        logger.info("dagSessionSpec:" + dagSessionSpec);
        // final PrintWriter w = new PrintWriter(sw, true);
        ReactorListener listener = new ReactorListener() {

            // TODO: Does it really needs handlers to be synchronized?
            @Override
            public synchronized void onTaskCompleted(Task t) {
                processTaskResult(execChainContext, (TISReactor.TaskImpl) t, dataProcessFeedback, new ITaskResultProcessor() {

                    @Override
                    public void process(DumpPhaseStatus dumpPhase, TISReactor.TaskImpl task) {
                    }

                    @Override
                    public void process(JoinPhaseStatus joinPhase, TISReactor.TaskImpl task) {
                    }
                });
            }

            @Override
            public synchronized void onTaskFailed(Task t, Throwable err, boolean fatal) {
                // w.println("Failed " + t.getDisplayName() + " with " + err);
                processTaskResult(execChainContext, (TISReactor.TaskImpl) t, dataProcessFeedback, new ITaskResultProcessor() {

                    @Override
                    public void process(DumpPhaseStatus dumpPhase, TISReactor.TaskImpl task) {
                        dataProcessFeedback.reportDumpTableStatusError(execChainContext, task);
                    }

                    @Override
                    public void process(JoinPhaseStatus joinPhase, TISReactor.TaskImpl task) {
                        JoinPhaseStatus.JoinTaskStatus stat = joinPhase.getTaskStatus(task.getIdentityName());
                        // statReceiver.reportBuildIndexStatErr(execContext.getTaskId(),task.getIdentityName());
                        stat.setWaiting(false);
                        stat.setFaild(true);
                        stat.setComplete(true);
                    }
                });
            }
        };
        // 执行DAG地调度
        reactor.execute(executorService, reactor.buildSession(dagSessionSpec), listener, new ReactorListener() {

            @Override
            public void onTaskCompleted(Task t) {
            // dumpPhaseStatus.isComplete();
            // joinPhaseStatus.isComplete();
            }

            @Override
            public void onTaskFailed(Task t, Throwable err, boolean fatal) {
                logger.error(t.getDisplayName(), err);
                faildResult[0] = ExecuteResult.createFaild().setMessage("status.runningStatus.isComplete():" + err.getMessage());
            }
        });
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return faildResult[0];
}
Also used : Task(org.jvnet.hudson.reactor.Task) DataflowTask(com.qlangtech.tis.fullbuild.taskflow.DataflowTask) DumpPhaseStatus(com.qlangtech.tis.fullbuild.phasestatus.impl.DumpPhaseStatus) JoinPhaseStatus(com.qlangtech.tis.fullbuild.phasestatus.impl.JoinPhaseStatus) TISReactor(com.qlangtech.tis.fullbuild.taskflow.TISReactor) ExecuteResult(com.qlangtech.tis.exec.ExecuteResult) ReactorListener(org.jvnet.hudson.reactor.ReactorListener)

Example 2 with TISReactor

use of com.qlangtech.tis.fullbuild.taskflow.TISReactor in project tis by qlangtech.

the class DataXExecuteInterceptor method executeDAG.

private void executeDAG(ExecutorService executorService, IExecChainContext execChainContext, String dagSessionSpec, Map<String, TISReactor.TaskAndMilestone> taskMap, ReactorListener reactorListener) {
    try {
        TISReactor reactor = new TISReactor(execChainContext, taskMap);
        // String dagSessionSpec = topology.getDAGSessionSpec();
        logger.info("dagSessionSpec:" + dagSessionSpec);
        // final PrintWriter w = new PrintWriter(sw, true);
        ReactorListener listener = new ReactorListener() {

            // TODO: Does it really needs handlers to be synchronized?
            // @Override
            // public synchronized void onTaskStarted(Task t) {
            // //        w.println("Started " + t.getDisplayName());
            // }
            @Override
            public synchronized void onTaskCompleted(Task t) {
            // w.println("Ended " + t.getDisplayName());
            // processTaskResult(execChainContext, (TISReactor.TaskImpl) t, new ITaskResultProcessor() {
            // @Override
            // public void process(DumpPhaseStatus dumpPhase, TISReactor.TaskImpl task) {
            // }
            // 
            // @Override
            // public void process(JoinPhaseStatus joinPhase, TISReactor.TaskImpl task) {
            // }
            // });
            }

            @Override
            public synchronized void onTaskFailed(Task t, Throwable err, boolean fatal) {
            // w.println("Failed " + t.getDisplayName() + " with " + err);
            // processTaskResult(execChainContext, (TISReactor.TaskImpl) t, new ITaskResultProcessor() {
            // 
            // @Override
            // public void process(DumpPhaseStatus dumpPhase, TISReactor.TaskImpl task) {
            // IncrStatusUmbilicalProtocolImpl statReceiver = IncrStatusUmbilicalProtocolImpl.getInstance();
            // statReceiver.reportDumpTableStatusError(execChainContext.getTaskId(), task.getIdentityName());
            // }
            // 
            // @Override
            // public void process(JoinPhaseStatus joinPhase, TISReactor.TaskImpl task) {
            // JoinPhaseStatus.JoinTaskStatus stat = joinPhase.getTaskStatus(task.getIdentityName());
            // // statReceiver.reportBuildIndexStatErr(execContext.getTaskId(),task.getIdentityName());
            // stat.setWaiting(false);
            // stat.setFaild(true);
            // stat.setComplete(true);
            // }
            // });
            }
        };
        // 执行DAG地调度
        // executorService
        reactor.execute(executorService, reactor.buildSession(dagSessionSpec), listener, reactorListener);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : Task(org.jvnet.hudson.reactor.Task) DataflowTask(com.qlangtech.tis.fullbuild.taskflow.DataflowTask) TISReactor(com.qlangtech.tis.fullbuild.taskflow.TISReactor) ReactorListener(org.jvnet.hudson.reactor.ReactorListener)

Aggregations

DataflowTask (com.qlangtech.tis.fullbuild.taskflow.DataflowTask)2 TISReactor (com.qlangtech.tis.fullbuild.taskflow.TISReactor)2 ReactorListener (org.jvnet.hudson.reactor.ReactorListener)2 Task (org.jvnet.hudson.reactor.Task)2 ExecuteResult (com.qlangtech.tis.exec.ExecuteResult)1 DumpPhaseStatus (com.qlangtech.tis.fullbuild.phasestatus.impl.DumpPhaseStatus)1 JoinPhaseStatus (com.qlangtech.tis.fullbuild.phasestatus.impl.JoinPhaseStatus)1