Search in sources :

Example 1 with ITransactionManager

use of org.apache.asterix.common.transactions.ITransactionManager 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 ITransactionManager

use of org.apache.asterix.common.transactions.ITransactionManager in project asterixdb by apache.

the class AbstractCheckpointManager method capture.

protected void capture(long minMCTFirstLSN, boolean sharp) throws HyracksDataException {
    ILogManager logMgr = txnSubsystem.getLogManager();
    ITransactionManager txnMgr = txnSubsystem.getTransactionManager();
    Checkpoint checkpointObject = new Checkpoint(logMgr.getAppendLSN(), minMCTFirstLSN, txnMgr.getMaxJobId(), System.currentTimeMillis(), sharp, StorageConstants.VERSION);
    persist(checkpointObject);
    cleanup();
}
Also used : Checkpoint(org.apache.asterix.common.transactions.Checkpoint) ITransactionManager(org.apache.asterix.common.transactions.ITransactionManager) ILogManager(org.apache.asterix.common.transactions.ILogManager)

Example 3 with ITransactionManager

use of org.apache.asterix.common.transactions.ITransactionManager in project asterixdb by apache.

the class FlushDatasetOperatorDescriptor method createPushRuntime.

@Override
public IOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx, IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) throws HyracksDataException {
    return new AbstractUnaryInputSinkOperatorNodePushable() {

        @Override
        public void open() throws HyracksDataException {
        }

        @Override
        public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
        }

        @Override
        public void fail() throws HyracksDataException {
            this.close();
        }

        @Override
        public void close() throws HyracksDataException {
            try {
                INcApplicationContext appCtx = (INcApplicationContext) ctx.getJobletContext().getServiceContext().getApplicationContext();
                IDatasetLifecycleManager datasetLifeCycleManager = appCtx.getDatasetLifecycleManager();
                ILockManager lockManager = appCtx.getTransactionSubsystem().getLockManager();
                ITransactionManager txnManager = appCtx.getTransactionSubsystem().getTransactionManager();
                // get the local transaction
                ITransactionContext txnCtx = txnManager.getTransactionContext(jobId, false);
                // lock the dataset granule
                lockManager.lock(datasetId, -1, LockMode.S, txnCtx);
                // flush the dataset synchronously
                datasetLifeCycleManager.flushDataset(datasetId.getId(), false);
            } catch (ACIDException e) {
                throw new HyracksDataException(e);
            }
        }
    };
}
Also used : IDatasetLifecycleManager(org.apache.asterix.common.api.IDatasetLifecycleManager) AbstractUnaryInputSinkOperatorNodePushable(org.apache.hyracks.dataflow.std.base.AbstractUnaryInputSinkOperatorNodePushable) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) ILockManager(org.apache.asterix.common.transactions.ILockManager) ITransactionManager(org.apache.asterix.common.transactions.ITransactionManager) ITransactionContext(org.apache.asterix.common.transactions.ITransactionContext) ByteBuffer(java.nio.ByteBuffer) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 4 with ITransactionManager

use of org.apache.asterix.common.transactions.ITransactionManager 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

ITransactionManager (org.apache.asterix.common.transactions.ITransactionManager)4 INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)3 ACIDException (org.apache.asterix.common.exceptions.ACIDException)3 ITransactionContext (org.apache.asterix.common.transactions.ITransactionContext)3 IJobletEventListener (org.apache.hyracks.api.job.IJobletEventListener)2 JobStatus (org.apache.hyracks.api.job.JobStatus)2 ByteBuffer (java.nio.ByteBuffer)1 IDatasetLifecycleManager (org.apache.asterix.common.api.IDatasetLifecycleManager)1 Checkpoint (org.apache.asterix.common.transactions.Checkpoint)1 ILockManager (org.apache.asterix.common.transactions.ILockManager)1 ILogManager (org.apache.asterix.common.transactions.ILogManager)1 JobId (org.apache.asterix.common.transactions.JobId)1 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1 AbstractUnaryInputSinkOperatorNodePushable (org.apache.hyracks.dataflow.std.base.AbstractUnaryInputSinkOperatorNodePushable)1