Search in sources :

Example 6 with TablePrefixLayoutStrategy

use of org.apache.rya.api.layout.TablePrefixLayoutStrategy in project incubator-rya by apache.

the class EntityOptimizerTest method init.

@Before
public void init() throws RepositoryException, TupleQueryResultHandlerException, QueryEvaluationException, MalformedQueryException, AccumuloException, AccumuloSecurityException, TableExistsException {
    accCon = new MockInstance("instance").getConnector("root", "".getBytes());
    config = new BatchWriterConfig();
    config.setMaxMemory(1000);
    config.setMaxLatency(1000, TimeUnit.SECONDS);
    config.setMaxWriteThreads(10);
    if (accCon.tableOperations().exists("rya_prospects")) {
        try {
            accCon.tableOperations().delete("rya_prospects");
        } catch (TableNotFoundException e) {
            e.printStackTrace();
        }
    }
    if (accCon.tableOperations().exists("rya_selectivity")) {
        try {
            accCon.tableOperations().delete("rya_selectivity");
        } catch (TableNotFoundException e) {
            e.printStackTrace();
        }
    }
    accCon.tableOperations().create("rya_prospects");
    accCon.tableOperations().create("rya_selectivity");
    Configuration con = new Configuration();
    con.set(ConfigUtils.CLOUDBASE_AUTHS, "U");
    con.set(ConfigUtils.CLOUDBASE_INSTANCE, "instance");
    con.set(ConfigUtils.CLOUDBASE_USER, "root");
    con.set(ConfigUtils.CLOUDBASE_PASSWORD, "");
    conf = new AccumuloRdfConfiguration(con);
    TablePrefixLayoutStrategy tps = new TablePrefixLayoutStrategy("rya_");
    conf.setTableLayoutStrategy(tps);
    conf.set(ConfigUtils.USE_MOCK_INSTANCE, "true");
    res = new ProspectorServiceEvalStatsDAO(accCon, conf);
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) Configuration(org.apache.hadoop.conf.Configuration) RdfCloudTripleStoreConfiguration(org.apache.rya.api.RdfCloudTripleStoreConfiguration) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) TablePrefixLayoutStrategy(org.apache.rya.api.layout.TablePrefixLayoutStrategy) ProspectorServiceEvalStatsDAO(org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAO) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) Before(org.junit.Before)

Example 7 with TablePrefixLayoutStrategy

use of org.apache.rya.api.layout.TablePrefixLayoutStrategy in project incubator-rya by apache.

the class RyaTableNames method getTableNames.

/**
 * Get the the Accumulo table names that are used by an instance of Rya.
 *
 * @param ryaInstanceName - The name of the Rya instance. (not null)
 * @param conn - A connector to the host Accumulo instance. (not null)
 * @return The Accumulo table names that are used by the Rya instance.
 * @throws NotInitializedException The instance's Rya Details have not been initialized.
 * @throws RyaDetailsRepositoryException General problem with the Rya Details repository.
 * @throws PCJStorageException General problem with the PCJ storage.
 */
public List<String> getTableNames(final String ryaInstanceName, final Connector conn) throws NotInitializedException, RyaDetailsRepositoryException, PCJStorageException {
    // Build the list of tables that may be present within the Rya instance.
    final List<String> tables = new ArrayList<>();
    // Core Rya tables.
    final TableLayoutStrategy coreTableNames = new TablePrefixLayoutStrategy(ryaInstanceName);
    tables.add(coreTableNames.getSpo());
    tables.add(coreTableNames.getPo());
    tables.add(coreTableNames.getOsp());
    tables.add(coreTableNames.getEval());
    tables.add(coreTableNames.getNs());
    tables.add(coreTableNames.getProspects());
    tables.add(coreTableNames.getSelectivity());
    // Rya Details table.
    tables.add(AccumuloRyaInstanceDetailsRepository.makeTableName(ryaInstanceName));
    // Secondary Indexer Tables.
    final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(conn, ryaInstanceName);
    final RyaDetails details = detailsRepo.getRyaInstanceDetails();
    if (details.getEntityCentricIndexDetails().isEnabled()) {
        tables.add(EntityCentricIndex.makeTableName(ryaInstanceName));
    }
    if (details.getFreeTextIndexDetails().isEnabled()) {
        tables.addAll(AccumuloFreeTextIndexer.makeTableNames(ryaInstanceName));
    }
    if (details.getTemporalIndexDetails().isEnabled()) {
        tables.add(AccumuloTemporalIndexer.makeTableName(ryaInstanceName));
    }
    if (details.getPCJIndexDetails().isEnabled()) {
        try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(conn, ryaInstanceName)) {
            final List<String> pcjIds = pcjStorage.listPcjs();
            final PcjTableNameFactory tableNameFactory = new PcjTableNameFactory();
            for (final String pcjId : pcjIds) {
                tables.add(tableNameFactory.makeTableName(ryaInstanceName, pcjId));
            }
        }
    }
    // Verify they actually exist. If any don't, remove them from the list.
    final TableOperations tableOps = conn.tableOperations();
    final Iterator<String> tablesIt = tables.iterator();
    while (tablesIt.hasNext()) {
        final String table = tablesIt.next();
        if (!tableOps.exists(table)) {
            tablesIt.remove();
        }
    }
    return tables;
}
Also used : TableLayoutStrategy(org.apache.rya.api.layout.TableLayoutStrategy) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) ArrayList(java.util.ArrayList) RyaDetails(org.apache.rya.api.instance.RyaDetails) PcjTableNameFactory(org.apache.rya.indexing.pcj.storage.accumulo.PcjTableNameFactory) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) TableOperations(org.apache.accumulo.core.client.admin.TableOperations) TablePrefixLayoutStrategy(org.apache.rya.api.layout.TablePrefixLayoutStrategy) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository)

Example 8 with TablePrefixLayoutStrategy

use of org.apache.rya.api.layout.TablePrefixLayoutStrategy in project incubator-rya by apache.

the class RyaSailFactory method getRyaSail.

private static Sail getRyaSail(final Configuration config) throws InferenceEngineException, RyaDAOException, AccumuloException, AccumuloSecurityException, SailException {
    final RdfCloudTripleStore store = new RdfCloudTripleStore();
    final RyaDAO<?> dao;
    final RdfCloudTripleStoreConfiguration rdfConfig;
    final String user;
    final String pswd;
    // XXX Should(?) be MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX inside the if below. RYA-135
    final String ryaInstance = config.get(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX);
    Objects.requireNonNull(ryaInstance, "RyaInstance or table prefix is missing from configuration." + RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX);
    if (ConfigUtils.getUseMongo(config)) {
        // Get a reference to a Mongo DB configuration object.
        final MongoDBRdfConfiguration mongoConfig = (config instanceof MongoDBRdfConfiguration) ? (MongoDBRdfConfiguration) config : new MongoDBRdfConfiguration(config);
        // Instantiate a Mongo client and Mongo DAO.
        dao = getMongoDAO(mongoConfig);
        // Then use the DAO's newly-created stateful conf in place of the original
        rdfConfig = dao.getConf();
    } else {
        rdfConfig = new AccumuloRdfConfiguration(config);
        user = rdfConfig.get(ConfigUtils.CLOUDBASE_USER);
        pswd = rdfConfig.get(ConfigUtils.CLOUDBASE_PASSWORD);
        Objects.requireNonNull(user, "Accumulo user name is missing from configuration." + ConfigUtils.CLOUDBASE_USER);
        Objects.requireNonNull(pswd, "Accumulo user password is missing from configuration." + ConfigUtils.CLOUDBASE_PASSWORD);
        rdfConfig.setTableLayoutStrategy(new TablePrefixLayoutStrategy(ryaInstance));
        updateAccumuloConfig((AccumuloRdfConfiguration) rdfConfig, user, pswd, ryaInstance);
        dao = getAccumuloDAO((AccumuloRdfConfiguration) rdfConfig);
    }
    store.setRyaDAO(dao);
    rdfConfig.setTablePrefix(ryaInstance);
    if (rdfConfig.isInfer()) {
        final InferenceEngine inferenceEngine = new InferenceEngine();
        inferenceEngine.setConf(rdfConfig);
        inferenceEngine.setRyaDAO(dao);
        inferenceEngine.init();
        store.setInferenceEngine(inferenceEngine);
    }
    store.initialize();
    return store;
}
Also used : RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) InferenceEngine(org.apache.rya.rdftriplestore.inference.InferenceEngine) TablePrefixLayoutStrategy(org.apache.rya.api.layout.TablePrefixLayoutStrategy) RdfCloudTripleStoreConfiguration(org.apache.rya.api.RdfCloudTripleStoreConfiguration) MongoDBRdfConfiguration(org.apache.rya.mongodb.MongoDBRdfConfiguration) StatefulMongoDBRdfConfiguration(org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Example 9 with TablePrefixLayoutStrategy

use of org.apache.rya.api.layout.TablePrefixLayoutStrategy in project incubator-rya by apache.

the class RyaSailFactory method getAccumuloDAOWithUpdatedConfig.

/**
 * Creates an AccumuloRyaDAO after updating the AccumuloRdfConfiguration so that it is consistent
 * with the configuration of the RyaInstance that the user is trying to connect to.  This ensures
 * that user configuration aligns with Rya instance configuration and prevents the creation of
 * new index tables based on a user's query configuration.  This method requires the {@link AccumuloRyaInstanceDetailsRepository}
 * to exist.
 *
 * @param config - user's query configuration
 * @return - AccumuloRyaDAO with an updated configuration that is consistent with the Rya instance configuration
 * @throws AccumuloException
 * @throws AccumuloSecurityException
 * @throws RyaDAOException
 */
public static AccumuloRyaDAO getAccumuloDAOWithUpdatedConfig(final AccumuloRdfConfiguration config) throws AccumuloException, AccumuloSecurityException, RyaDAOException {
    final String ryaInstance = config.get(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX);
    Objects.requireNonNull(ryaInstance, "RyaInstance or table prefix is missing from configuration." + RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX);
    final String user = config.get(AccumuloRdfConfiguration.CLOUDBASE_USER);
    final String pswd = config.get(AccumuloRdfConfiguration.CLOUDBASE_PASSWORD);
    Objects.requireNonNull(user, "Accumulo user name is missing from configuration." + AccumuloRdfConfiguration.CLOUDBASE_USER);
    Objects.requireNonNull(pswd, "Accumulo user password is missing from configuration." + AccumuloRdfConfiguration.CLOUDBASE_PASSWORD);
    config.setTableLayoutStrategy(new TablePrefixLayoutStrategy(ryaInstance));
    updateAccumuloConfig(config, user, pswd, ryaInstance);
    return getAccumuloDAO(config);
}
Also used : TablePrefixLayoutStrategy(org.apache.rya.api.layout.TablePrefixLayoutStrategy)

Example 10 with TablePrefixLayoutStrategy

use of org.apache.rya.api.layout.TablePrefixLayoutStrategy in project incubator-rya by apache.

the class RdfCloudTripleStoreSelectivityEvaluationStatisticsTest method init.

@Before
public void init() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
    mock = new MockInstance("accumulo");
    PasswordToken pToken = new PasswordToken("pass".getBytes());
    conn = mock.getConnector("user", pToken);
    config = new BatchWriterConfig();
    config.setMaxMemory(1000);
    config.setMaxLatency(1000, TimeUnit.SECONDS);
    config.setMaxWriteThreads(10);
    if (conn.tableOperations().exists("rya_prospects")) {
        conn.tableOperations().delete("rya_prospects");
    }
    if (conn.tableOperations().exists("rya_selectivity")) {
        conn.tableOperations().delete("rya_selectivity");
    }
    arc = new AccumuloRdfConfiguration();
    arc.setTableLayoutStrategy(new TablePrefixLayoutStrategy());
    arc.setMaxRangesForScanner(300);
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) TablePrefixLayoutStrategy(org.apache.rya.api.layout.TablePrefixLayoutStrategy) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) Before(org.junit.Before)

Aggregations

TablePrefixLayoutStrategy (org.apache.rya.api.layout.TablePrefixLayoutStrategy)11 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)7 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)4 MockInstance (org.apache.accumulo.core.client.mock.MockInstance)4 Before (org.junit.Before)4 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)3 RdfCloudTripleStoreConfiguration (org.apache.rya.api.RdfCloudTripleStoreConfiguration)3 ProspectorServiceEvalStatsDAO (org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAO)3 MongoDBRdfConfiguration (org.apache.rya.mongodb.MongoDBRdfConfiguration)2 StatefulMongoDBRdfConfiguration (org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration)2 RdfCloudTripleStore (org.apache.rya.rdftriplestore.RdfCloudTripleStore)2 InferenceEngine (org.apache.rya.rdftriplestore.inference.InferenceEngine)2 MongoClient (com.mongodb.MongoClient)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 TableOperations (org.apache.accumulo.core.client.admin.TableOperations)1 Configuration (org.apache.hadoop.conf.Configuration)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 Path (org.apache.hadoop.fs.Path)1