/** * Sets up a {@link AccumuloRyaDAO} with the specified connector and config. * @param connector the {@link Connector}. * @param accumuloRdfConfiguration the {@link AccumuloRdfConfiguration}. * @return the {@link AccumuloRyaDAO}. */ public static AccumuloRyaDAO setupDao(final Connector connector, final AccumuloRdfConfiguration accumuloRdfConfiguration) { final AccumuloRyaDAO accumuloRyaDao = new AccumuloRyaDAO(); accumuloRyaDao.setConnector(connector); accumuloRyaDao.setConf(accumuloRdfConfiguration); try { accumuloRyaDao.init(); } catch (final RyaDAOException e) { log.error("Error initializing DAO", e); } return accumuloRyaDao; }
/** * Tears down the {@link AccumuloRyaDAO}. * @throws Exception */ public void tearDownDao() throws Exception { if (dao != null) { log.info("Stopping " + driverName + " DAO"); try { dao.destroy(); } catch (final RyaDAOException e) { log.error("Error stopping " + driverName + " DAO", e); } dao = null; } }
/** * Insert a statement into the child Accumulo instance via the child DAO. * @param rstmt RyaStatement to add to the child * @param context Map context, not used * @throws IOException if the DAO encounters an error adding the statement to Accumulo */ @Override protected void copyStatement(final RyaStatement rstmt, final Context context) throws IOException { try { childDao.add(rstmt); } catch (final RyaDAOException e) { throw new IOException("Error inserting statement into child Rya DAO", e); } }
public StatementMetadataExample(AccumuloRdfConfiguration conf) throws Exception { Connector aConn = ConfigUtils.getConnector(conf); dao = new AccumuloRyaDAO(); dao.setConnector(aConn); dao.init(); sail = RyaSailFactory.getInstance(conf); repository = new SailRepository(sail); conn = repository.getConnection(); }
private RdfCloudTripleStoreConnection getRyaSailConnection() throws AccumuloException, AccumuloSecurityException, SailException { RdfCloudTripleStore store = new RdfCloudTripleStore(); AccumuloRyaDAO crdfdao = new AccumuloRyaDAO(); crdfdao.setConnector(accCon); AccumuloRdfConfiguration acc = new AccumuloRdfConfiguration(conf); crdfdao.setConf(acc); store.setRyaDAO(crdfdao); store.initialize(); return (RdfCloudTripleStoreConnection) store.getConnection(); }
final AccumuloRyaDAO dao = new AccumuloRyaDAO(); dao.setConnector(accumuloConn); dao.setConf(makeConfig()); dao.init(); makeRyaStatement(vf.createStatement(vf.createIRI("http://David"), vf.createIRI("http://worksAt"), vf.createIRI("http://Chipotle")), "V")); dao.add(historicTriples.iterator()); dao.flush();
@Override public void dropAndDestroy() throws RyaDAOException { for (final String tableName : getTables()) { try { if (tableName != null) { drop(tableName); } } catch (final AccumuloSecurityException e) { logger.error(e.getMessage()); throw new RyaDAOException(e); } catch (final AccumuloException e) { logger.error(e.getMessage()); throw new RyaDAOException(e); } catch (final TableNotFoundException e) { logger.warn(e.getMessage()); } } destroy(); for(final AccumuloIndexer indexer : this.secondaryIndexers) { try { indexer.dropAndDestroy(); } catch(final Exception e) { logger.error("Failed to drop and destroy indexer", e); } } }
@Override public void addStatement(final RyaStatement statement) throws AddStatementException { try { accumuloRyaDao.add(statement); accumuloRyaDao.flush(); //This is a hack since a statement re-added with the same timestamp won't reappear since its been marked for deletion. //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); } }
private void flush(final Context context) throws IOException, InterruptedException { try { childDao.flush(); } catch (final RyaDAOException e) { throw new IOException("Error writing to in-memory table", e); final Scanner scanner = childDao.getConnector().createScanner(table, childAuths); for (final Map.Entry<Key, Value> row : scanner) { compositeKey.setKey(row.getKey());
@Override public void delete(final RyaStatement stmt, final AccumuloRdfConfiguration aconf) throws RyaDAOException { this.delete(Iterators.singletonIterator(stmt), aconf); }
private RdfCloudTripleStoreConnection getRyaSailConnection() throws AccumuloException, AccumuloSecurityException, SailException { RdfCloudTripleStore store = new RdfCloudTripleStore(); AccumuloRyaDAO crdfdao = new AccumuloRyaDAO(); crdfdao.setConnector(accCon); AccumuloRdfConfiguration acc = new AccumuloRdfConfiguration(conf); crdfdao.setConf(acc); store.setRyaDAO(crdfdao); store.initialize(); return (RdfCloudTripleStoreConnection) store.getConnection(); }
@Override public void dropAndDestroy() throws RyaDAOException { for (final String tableName : getTables()) { try { if (tableName != null) { drop(tableName); } } catch (final AccumuloSecurityException e) { logger.error(e.getMessage()); throw new RyaDAOException(e); } catch (final AccumuloException e) { logger.error(e.getMessage()); throw new RyaDAOException(e); } catch (final TableNotFoundException e) { logger.warn(e.getMessage()); } } destroy(); for(final AccumuloIndexer indexer : this.secondaryIndexers) { try { indexer.dropAndDestroy(); } catch(final Exception e) { logger.error("Failed to drop and destroy indexer", e); } } }
@Override public void addStatement(final RyaStatement statement) throws AddStatementException { try { accumuloRyaDao.add(statement); accumuloRyaDao.flush(); //This is a hack since a statement re-added with the same timestamp won't reappear since its been marked for deletion. //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); } }
@Override public void delete(final RyaStatement stmt, final AccumuloRdfConfiguration aconf) throws RyaDAOException { this.delete(Iterators.singletonIterator(stmt), aconf); }
/** * Sets up a {@link AccumuloRyaDAO} with the specified connector and config. * @param connector the {@link Connector}. * @param accumuloRdfConfiguration the {@link AccumuloRdfConfiguration}. * @return the {@link AccumuloRyaDAO}. */ public static AccumuloRyaDAO setupDao(final Connector connector, final AccumuloRdfConfiguration accumuloRdfConfiguration) { final AccumuloRyaDAO accumuloRyaDao = new AccumuloRyaDAO(); accumuloRyaDao.setConnector(connector); accumuloRyaDao.setConf(accumuloRdfConfiguration); try { accumuloRyaDao.init(); } catch (final RyaDAOException e) { log.error("Error initializing DAO", e); } return accumuloRyaDao; } }
private static RyaSailRepository makeRyaRepository(final PcjAdminClientProperties clientProps, final Connector accumulo) throws RepositoryException { checkNotNull(clientProps); checkNotNull(accumulo); // Setup Rya configuration values. final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration(); ryaConf.setTablePrefix( clientProps.getRyaTablePrefix() ); // Connect to the Rya repo. final AccumuloRyaDAO accumuloRyaDao = new AccumuloRyaDAO(); accumuloRyaDao.setConnector(accumulo); accumuloRyaDao.setConf(ryaConf); final RdfCloudTripleStore ryaStore = new RdfCloudTripleStore(); ryaStore.setRyaDAO(accumuloRyaDao); final RyaSailRepository ryaRepo = new RyaSailRepository(ryaStore); ryaRepo.initialize(); return ryaRepo; }