use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class MongoDBRyaDAO method add.
@Override
public void add(final Iterator<RyaStatement> statementIter) throws RyaDAOException {
final List<DBObject> dbInserts = new ArrayList<>();
while (statementIter.hasNext()) {
final RyaStatement ryaStatement = statementIter.next();
final boolean canAdd = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility());
if (canAdd) {
final DBObject insert = storageStrategy.serialize(ryaStatement);
dbInserts.add(insert);
try {
for (final RyaSecondaryIndexer index : secondaryIndexers) {
index.storeStatement(ryaStatement);
}
} catch (final IOException e) {
log.error("Failed to add: " + ryaStatement.toString() + " to the indexer");
}
} else {
throw new RyaDAOException("User does not have the required authorizations to add statement");
}
}
try {
mongoDbBatchWriter.addObjectsToQueue(dbInserts);
if (flushEachUpdate.get()) {
flush();
}
} catch (final MongoDbBatchWriterException e) {
throw new RyaDAOException("Error adding statements", e);
}
}
use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class MongoDBRyaDAO method destroy.
@Override
public void destroy() throws RyaDAOException {
if (!isInitialized.get()) {
return;
}
isInitialized.set(false);
flush();
try {
mongoDbBatchWriter.shutdown();
} catch (final MongoDbBatchWriterException e) {
throw new RyaDAOException("Error shutting down MongoDB batch writer", e);
}
for (final MongoSecondaryIndex indexer : secondaryIndexers) {
try {
indexer.close();
} catch (final IOException e) {
log.error("Error closing indexer: " + indexer.getClass().getSimpleName(), e);
}
}
IOUtils.closeQuietly(queryEngine);
}
use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class MongoDBRyaDAO method flush.
@Override
public void flush() throws RyaDAOException {
try {
mongoDbBatchWriter.flush();
flushIndexers();
} catch (final MongoDbBatchWriterException e) {
throw new RyaDAOException("Error flushing data.", e);
}
}
use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class MongoDBRyaDAO method delete.
@Override
public void delete(final Iterator<RyaStatement> statements, final StatefulMongoDBRdfConfiguration conf) throws RyaDAOException {
while (statements.hasNext()) {
final RyaStatement ryaStatement = statements.next();
final boolean canDelete = DocumentVisibilityUtil.doesUserHaveDocumentAccess(auths, ryaStatement.getColumnVisibility());
if (canDelete) {
coll.remove(storageStrategy.getQuery(ryaStatement));
for (final RyaSecondaryIndexer index : secondaryIndexers) {
try {
index.deleteStatement(ryaStatement);
} catch (final IOException e) {
log.error("Unable to remove statement: " + ryaStatement.toString() + " from secondary indexer: " + index.getTableName(), e);
}
}
} else {
throw new RyaDAOException("User does not have the required authorizations to delete statement");
}
}
}
use of org.apache.rya.api.persist.RyaDAOException in project incubator-rya by apache.
the class AccumuloRyaStatementStore method findStatement.
public RyaStatement findStatement(final RyaStatement ryaStatement) throws RyaDAOException {
RyaStatement resultRyaStatement = null;
CloseableIteration<RyaStatement, RyaDAOException> iter = null;
try {
iter = accumuloRyaDao.getQueryEngine().query(ryaStatement, accumuloRyaDao.getConf());
if (iter.hasNext()) {
resultRyaStatement = iter.next();
}
} finally {
if (iter != null) {
iter.close();
}
}
return resultRyaStatement;
}
Aggregations