Search in sources :

Example 1 with JobStatus

use of org.apache.hyracks.api.job.JobStatus in project asterixdb by apache.

the class JobEventListenerFactory method createListener.

@Override
public IJobletEventListener createListener(final IHyracksJobletContext jobletContext) {
    return new IJobletEventListener() {

        @Override
        public void jobletFinish(JobStatus jobStatus) {
            try {
                ITransactionManager txnManager = ((INcApplicationContext) jobletContext.getServiceContext().getApplicationContext()).getTransactionSubsystem().getTransactionManager();
                ITransactionContext txnContext = txnManager.getTransactionContext(jobId, false);
                txnContext.setWriteTxn(transactionalWrite);
                txnManager.completedTransaction(txnContext, DatasetId.NULL, -1, !(jobStatus == JobStatus.FAILURE));
            } catch (ACIDException e) {
                throw new Error(e);
            }
        }

        @Override
        public void jobletStart() {
            try {
                ((INcApplicationContext) jobletContext.getServiceContext().getApplicationContext()).getTransactionSubsystem().getTransactionManager().getTransactionContext(jobId, true);
            } catch (ACIDException e) {
                throw new Error(e);
            }
        }
    };
}
Also used : JobStatus(org.apache.hyracks.api.job.JobStatus) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) ITransactionManager(org.apache.asterix.common.transactions.ITransactionManager) ITransactionContext(org.apache.asterix.common.transactions.ITransactionContext) IJobletEventListener(org.apache.hyracks.api.job.IJobletEventListener) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 2 with JobStatus

use of org.apache.hyracks.api.job.JobStatus in project asterixdb by apache.

the class FeedEventsListener method finish.

private void finish() throws Exception {
    IHyracksClientConnection hcc = appCtx.getHcc();
    JobStatus status = hcc.getJobStatus(jobId);
    state = status.equals(JobStatus.FAILURE) ? ActivityState.FAILED : ActivityState.STOPPED;
    ActiveLifecycleListener activeLcListener = (ActiveLifecycleListener) appCtx.getActiveLifecycleListener();
    activeLcListener.getNotificationHandler().removeListener(this);
}
Also used : JobStatus(org.apache.hyracks.api.job.JobStatus) IHyracksClientConnection(org.apache.hyracks.api.client.IHyracksClientConnection) ActiveLifecycleListener(org.apache.asterix.active.ActiveLifecycleListener)

Example 3 with JobStatus

use of org.apache.hyracks.api.job.JobStatus in project asterixdb by apache.

the class GetJobStatusWork method doRun.

@Override
protected void doRun() throws Exception {
    try {
        JobRun run = jobManager.get(jobId);
        JobStatus status = run == null ? null : run.getStatus();
        callback.setValue(status);
    } catch (Exception e) {
        callback.setException(e);
    }
}
Also used : JobStatus(org.apache.hyracks.api.job.JobStatus) JobRun(org.apache.hyracks.control.cc.job.JobRun)

Example 4 with JobStatus

use of org.apache.hyracks.api.job.JobStatus in project asterixdb by apache.

the class MultiTransactionJobletEventListenerFactory method createListener.

@Override
public IJobletEventListener createListener(final IHyracksJobletContext jobletContext) {
    return new IJobletEventListener() {

        @Override
        public void jobletFinish(JobStatus jobStatus) {
            try {
                ITransactionManager txnManager = ((INcApplicationContext) jobletContext.getServiceContext().getApplicationContext()).getTransactionSubsystem().getTransactionManager();
                for (JobId jobId : jobIds) {
                    ITransactionContext txnContext = txnManager.getTransactionContext(jobId, false);
                    txnContext.setWriteTxn(transactionalWrite);
                    txnManager.completedTransaction(txnContext, DatasetId.NULL, -1, !(jobStatus == JobStatus.FAILURE));
                }
            } catch (ACIDException e) {
                throw new Error(e);
            }
        }

        @Override
        public void jobletStart() {
            try {
                for (JobId jobId : jobIds) {
                    ((INcApplicationContext) jobletContext.getServiceContext().getApplicationContext()).getTransactionSubsystem().getTransactionManager().getTransactionContext(jobId, true);
                }
            } catch (ACIDException e) {
                throw new Error(e);
            }
        }
    };
}
Also used : JobStatus(org.apache.hyracks.api.job.JobStatus) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) ITransactionManager(org.apache.asterix.common.transactions.ITransactionManager) ITransactionContext(org.apache.asterix.common.transactions.ITransactionContext) IJobletEventListener(org.apache.hyracks.api.job.IJobletEventListener) JobId(org.apache.asterix.common.transactions.JobId) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Aggregations

JobStatus (org.apache.hyracks.api.job.JobStatus)4 INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)2 ACIDException (org.apache.asterix.common.exceptions.ACIDException)2 ITransactionContext (org.apache.asterix.common.transactions.ITransactionContext)2 ITransactionManager (org.apache.asterix.common.transactions.ITransactionManager)2 IJobletEventListener (org.apache.hyracks.api.job.IJobletEventListener)2 ActiveLifecycleListener (org.apache.asterix.active.ActiveLifecycleListener)1 JobId (org.apache.asterix.common.transactions.JobId)1 IHyracksClientConnection (org.apache.hyracks.api.client.IHyracksClientConnection)1 JobRun (org.apache.hyracks.control.cc.job.JobRun)1