Search in sources :

Example 1 with DatasourceAdapterTupleTranslator

use of org.apache.asterix.metadata.entitytupletranslators.DatasourceAdapterTupleTranslator in project asterixdb by apache.

the class MetadataNode method addAdapter.

@Override
public void addAdapter(JobId jobId, DatasourceAdapter adapter) throws MetadataException, RemoteException {
    try {
        // Insert into the 'Adapter' dataset.
        DatasourceAdapterTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getAdapterTupleTranslator(true);
        ITupleReference adapterTuple = tupleReaderWriter.getTupleFromMetadataEntity(adapter);
        insertTupleIntoIndex(jobId, MetadataPrimaryIndexes.DATASOURCE_ADAPTER_DATASET, adapterTuple);
    } catch (HyracksDataException e) {
        if (e.getComponent().equals(ErrorCode.HYRACKS) && e.getErrorCode() == ErrorCode.DUPLICATE_KEY) {
            throw new MetadataException("A adapter with this name " + adapter.getAdapterIdentifier().getName() + " already exists in dataverse '" + adapter.getAdapterIdentifier().getNamespace() + "'.", e);
        } else {
            throw new MetadataException(e);
        }
    } catch (ACIDException e) {
        throw new MetadataException(e);
    }
}
Also used : ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) DatasourceAdapterTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.DatasourceAdapterTupleTranslator) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) ACIDException(org.apache.asterix.common.exceptions.ACIDException)

Example 2 with DatasourceAdapterTupleTranslator

use of org.apache.asterix.metadata.entitytupletranslators.DatasourceAdapterTupleTranslator in project asterixdb by apache.

the class MetadataNode method getDataverseAdapters.

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

Example 3 with DatasourceAdapterTupleTranslator

use of org.apache.asterix.metadata.entitytupletranslators.DatasourceAdapterTupleTranslator in project asterixdb by apache.

the class MetadataNode method getAdapter.

@Override
public DatasourceAdapter getAdapter(JobId jobId, String dataverseName, String adapterName) throws MetadataException, RemoteException {
    try {
        ITupleReference searchKey = createTuple(dataverseName, adapterName);
        DatasourceAdapterTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getAdapterTupleTranslator(false);
        List<DatasourceAdapter> results = new ArrayList<>();
        IValueExtractor<DatasourceAdapter> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
        searchIndex(jobId, MetadataPrimaryIndexes.DATASOURCE_ADAPTER_DATASET, searchKey, valueExtractor, results);
        if (results.isEmpty()) {
            return null;
        }
        return results.get(0);
    } catch (HyracksDataException e) {
        throw new MetadataException(e);
    }
}
Also used : MetadataEntityValueExtractor(org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor) DatasourceAdapter(org.apache.asterix.metadata.entities.DatasourceAdapter) ITupleReference(org.apache.hyracks.dataflow.common.data.accessors.ITupleReference) ArrayList(java.util.ArrayList) DatasourceAdapterTupleTranslator(org.apache.asterix.metadata.entitytupletranslators.DatasourceAdapterTupleTranslator) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

DatasourceAdapterTupleTranslator (org.apache.asterix.metadata.entitytupletranslators.DatasourceAdapterTupleTranslator)3 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)3 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)3 ArrayList (java.util.ArrayList)2 DatasourceAdapter (org.apache.asterix.metadata.entities.DatasourceAdapter)2 MetadataEntityValueExtractor (org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor)2 ACIDException (org.apache.asterix.common.exceptions.ACIDException)1