Search in sources :

Example 36 with ACIDException

use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.

the class MetadataNode method addFeed.

@Override
public void addFeed(JobId jobId, Feed feed) throws MetadataException, RemoteException {
    try {
        // Insert into the 'Feed' dataset.
        FeedTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getFeedTupleTranslator(true);
        ITupleReference feedTuple = tupleReaderWriter.getTupleFromMetadataEntity(feed);
        insertTupleIntoIndex(jobId, MetadataPrimaryIndexes.FEED_DATASET, feedTuple);
    } catch (HyracksDataException e) {
        if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.DUPLICATE_KEY) {
            throw new MetadataException("A feed with this name " + feed.getFeedName() + " already exists in dataverse '" + feed.getDataverseName() + "'.", e);
        } else {
            throw new MetadataException(e);
        }
    } catch (ACIDException e) {
        throw new MetadataException(e);
    }
}
Also used : ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) FeedTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.FeedTupleTranslator) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 37 with ACIDException

use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.

the class MetadataNode method addLibrary.

@Override
public void addLibrary(JobId jobId, Library library) throws MetadataException, RemoteException {
    try {
        // Insert into the 'Library' dataset.
        LibraryTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getLibraryTupleTranslator(true);
        ITupleReference libraryTuple = tupleReaderWriter.getTupleFromMetadataEntity(library);
        insertTupleIntoIndex(jobId, MetadataPrimaryIndexes.LIBRARY_DATASET, libraryTuple);
    } catch (HyracksDataException e) {
        if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.DUPLICATE_KEY) {
            throw new MetadataException("A library with this name " + library.getDataverseName() + " already exists in dataverse '" + library.getDataverseName() + "'.", e);
        } else {
            throw new MetadataException(e);
        }
    } catch (ACIDException e) {
        throw new MetadataException(e);
    }
}
Also used : ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) LibraryTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.LibraryTupleTranslator) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 38 with ACIDException

use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.

the class MetadataNode method dropDatatype.

@Override
public void dropDatatype(JobId jobId, String dataverseName, String datatypeName) throws MetadataException, RemoteException {
    confirmDatatypeIsUnused(jobId, dataverseName, datatypeName);
    // Delete the datatype entry, including all it's nested anonymous types.
    try {
        ITupleReference searchKey = createTuple(dataverseName, datatypeName);
        // Searches the index for the tuple to be deleted. Acquires an S
        // lock on the 'datatype' dataset.
        ITupleReference tuple = getTupleToBeDeleted(jobId, MetadataPrimaryIndexes.DATATYPE_DATASET, searchKey);
        // Get nested types
        List<String> nestedTypes = getNestedComplexDatatypeNamesForThisDatatype(jobId, dataverseName, datatypeName);
        deleteTupleFromIndex(jobId, MetadataPrimaryIndexes.DATATYPE_DATASET, tuple);
        for (String nestedType : nestedTypes) {
            Datatype dt = getDatatype(jobId, dataverseName, nestedType);
            if (dt != null && dt.getIsAnonymous()) {
                dropDatatype(jobId, dataverseName, dt.getDatatypeName());
            }
        }
    // TODO: Change this to be a BTree specific exception, e.g.,
    // BTreeKeyDoesNotExistException.
    } catch (HyracksDataException e) {
        if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.UPDATE_OR_DELETE_NON_EXISTENT_KEY) {
            throw new MetadataException("Cannot drop type '" + datatypeName + "' because it doesn't exist", e);
        } else {
            throw new MetadataException(e);
        }
    } catch (ACIDException e) {
        throw new MetadataException(e);
    }
}
Also used : ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) AString(org.apache.asterix.om.base.AString) AMutableString(org.apache.asterix.om.base.AMutableString) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) Datatype(org.apache.asterix.metadata.entities.Datatype) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 39 with ACIDException

use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.

the class MetadataNode method updateFunction.

@Override
public void updateFunction(JobId jobId, Function function) throws MetadataException, RemoteException {
    try {
        // remove old function
        ITupleReference searchKey;
        searchKey = createTuple(function.getDataverseName(), function.getName(), Integer.toString(function.getArity()));
        ITupleReference functionTuple = getTupleToBeDeleted(jobId, MetadataPrimaryIndexes.FUNCTION_DATASET, searchKey);
        deleteTupleFromIndex(jobId, MetadataPrimaryIndexes.FUNCTION_DATASET, functionTuple);
        // add new function
        FunctionTupleTranslator functionTupleTranslator = tupleTranslatorProvider.getFunctionTupleTranslator(true);
        functionTuple = functionTupleTranslator.getTupleFromMetadataEntity(function);
        insertTupleIntoIndex(jobId, MetadataPrimaryIndexes.FUNCTION_DATASET, functionTuple);
    } catch (HyracksDataException | ACIDException e) {
        throw new MetadataException(e);
    }
}
Also used : ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) FunctionTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.FunctionTupleTranslator) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 40 with ACIDException

use of org.apache.asterix.common.exceptions.ACIDException in project asterixdb by apache.

the class MetadataNode method dropIndex.

@Override
public void dropIndex(JobId jobId, String dataverseName, String datasetName, String indexName) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = createTuple(dataverseName, datasetName, indexName);
        // Searches the index for the tuple to be deleted. Acquires an S
        // lock on the 'index' dataset.
        ITupleReference tuple = getTupleToBeDeleted(jobId, MetadataPrimaryIndexes.INDEX_DATASET, searchKey);
        deleteTupleFromIndex(jobId, MetadataPrimaryIndexes.INDEX_DATASET, tuple);
    // TODO: Change this to be a BTree specific exception, e.g.,
    // BTreeKeyDoesNotExistException.
    } catch (HyracksDataException e) {
        if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.UPDATE_OR_DELETE_NON_EXISTENT_KEY) {
            throw new MetadataException("Cannot drop index '" + datasetName + "." + indexName + "' because it doesn't exist.", e);
        } else {
            throw new MetadataException(e);
        }
    } catch (ACIDException e) {
        throw new MetadataException(e);
    }
}
Also used : ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Aggregations

ACIDException (org.apache.asterix.common.exceptions.ACIDException)70 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)54 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)31 ITransactionContext (org.apache.asterix.common.transactions.ITransactionContext)14 IOException (java.io.IOException)9 ILSMIndex (org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex)9 DatasetLocalResource (org.apache.asterix.common.dataflow.DatasetLocalResource)6 DatasetId (org.apache.asterix.common.transactions.DatasetId)5 ITransactionSubsystem (org.apache.asterix.common.transactions.ITransactionSubsystem)5 LogRecord (org.apache.asterix.common.transactions.LogRecord)5 RemoteException (java.rmi.RemoteException)4 Checkpoint (org.apache.asterix.common.transactions.Checkpoint)4 ILogRecord (org.apache.asterix.common.transactions.ILogRecord)4 IModificationOperationCallback (org.apache.hyracks.storage.common.IModificationOperationCallback)4 HashMap (java.util.HashMap)3 IDatasetLifecycleManager (org.apache.asterix.common.api.IDatasetLifecycleManager)3 INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)3 ITransactionManager (org.apache.asterix.common.transactions.ITransactionManager)3 MetadataTransactionContext (org.apache.asterix.metadata.MetadataTransactionContext)3 IIndex (org.apache.hyracks.storage.common.IIndex)3