Search in sources :

Example 1 with IJobStatusConditionVariable

use of org.apache.hyracks.control.cc.job.IJobStatusConditionVariable in project asterixdb by apache.

the class WaitForJobCompletionWork method doRun.

@Override
protected void doRun() throws Exception {
    IJobManager jobManager = ccs.getJobManager();
    final IJobStatusConditionVariable cRunningVar = jobManager.get(jobId);
    if (cRunningVar != null) {
        ccs.getExecutor().execute(new Runnable() {

            @Override
            public void run() {
                try {
                    cRunningVar.waitForCompletion();
                    callback.setValue(null);
                } catch (Exception e) {
                    callback.setException(e);
                }
            }
        });
    } else {
        final List<Exception> exceptions = jobManager.getExceptionHistory(jobId);
        ccs.getExecutor().execute(new Runnable() {

            @Override
            public void run() {
                callback.setValue(null);
                if (exceptions != null && !exceptions.isEmpty()) {
                    /**
                         * only report the first exception because IResultCallback will only throw one exception
                         * anyway
                         */
                    callback.setException(exceptions.get(0));
                }
            }
        });
    }
}
Also used : IJobStatusConditionVariable(org.apache.hyracks.control.cc.job.IJobStatusConditionVariable) IJobManager(org.apache.hyracks.control.cc.job.IJobManager)

Aggregations

IJobManager (org.apache.hyracks.control.cc.job.IJobManager)1 IJobStatusConditionVariable (org.apache.hyracks.control.cc.job.IJobStatusConditionVariable)1