Search in sources :

Example 1 with FeedPolicyTupleTranslator

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

the class MetadataNode method getDataversePolicies.

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

Example 2 with FeedPolicyTupleTranslator

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

the class MetadataNode method getFeedPolicy.

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

Example 3 with FeedPolicyTupleTranslator

use of org.apache.asterix.metadata.entitytupletranslators.FeedPolicyTupleTranslator 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)

Aggregations

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