Search in sources :

Example 16 with INcApplicationContext

use of org.apache.asterix.common.api.INcApplicationContext 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

INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)16 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)8 ACIDException (org.apache.asterix.common.exceptions.ACIDException)4 ITransactionContext (org.apache.asterix.common.transactions.ITransactionContext)3 ITransactionManager (org.apache.asterix.common.transactions.ITransactionManager)3 IDatasetLifecycleManager (org.apache.asterix.common.api.IDatasetLifecycleManager)2 ILibraryManager (org.apache.asterix.common.library.ILibraryManager)2 PrimaryIndexLogMarkerCallback (org.apache.asterix.common.transactions.PrimaryIndexLogMarkerCallback)2 VSizeFrame (org.apache.hyracks.api.comm.VSizeFrame)2 IJobletEventListener (org.apache.hyracks.api.job.IJobletEventListener)2 JobStatus (org.apache.hyracks.api.job.JobStatus)2 NodeControllerService (org.apache.hyracks.control.nc.NodeControllerService)2 FrameTupleAccessor (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor)2 FrameTupleAppender (org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender)2 FrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.FrameTupleReference)2 DataOutput (java.io.DataOutput)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1