use of org.apache.asterix.common.transactions.ILockManager 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);
}
}
};
}
Aggregations