Search in sources :

Example 1 with ITransactionSubsystem

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

the class UpsertOperationCallbackFactory method createModificationOperationCallback.

@Override
public IModificationOperationCallback createModificationOperationCallback(LocalResource resource, IHyracksTaskContext ctx, IOperatorNodePushable operatorNodePushable) throws HyracksDataException {
    DatasetLocalResource aResource = (DatasetLocalResource) resource.getResource();
    ITransactionSubsystem txnSubsystem = txnSubsystemProvider.getTransactionSubsystem(ctx);
    IResourceLifecycleManager indexLifeCycleManager = txnSubsystem.getAsterixAppRuntimeContextProvider().getDatasetLifecycleManager();
    ILSMIndex index = (ILSMIndex) indexLifeCycleManager.get(resource.getPath());
    if (index == null) {
        throw new HyracksDataException("Index(id:" + resource.getId() + ") is not registered.");
    }
    try {
        ITransactionContext txnCtx = txnSubsystem.getTransactionManager().getTransactionContext(jobId, false);
        IModificationOperationCallback modCallback = new UpsertOperationCallback(new DatasetId(datasetId), primaryKeyFields, txnCtx, txnSubsystem.getLockManager(), txnSubsystem, resource.getId(), aResource.getPartition(), resourceType, indexOp);
        txnCtx.registerIndexAndCallback(resource.getId(), index, (AbstractOperationCallback) modCallback, true);
        return modCallback;
    } catch (ACIDException e) {
        throw new HyracksDataException(e);
    }
}
Also used : DatasetLocalResource(org.apache.asterix.common.dataflow.DatasetLocalResource) ITransactionContext(org.apache.asterix.common.transactions.ITransactionContext) ILSMIndex(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex) ITransactionSubsystem(org.apache.asterix.common.transactions.ITransactionSubsystem) IResourceLifecycleManager(org.apache.hyracks.storage.common.IResourceLifecycleManager) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IModificationOperationCallback(org.apache.hyracks.storage.common.IModificationOperationCallback) DatasetId(org.apache.asterix.common.transactions.DatasetId) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 2 with ITransactionSubsystem

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

the class SecondaryIndexModificationOperationCallbackFactory method createModificationOperationCallback.

@Override
public IModificationOperationCallback createModificationOperationCallback(LocalResource resource, IHyracksTaskContext ctx, IOperatorNodePushable operatorNodePushable) throws HyracksDataException {
    ITransactionSubsystem txnSubsystem = txnSubsystemProvider.getTransactionSubsystem(ctx);
    IResourceLifecycleManager indexLifeCycleManager = txnSubsystem.getAsterixAppRuntimeContextProvider().getDatasetLifecycleManager();
    ILSMIndex index = (ILSMIndex) indexLifeCycleManager.get(resource.getPath());
    if (index == null) {
        throw new HyracksDataException("Index(id:" + resource.getId() + ") is not registered.");
    }
    try {
        ITransactionContext txnCtx = txnSubsystem.getTransactionManager().getTransactionContext(jobId, false);
        DatasetLocalResource aResource = (DatasetLocalResource) resource.getResource();
        IModificationOperationCallback modCallback = new SecondaryIndexModificationOperationCallback(new DatasetId(datasetId), primaryKeyFields, txnCtx, txnSubsystem.getLockManager(), txnSubsystem, resource.getId(), aResource.getPartition(), resourceType, indexOp);
        txnCtx.registerIndexAndCallback(resource.getId(), index, (AbstractOperationCallback) modCallback, false);
        return modCallback;
    } catch (ACIDException e) {
        throw new HyracksDataException(e);
    }
}
Also used : DatasetLocalResource(org.apache.asterix.common.dataflow.DatasetLocalResource) ITransactionContext(org.apache.asterix.common.transactions.ITransactionContext) ILSMIndex(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex) ITransactionSubsystem(org.apache.asterix.common.transactions.ITransactionSubsystem) IResourceLifecycleManager(org.apache.hyracks.storage.common.IResourceLifecycleManager) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IModificationOperationCallback(org.apache.hyracks.storage.common.IModificationOperationCallback) DatasetId(org.apache.asterix.common.transactions.DatasetId) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 3 with ITransactionSubsystem

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

the class TempDatasetPrimaryIndexModificationOperationCallbackFactory method createModificationOperationCallback.

@Override
public IModificationOperationCallback createModificationOperationCallback(LocalResource resource, IHyracksTaskContext ctx, IOperatorNodePushable operatorNodePushable) throws HyracksDataException {
    ITransactionSubsystem txnSubsystem = txnSubsystemProvider.getTransactionSubsystem(ctx);
    IResourceLifecycleManager indexLifeCycleManager = txnSubsystem.getAsterixAppRuntimeContextProvider().getDatasetLifecycleManager();
    ILSMIndex index = (ILSMIndex) indexLifeCycleManager.get(resource.getPath());
    if (index == null) {
        throw new HyracksDataException("Index(id:" + resource.getId() + ") is not registered.");
    }
    try {
        ITransactionContext txnCtx = txnSubsystem.getTransactionManager().getTransactionContext(jobId, false);
        DatasetLocalResource aResource = (DatasetLocalResource) resource.getResource();
        IModificationOperationCallback modCallback = new TempDatasetIndexModificationOperationCallback(new DatasetId(datasetId), primaryKeyFields, txnCtx, txnSubsystem.getLockManager(), txnSubsystem, resource.getId(), aResource.getPartition(), resourceType, indexOp);
        txnCtx.registerIndexAndCallback(resource.getId(), index, (AbstractOperationCallback) modCallback, true);
        return modCallback;
    } catch (ACIDException e) {
        throw new HyracksDataException(e);
    }
}
Also used : DatasetLocalResource(org.apache.asterix.common.dataflow.DatasetLocalResource) ITransactionContext(org.apache.asterix.common.transactions.ITransactionContext) ILSMIndex(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex) ITransactionSubsystem(org.apache.asterix.common.transactions.ITransactionSubsystem) IResourceLifecycleManager(org.apache.hyracks.storage.common.IResourceLifecycleManager) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IModificationOperationCallback(org.apache.hyracks.storage.common.IModificationOperationCallback) DatasetId(org.apache.asterix.common.transactions.DatasetId) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 4 with ITransactionSubsystem

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

the class TempDatasetSecondaryIndexModificationOperationCallbackFactory method createModificationOperationCallback.

@Override
public IModificationOperationCallback createModificationOperationCallback(LocalResource resource, IHyracksTaskContext ctx, IOperatorNodePushable operatorNodePushable) throws HyracksDataException {
    DatasetLocalResource aResource = (DatasetLocalResource) resource.getResource();
    ITransactionSubsystem txnSubsystem = txnSubsystemProvider.getTransactionSubsystem(ctx);
    IResourceLifecycleManager<IIndex> indexLifeCycleManager = txnSubsystem.getAsterixAppRuntimeContextProvider().getDatasetLifecycleManager();
    ILSMIndex index = (ILSMIndex) indexLifeCycleManager.get(resource.getPath());
    if (index == null) {
        throw new HyracksDataException("Index(id:" + resource.getId() + ") is not registered.");
    }
    try {
        ITransactionContext txnCtx = txnSubsystem.getTransactionManager().getTransactionContext(jobId, false);
        IModificationOperationCallback modCallback = new TempDatasetIndexModificationOperationCallback(new DatasetId(datasetId), primaryKeyFields, txnCtx, txnSubsystem.getLockManager(), txnSubsystem, resource.getId(), aResource.getPartition(), resourceType, indexOp);
        txnCtx.registerIndexAndCallback(resource.getId(), index, (AbstractOperationCallback) modCallback, false);
        return modCallback;
    } catch (ACIDException e) {
        throw new HyracksDataException(e);
    }
}
Also used : DatasetLocalResource(org.apache.asterix.common.dataflow.DatasetLocalResource) IIndex(org.apache.hyracks.storage.common.IIndex) ITransactionContext(org.apache.asterix.common.transactions.ITransactionContext) ILSMIndex(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex) ITransactionSubsystem(org.apache.asterix.common.transactions.ITransactionSubsystem) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IModificationOperationCallback(org.apache.hyracks.storage.common.IModificationOperationCallback) DatasetId(org.apache.asterix.common.transactions.DatasetId) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 5 with ITransactionSubsystem

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

the class PrimaryIndexModificationOperationCallbackFactory method createModificationOperationCallback.

@Override
public IModificationOperationCallback createModificationOperationCallback(LocalResource resource, IHyracksTaskContext ctx, IOperatorNodePushable operatorNodePushable) throws HyracksDataException {
    ITransactionSubsystem txnSubsystem = txnSubsystemProvider.getTransactionSubsystem(ctx);
    IResourceLifecycleManager<IIndex> indexLifeCycleManager = txnSubsystem.getAsterixAppRuntimeContextProvider().getDatasetLifecycleManager();
    ILSMIndex index = (ILSMIndex) indexLifeCycleManager.get(resource.getPath());
    if (index == null) {
        throw new HyracksDataException("Index(id:" + resource.getId() + ") is not registered.");
    }
    try {
        ITransactionContext txnCtx = txnSubsystem.getTransactionManager().getTransactionContext(jobId, false);
        DatasetLocalResource aResource = (DatasetLocalResource) resource.getResource();
        IModificationOperationCallback modCallback = new PrimaryIndexModificationOperationCallback(new DatasetId(datasetId), primaryKeyFields, txnCtx, txnSubsystem.getLockManager(), txnSubsystem, resource.getId(), aResource.getPartition(), resourceType, indexOp, operatorNodePushable);
        txnCtx.registerIndexAndCallback(resource.getId(), index, (AbstractOperationCallback) modCallback, true);
        return modCallback;
    } catch (ACIDException e) {
        throw new HyracksDataException(e);
    }
}
Also used : IIndex(org.apache.hyracks.storage.common.IIndex) DatasetLocalResource(org.apache.asterix.common.dataflow.DatasetLocalResource) ITransactionContext(org.apache.asterix.common.transactions.ITransactionContext) ILSMIndex(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex) ITransactionSubsystem(org.apache.asterix.common.transactions.ITransactionSubsystem) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IModificationOperationCallback(org.apache.hyracks.storage.common.IModificationOperationCallback) DatasetId(org.apache.asterix.common.transactions.DatasetId) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Aggregations

DatasetLocalResource (org.apache.asterix.common.dataflow.DatasetLocalResource)5 ACIDException (org.apache.asterix.common.exceptions.ACIDException)5 DatasetId (org.apache.asterix.common.transactions.DatasetId)5 ITransactionContext (org.apache.asterix.common.transactions.ITransactionContext)5 ITransactionSubsystem (org.apache.asterix.common.transactions.ITransactionSubsystem)5 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)5 ILSMIndex (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex)5 IModificationOperationCallback (org.apache.hyracks.storage.common.IModificationOperationCallback)5 IResourceLifecycleManager (org.apache.hyracks.storage.common.IResourceLifecycleManager)3 IIndex (org.apache.hyracks.storage.common.IIndex)2