Search in sources :

Example 41 with ACIDException

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

the class MetadataNode method addFeedPolicy.

@Override
public void addFeedPolicy(JobId jobId, FeedPolicyEntity feedPolicy) throws MetadataException, RemoteException {
    try {
        // Insert into the 'FeedPolicy' dataset.
        FeedPolicyTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getFeedPolicyTupleTranslator(true);
        ITupleReference feedPolicyTuple = tupleReaderWriter.getTupleFromMetadataEntity(feedPolicy);
        insertTupleIntoIndex(jobId, MetadataPrimaryIndexes.FEED_POLICY_DATASET, feedPolicyTuple);
    } catch (HyracksDataException e) {
        if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.DUPLICATE_KEY) {
            throw new MetadataException("A feed policy with this name " + feedPolicy.getPolicyName() + " already exists in dataverse '" + feedPolicy.getPolicyName() + "'.", 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) FeedPolicyTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.FeedPolicyTupleTranslator) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 42 with ACIDException

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

the class MetadataNode method deleteEntity.

/**
     * Delete entity from index
     *
     * @param jobId
     * @param entity
     * @param tupleTranslator
     * @param index
     * @throws MetadataException
     */
private <T> void deleteEntity(JobId jobId, T entity, IMetadataEntityTupleTranslator<T> tupleTranslator, IMetadataIndex index) throws MetadataException {
    try {
        ITupleReference tuple = tupleTranslator.getTupleFromMetadataEntity(entity);
        deleteTupleFromIndex(jobId, index, tuple);
    } catch (HyracksDataException | 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)

Example 43 with ACIDException

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

the class MetadataNode method dropLibrary.

@Override
public void dropLibrary(JobId jobId, String dataverseName, String libraryName) throws MetadataException, RemoteException {
    Library library = getLibrary(jobId, dataverseName, libraryName);
    if (library == null) {
        throw new MetadataException("Cannot drop library '" + library + "' because it doesn't exist.");
    }
    try {
        // Delete entry from the 'Library' dataset.
        ITupleReference searchKey = createTuple(dataverseName, libraryName);
        // Searches the index for the tuple to be deleted. Acquires an S
        // lock on the 'Adapter' dataset.
        ITupleReference datasetTuple = getTupleToBeDeleted(jobId, MetadataPrimaryIndexes.LIBRARY_DATASET, searchKey);
        deleteTupleFromIndex(jobId, MetadataPrimaryIndexes.LIBRARY_DATASET, datasetTuple);
    // 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 library '" + libraryName, e);
        } else {
            throw new MetadataException(e);
        }
    } catch (ACIDException e) {
        throw new MetadataException(e);
    }
}
Also used : ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) Library(org.apache.asterix.metadata.entities.Library) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 44 with ACIDException

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

the class LogBuffer method notifyFlushTermination.

public void notifyFlushTermination() throws ACIDException {
    LogRecord logRecord = null;
    try {
        logRecord = (LogRecord) flushQ.take();
    } catch (InterruptedException e) {
    //ignore
    }
    synchronized (logRecord) {
        logRecord.isFlushed(true);
        logRecord.notifyAll();
    }
    PrimaryIndexOperationTracker opTracker = logRecord.getOpTracker();
    if (opTracker != null) {
        try {
            opTracker.triggerScheduleFlush(logRecord);
        } catch (HyracksDataException e) {
            throw new ACIDException(e);
        }
    }
}
Also used : ILogRecord(org.apache.asterix.common.transactions.ILogRecord) LogRecord(org.apache.asterix.common.transactions.LogRecord) PrimaryIndexOperationTracker(org.apache.asterix.common.context.PrimaryIndexOperationTracker) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 45 with ACIDException

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

the class LogReader method refillLogReadBuffer.

/**
     * Continues log analysis between log file splits.
     *
     * @return true if log continues, false if EOF
     * @throws ACIDException
     */
private boolean refillLogReadBuffer() throws ACIDException {
    try {
        if (readLSN % logFileSize == logFile.size()) {
            logFile.close();
            readLSN += logFileSize - (readLSN % logFileSize);
            getLogFile();
        }
        return fillLogReadBuffer();
    } catch (IOException e) {
        throw new ACIDException(e);
    }
}
Also used : IOException(java.io.IOException) 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