Search in sources :

Example 1 with FetchStatementException

use of org.apache.rya.export.api.store.FetchStatementException in project incubator-rya by apache.

the class MemoryTimeMerger method runJob.

@Override
public void runJob() {
    final Optional<MergeParentMetadata> metadata = parentStore.getParentMetadata();
    // check the parent for a parent metadata repo
    if (metadata.isPresent()) {
        LOG.info("Merging statements...");
        final MergeParentMetadata parentMetadata = metadata.get();
        if (parentMetadata.getRyaInstanceName().equals(ryaInstanceName)) {
            try {
                importStatements(parentMetadata);
            } catch (AddStatementException | ContainsStatementException | RemoveStatementException | FetchStatementException e) {
                LOG.error("Failed to import statements.", e);
            }
        }
    } else {
        try {
            LOG.info("Cloning statements...");
            export();
        } catch (final ParentMetadataExistsException | FetchStatementException e) {
            LOG.error("Failed to export statements.", e);
        }
    }
}
Also used : AddStatementException(org.apache.rya.export.api.store.AddStatementException) ParentMetadataExistsException(org.apache.rya.export.api.metadata.ParentMetadataExistsException) MergeParentMetadata(org.apache.rya.export.api.metadata.MergeParentMetadata) ContainsStatementException(org.apache.rya.export.api.store.ContainsStatementException) RemoveStatementException(org.apache.rya.export.api.store.RemoveStatementException) FetchStatementException(org.apache.rya.export.api.store.FetchStatementException)

Example 2 with FetchStatementException

use of org.apache.rya.export.api.store.FetchStatementException in project incubator-rya by apache.

the class AccumuloRyaStatementStore method fetchStatements.

@Override
public Iterator<RyaStatement> fetchStatements() throws FetchStatementException {
    try {
        final RyaTripleContext ryaTripleContext = RyaTripleContext.getInstance(accumuloRyaDao.getConf());
        Scanner scanner = null;
        try {
            scanner = AccumuloRyaUtils.getScanner(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, accumuloRyaDao.getConf());
            for (final IteratorSetting iteratorSetting : iteratorSettings) {
                scanner.addScanIterator(iteratorSetting);
            }
        } catch (final IOException e) {
            throw new FetchStatementException("Unable to get scanner to fetch Rya Statements", e);
        }
        // Convert Entry iterator to RyaStatement iterator
        final Iterator<Entry<Key, Value>> entryIter = scanner.iterator();
        final Iterator<RyaStatement> ryaStatementIter = Iterators.transform(entryIter, new Function<Entry<Key, Value>, RyaStatement>() {

            @Override
            public RyaStatement apply(final Entry<Key, Value> entry) {
                final Key key = entry.getKey();
                final Value value = entry.getValue();
                RyaStatement ryaStatement = null;
                try {
                    ryaStatement = AccumuloRyaUtils.createRyaStatement(key, value, ryaTripleContext);
                } catch (final TripleRowResolverException e) {
                    log.error("Unable to convert the key/value pair into a Rya Statement", e);
                }
                return ryaStatement;
            }
        });
        return ryaStatementIter;
    } catch (final Exception e) {
        throw new FetchStatementException("Failed to fetch statements.", e);
    }
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) RyaStatement(org.apache.rya.api.domain.RyaStatement) IOException(java.io.IOException) FetchStatementException(org.apache.rya.export.api.store.FetchStatementException) TripleRowResolverException(org.apache.rya.api.resolver.triple.TripleRowResolverException) AddStatementException(org.apache.rya.export.api.store.AddStatementException) ParentMetadataExistsException(org.apache.rya.export.api.metadata.ParentMetadataExistsException) UpdateStatementException(org.apache.rya.export.api.store.UpdateStatementException) FetchStatementException(org.apache.rya.export.api.store.FetchStatementException) IOException(java.io.IOException) RemoveStatementException(org.apache.rya.export.api.store.RemoveStatementException) ContainsStatementException(org.apache.rya.export.api.store.ContainsStatementException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) MergerException(org.apache.rya.export.api.MergerException) TripleRowResolverException(org.apache.rya.api.resolver.triple.TripleRowResolverException) RyaTripleContext(org.apache.rya.api.resolver.RyaTripleContext) Entry(java.util.Map.Entry) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Value(org.apache.accumulo.core.data.Value) Key(org.apache.accumulo.core.data.Key)

Aggregations

ParentMetadataExistsException (org.apache.rya.export.api.metadata.ParentMetadataExistsException)2 AddStatementException (org.apache.rya.export.api.store.AddStatementException)2 ContainsStatementException (org.apache.rya.export.api.store.ContainsStatementException)2 FetchStatementException (org.apache.rya.export.api.store.FetchStatementException)2 RemoveStatementException (org.apache.rya.export.api.store.RemoveStatementException)2 IOException (java.io.IOException)1 Entry (java.util.Map.Entry)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 Scanner (org.apache.accumulo.core.client.Scanner)1 Key (org.apache.accumulo.core.data.Key)1 Value (org.apache.accumulo.core.data.Value)1 RyaStatement (org.apache.rya.api.domain.RyaStatement)1 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)1 RyaTripleContext (org.apache.rya.api.resolver.RyaTripleContext)1 TripleRowResolverException (org.apache.rya.api.resolver.triple.TripleRowResolverException)1 MergerException (org.apache.rya.export.api.MergerException)1 MergeParentMetadata (org.apache.rya.export.api.metadata.MergeParentMetadata)1 UpdateStatementException (org.apache.rya.export.api.store.UpdateStatementException)1