Search in sources :

Example 1 with AddStatementException

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

the class AccumuloRyaStatementStore method updateStatement.

@Override
public void updateStatement(final RyaStatement original, final RyaStatement update) throws UpdateStatementException {
    try {
        removeStatement(original);
        addStatement(update);
    } catch (final AddStatementException | RemoveStatementException e) {
        throw new UpdateStatementException("Unable to update the Rya Statement", e);
    }
}
Also used : AddStatementException(org.apache.rya.export.api.store.AddStatementException) UpdateStatementException(org.apache.rya.export.api.store.UpdateStatementException) RemoveStatementException(org.apache.rya.export.api.store.RemoveStatementException)

Example 2 with AddStatementException

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

the class MemoryTimeMerger method export.

/**
 * Exports all statements after the provided timestamp.
 * @throws ParentMetadataExistsException -
 * @throws FetchStatementException
 */
private void export() throws ParentMetadataExistsException, FetchStatementException {
    LOG.info("Creating parent metadata in the child.");
    // setup parent metadata repo in the child
    final MergeParentMetadata metadata = new MergeParentMetadata.Builder().setRyaInstanceName(ryaInstanceName).setTimestamp(new Date()).setParentTimeOffset(timeOffset).setFilterTimestmap(timestamp).build();
    childStore.setParentMetadata(metadata);
    // fetch all statements after timestamp from the parent
    final Iterator<RyaStatement> statements = parentStore.fetchStatements();
    LOG.info("Exporting statements.");
    while (statements.hasNext()) {
        System.out.print(".");
        final RyaStatement statement = statements.next();
        try {
            childStore.addStatement(statement);
        } catch (final AddStatementException e) {
            LOG.error("Failed to add statement: " + statement + " to the statement store.", e);
        }
    }
}
Also used : AddStatementException(org.apache.rya.export.api.store.AddStatementException) MergeParentMetadata(org.apache.rya.export.api.metadata.MergeParentMetadata) RyaStatement(org.apache.rya.api.domain.RyaStatement) Date(java.util.Date)

Example 3 with AddStatementException

use of org.apache.rya.export.api.store.AddStatementException 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 4 with AddStatementException

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

the class AccumuloRyaStatementStore method addStatement.

@Override
public void addStatement(final RyaStatement statement) throws AddStatementException {
    try {
        accumuloRyaDao.add(statement);
        accumuloRyaDao.flush();
        // RYA-197 is the ticket for fixing this hack.
        if (!containsStatement(statement)) {
            statement.setTimestamp(statement.getTimestamp() + 1L);
            accumuloRyaDao.add(statement);
        }
    } catch (final RyaDAOException | ContainsStatementException e) {
        throw new AddStatementException("Unable to add the Rya Statement", e);
    }
}
Also used : AddStatementException(org.apache.rya.export.api.store.AddStatementException) ContainsStatementException(org.apache.rya.export.api.store.ContainsStatementException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException)

Aggregations

AddStatementException (org.apache.rya.export.api.store.AddStatementException)4 MergeParentMetadata (org.apache.rya.export.api.metadata.MergeParentMetadata)2 ContainsStatementException (org.apache.rya.export.api.store.ContainsStatementException)2 RemoveStatementException (org.apache.rya.export.api.store.RemoveStatementException)2 Date (java.util.Date)1 RyaStatement (org.apache.rya.api.domain.RyaStatement)1 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)1 ParentMetadataExistsException (org.apache.rya.export.api.metadata.ParentMetadataExistsException)1 FetchStatementException (org.apache.rya.export.api.store.FetchStatementException)1 UpdateStatementException (org.apache.rya.export.api.store.UpdateStatementException)1