Search in sources :

Example 86 with HyracksDataException

use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.

the class MetadataNode method dropExternalFile.

@Override
public void dropExternalFile(JobId jobId, String dataverseName, String datasetName, int fileNumber) throws MetadataException, RemoteException {
    try {
        // Delete entry from the 'ExternalFile' dataset.
        ITupleReference searchKey = createExternalFileSearchTuple(dataverseName, datasetName, fileNumber);
        // Searches the index for the tuple to be deleted. Acquires an S
        // lock on the 'ExternalFile' dataset.
        ITupleReference datasetTuple = getTupleToBeDeleted(jobId, MetadataPrimaryIndexes.EXTERNAL_FILE_DATASET, searchKey);
        deleteTupleFromIndex(jobId, MetadataPrimaryIndexes.EXTERNAL_FILE_DATASET, datasetTuple);
    } catch (HyracksDataException e) {
        if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.UPDATE_OR_DELETE_NON_EXISTENT_KEY) {
            throw new MetadataException("Couldn't drop externalFile.", 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)

Example 87 with HyracksDataException

use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.

the class MetadataNode method getFeedConnections.

@Override
public List<FeedConnection> getFeedConnections(JobId jobId, String dataverseName, String feedName) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = createTuple(dataverseName, feedName);
        FeedConnectionTupleTranslator tupleReaderWriter = new FeedConnectionTupleTranslator(false);
        List<FeedConnection> results = new ArrayList<>();
        IValueExtractor<FeedConnection> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        searchIndex(jobId, MetadataPrimaryIndexes.FEED_CONNECTION_DATASET, searchKey, valueExtractor, results);
        return results;
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) FeedConnection(org.apache.asterix.metadata.entities.FeedConnection) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) FeedConnectionTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.FeedConnectionTupleTranslator) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 88 with HyracksDataException

use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.

the class MetadataNode method getAllDatasets.

public List<Dataset> getAllDatasets(JobId jobId) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = null;
        DatasetTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getDatasetTupleTranslator(false);
        IValueExtractor<Dataset> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        List<Dataset> results = new ArrayList<>();
        searchIndex(jobId, MetadataPrimaryIndexes.DATASET_DATASET, searchKey, valueExtractor, results);
        return results;
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) DatasetTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.DatasetTupleTranslator) ExtensionMetadataDataset(org.apache.asterix.metadata.api.ExtensionMetadataDataset) Dataset(org.apache.asterix.metadata.entities.Dataset) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 89 with HyracksDataException

use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.

the class MetadataNode method addDataset.

@Override
public void addDataset(JobId jobId, Dataset dataset) throws MetadataException, RemoteException {
    try {
        // Insert into the 'dataset' dataset.
        DatasetTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getDatasetTupleTranslator(true);
        ITupleReference datasetTuple = tupleReaderWriter.getTupleFromMetadataEntity(dataset);
        insertTupleIntoIndex(jobId, MetadataPrimaryIndexes.DATASET_DATASET, datasetTuple);
        if (dataset.getDatasetType() == DatasetType.INTERNAL) {
            // Add the primary index for the dataset.
            InternalDatasetDetails id = (InternalDatasetDetails) dataset.getDatasetDetails();
            Index primaryIndex = new Index(dataset.getDataverseName(), dataset.getDatasetName(), dataset.getDatasetName(), IndexType.BTREE, id.getPrimaryKey(), id.getKeySourceIndicator(), id.getPrimaryKeyType(), false, true, dataset.getPendingOp());
            addIndex(jobId, primaryIndex);
        }
    } catch (HyracksDataException e) {
        if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.DUPLICATE_KEY) {
            throw new MetadataException("A dataset with this name " + dataset.getDatasetName() + " already exists in dataverse '" + dataset.getDataverseName() + "'.", e);
        } else {
            throw new MetadataException(e);
        }
    } catch (ACIDException e) {
        throw new MetadataException(e);
    }
}
Also used : DatasetTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.DatasetTupleTranslator) InternalDatasetDetails(org.apache.asterix.metadata.entities.InternalDatasetDetails) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) IMetadataIndex(org.apache.asterix.metadata.api.IMetadataIndex) Index(org.apache.asterix.metadata.entities.Index) AbstractLSMIndex(org.apache.hyracks.storage.am.lsm.common.impls.AbstractLSMIndex) ILSMIndex(org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex) IIndex(org.apache.hyracks.storage.common.IIndex) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 90 with HyracksDataException

use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.

the class MetadataNode method getDataverseLibraries.

@Override
public List<Library> getDataverseLibraries(JobId jobId, String dataverseName) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = createTuple(dataverseName);
        LibraryTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getLibraryTupleTranslator(false);
        IValueExtractor<Library> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        List<Library> results = new ArrayList<>();
        searchIndex(jobId, MetadataPrimaryIndexes.LIBRARY_DATASET, searchKey, valueExtractor, results);
        return results;
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) Library(org.apache.asterix.metadata.entities.Library) LibraryTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.LibraryTupleTranslator) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)566 IOException (java.io.IOException)209 DataOutput (java.io.DataOutput)96 ArrayBackedValueStorage (org.apache.hyracks.data.std.util.ArrayBackedValueStorage)78 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)75 IPointable (org.apache.hyracks.data.std.api.IPointable)73 IFrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference)70 TypeMismatchException (org.apache.asterix.runtime.exceptions.TypeMismatchException)67 IScalarEvaluator (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator)67 VoidPointable (org.apache.hyracks.data.std.primitive.VoidPointable)64 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)61 IHyracksTaskContext (org.apache.hyracks.api.context.IHyracksTaskContext)60 ArrayList (java.util.ArrayList)57 ACIDException (org.apache.asterix.common.exceptions.ACIDException)56 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)56 ATypeTag (org.apache.asterix.om.types.ATypeTag)39 AsterixException (org.apache.asterix.common.exceptions.AsterixException)36 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)32 ByteBuffer (java.nio.ByteBuffer)30 MetadataEntityValueExtractor (org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor)27