Search in sources :

Example 1 with IJobletEventListener

use of org.apache.hyracks.api.job.IJobletEventListener 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 IJobletEventListener

use of org.apache.hyracks.api.job.IJobletEventListener 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)

Example 3 with IJobletEventListener

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

the class Joblet method performCleanup.

private void performCleanup() {
    nodeController.getJobletMap().remove(jobId);
    IJobletEventListener listener = getJobletEventListener();
    if (listener != null) {
        listener.jobletFinish(cleanupStatus);
    }
    close();
    cleanupPending = false;
    try {
        nodeController.getClusterController().notifyJobletCleanup(jobId, nodeController.getId());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : IJobletEventListener(org.apache.hyracks.api.job.IJobletEventListener) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException)

Aggregations

IJobletEventListener (org.apache.hyracks.api.job.IJobletEventListener)3 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 JobStatus (org.apache.hyracks.api.job.JobStatus)2 JobId (org.apache.asterix.common.transactions.JobId)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)1