Search in sources :

Example 1 with AccumuloIndexer

use of org.apache.rya.accumulo.experimental.AccumuloIndexer in project incubator-rya by apache.

the class AccumuloRyaDAO method delete.

@Override
public void delete(final Iterator<RyaStatement> statements, final AccumuloRdfConfiguration conf) throws RyaDAOException {
    try {
        while (statements.hasNext()) {
            final RyaStatement stmt = statements.next();
            // query first
            final CloseableIteration<RyaStatement, RyaDAOException> query = this.queryEngine.query(stmt, conf);
            while (query.hasNext()) {
                deleteSingleRyaStatement(query.next());
            }
            for (final AccumuloIndexer index : secondaryIndexers) {
                index.deleteStatement(stmt);
            }
        }
        if (flushEachUpdate.get()) {
            mt_bw.flush();
        }
    } catch (final Exception e) {
        throw new RyaDAOException(e);
    }
}
Also used : AccumuloIndexer(org.apache.rya.accumulo.experimental.AccumuloIndexer) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException)

Example 2 with AccumuloIndexer

use of org.apache.rya.accumulo.experimental.AccumuloIndexer in project incubator-rya by apache.

the class AccumuloRyaDAO method commit.

protected void commit(final Iterator<RyaStatement> commitStatements) throws RyaDAOException {
    try {
        // TODO: Should have a lock here in case we are adding and committing at the same time
        while (commitStatements.hasNext()) {
            final RyaStatement stmt = commitStatements.next();
            final Map<TABLE_LAYOUT, Collection<Mutation>> mutationMap = ryaTableMutationsFactory.serialize(stmt);
            final Collection<Mutation> spo = mutationMap.get(TABLE_LAYOUT.SPO);
            final Collection<Mutation> po = mutationMap.get(TABLE_LAYOUT.PO);
            final Collection<Mutation> osp = mutationMap.get(TABLE_LAYOUT.OSP);
            bw_spo.addMutations(spo);
            bw_po.addMutations(po);
            bw_osp.addMutations(osp);
            for (final AccumuloIndexer index : secondaryIndexers) {
                index.storeStatement(stmt);
            }
        }
        if (flushEachUpdate.get()) {
            mt_bw.flush();
        }
    } catch (final Exception e) {
        throw new RyaDAOException(e);
    }
}
Also used : TABLE_LAYOUT(org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT) AccumuloIndexer(org.apache.rya.accumulo.experimental.AccumuloIndexer) RyaStatement(org.apache.rya.api.domain.RyaStatement) Collection(java.util.Collection) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) Mutation(org.apache.accumulo.core.data.Mutation) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException)

Example 3 with AccumuloIndexer

use of org.apache.rya.accumulo.experimental.AccumuloIndexer in project incubator-rya by apache.

the class AccumuloRyaDAO method destroy.

@Override
public void destroy() throws RyaDAOException {
    if (!isInitialized.get()) {
        return;
    }
    // TODO: write lock
    try {
        isInitialized.set(false);
        mt_bw.flush();
        mt_bw.close();
    } catch (final Exception e) {
        throw new RyaDAOException(e);
    }
    for (final AccumuloIndexer indexer : this.secondaryIndexers) {
        try {
            indexer.destroy();
        } catch (final Exception e) {
            logger.warn("Failed to destroy indexer", e);
        }
    }
}
Also used : AccumuloIndexer(org.apache.rya.accumulo.experimental.AccumuloIndexer) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException)

Example 4 with AccumuloIndexer

use of org.apache.rya.accumulo.experimental.AccumuloIndexer in project incubator-rya by apache.

the class AccumuloRyaDAO method purge.

@Override
public void purge(final RdfCloudTripleStoreConfiguration configuration) {
    for (final String tableName : getTables()) {
        try {
            purge(tableName, configuration.getAuths());
            compact(tableName);
        } catch (final TableNotFoundException e) {
            logger.error(e.getMessage());
        } catch (final MutationsRejectedException e) {
            logger.error(e.getMessage());
        }
    }
    for (final AccumuloIndexer indexer : this.secondaryIndexers) {
        try {
            indexer.purge(configuration);
        } catch (final Exception e) {
            logger.error("Failed to purge indexer", e);
        }
    }
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloIndexer(org.apache.rya.accumulo.experimental.AccumuloIndexer) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Example 5 with AccumuloIndexer

use of org.apache.rya.accumulo.experimental.AccumuloIndexer in project incubator-rya by apache.

the class AccumuloRyaDAO method init.

@Override
public void init() throws RyaDAOException {
    if (isInitialized.get()) {
        return;
    }
    try {
        checkNotNull(conf);
        checkNotNull(connector);
        if (batchWriterConfig == null) {
            batchWriterConfig = new BatchWriterConfig();
            batchWriterConfig.setMaxMemory(MAX_MEMORY);
            batchWriterConfig.setTimeout(MAX_TIME, TimeUnit.MILLISECONDS);
            batchWriterConfig.setMaxWriteThreads(NUM_THREADS);
        }
        tableLayoutStrategy = conf.getTableLayoutStrategy();
        ryaContext = RyaTripleContext.getInstance(conf);
        ryaTableMutationsFactory = new RyaTableMutationsFactory(ryaContext);
        secondaryIndexers = conf.getAdditionalIndexers();
        flushEachUpdate.set(conf.flushEachUpdate());
        final TableOperations tableOperations = connector.tableOperations();
        AccumuloRdfUtils.createTableIfNotExist(tableOperations, tableLayoutStrategy.getSpo());
        AccumuloRdfUtils.createTableIfNotExist(tableOperations, tableLayoutStrategy.getPo());
        AccumuloRdfUtils.createTableIfNotExist(tableOperations, tableLayoutStrategy.getOsp());
        AccumuloRdfUtils.createTableIfNotExist(tableOperations, tableLayoutStrategy.getNs());
        for (final AccumuloIndexer index : secondaryIndexers) {
            index.setConf(conf);
        }
        mt_bw = connector.createMultiTableBatchWriter(batchWriterConfig);
        // get the batch writers for tables
        bw_spo = mt_bw.getBatchWriter(tableLayoutStrategy.getSpo());
        bw_po = mt_bw.getBatchWriter(tableLayoutStrategy.getPo());
        bw_osp = mt_bw.getBatchWriter(tableLayoutStrategy.getOsp());
        bw_ns = mt_bw.getBatchWriter(tableLayoutStrategy.getNs());
        for (final AccumuloIndexer index : secondaryIndexers) {
            index.setConnector(connector);
            index.setMultiTableBatchWriter(mt_bw);
            index.init();
        }
        queryEngine = new AccumuloRyaQueryEngine(connector, conf);
        checkVersion();
        isInitialized.set(true);
    } catch (final Exception e) {
        throw new RyaDAOException(e);
    }
}
Also used : TableOperations(org.apache.accumulo.core.client.admin.TableOperations) AccumuloIndexer(org.apache.rya.accumulo.experimental.AccumuloIndexer) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) AccumuloRyaQueryEngine(org.apache.rya.accumulo.query.AccumuloRyaQueryEngine) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaDAOException(org.apache.rya.api.persist.RyaDAOException)

Aggregations

IOException (java.io.IOException)5 AccumuloException (org.apache.accumulo.core.client.AccumuloException)5 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)5 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)5 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)5 AccumuloIndexer (org.apache.rya.accumulo.experimental.AccumuloIndexer)5 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)5 RyaStatement (org.apache.rya.api.domain.RyaStatement)2 Collection (java.util.Collection)1 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)1 TableOperations (org.apache.accumulo.core.client.admin.TableOperations)1 Mutation (org.apache.accumulo.core.data.Mutation)1 AccumuloRyaQueryEngine (org.apache.rya.accumulo.query.AccumuloRyaQueryEngine)1 TABLE_LAYOUT (org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT)1