Search in sources :

Example 11 with RyaSailRepository

use of org.apache.rya.rdftriplestore.RyaSailRepository in project incubator-rya by apache.

the class ITBase method shutdownMiniResources.

@AfterClass
public static void shutdownMiniResources() throws RepositoryException {
    for (final RyaSailRepository repo : ryaRepos) {
        repo.shutDown();
    }
    for (final RepositoryConnection conn : ryaConns) {
        conn.close();
    }
    for (final MongoClient client : clients) {
        client.close();
    }
    ryaRepos.clear();
    ryaConns.clear();
    clients.clear();
}
Also used : RepositoryConnection(org.openrdf.repository.RepositoryConnection) MongoClient(com.mongodb.MongoClient) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) AfterClass(org.junit.AfterClass)

Example 12 with RyaSailRepository

use of org.apache.rya.rdftriplestore.RyaSailRepository in project incubator-rya by apache.

the class CbSailTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    store = new MockRdfCloudStore();
    // store.setDisplayQueryPlan(true);
    // store.setInferencing(false);
    NamespaceManager nm = new NamespaceManager(store.getRyaDAO(), store.getConf());
    store.setNamespaceManager(nm);
    repository = new RyaSailRepository(store);
    repository.initialize();
    JndiRegistry registry = super.createRegistry();
    registry.bind(Repository.class.getName(), repository);
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) NamespaceManager(org.apache.rya.rdftriplestore.namespace.NamespaceManager) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) Repository(org.openrdf.repository.Repository) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository)

Example 13 with RyaSailRepository

use of org.apache.rya.rdftriplestore.RyaSailRepository in project incubator-rya by apache.

the class PcjAdminClient method main.

public static void main(final String[] args) {
    log.trace("Starting up the PCJ Admin Client.");
    // If no command provided or the command isn't recognized, then print the usage.
    if (args.length == 0 || !commands.containsKey(args[0])) {
        System.out.println(usage);
        System.exit(-1);
    }
    // Load the properties file.
    final Properties props = new Properties();
    try (InputStream pin = Files.newInputStream(PROPERTIES_FILE)) {
        props.load(pin);
    } catch (final IOException e) {
        throw new RuntimeException("Could not load properties file: " + PROPERTIES_FILE, e);
    }
    // Fetch the command that will be executed.
    final String command = args[0];
    final String[] commandArgs = Arrays.copyOfRange(args, 1, args.length);
    final PcjAdminClientCommand pcjCommand = commands.get(command);
    RyaSailRepository rya = null;
    FluoClient fluo = null;
    try {
        // Connect to Accumulo, Rya, and Fluo.
        final PcjAdminClientProperties clientProps = new PcjAdminClientProperties(props);
        final Connector accumulo = createAccumuloConnector(clientProps);
        rya = makeRyaRepository(clientProps, accumulo);
        fluo = createFluoClient(clientProps);
        // Execute the command.
        pcjCommand.execute(accumulo, clientProps.getRyaTablePrefix(), rya, fluo, commandArgs);
    } catch (final AccumuloException | AccumuloSecurityException e) {
        System.err.println("Could not connect to the Accumulo instance that hosts the export PCJ tables.");
        e.printStackTrace();
        System.exit(-1);
    } catch (final RepositoryException e) {
        System.err.println("Could not connect to the Rya instance that hosts the historic RDF statements.");
        e.printStackTrace();
        System.exit(-1);
    } catch (final ArgumentsException e) {
        System.err.println(pcjCommand.getUsage());
        System.exit(-1);
    } catch (final ExecutionException e) {
        System.err.println("Could not execute the command.");
        e.printStackTrace();
        System.exit(-1);
    } catch (UnsupportedQueryException e) {
        System.err.println("Could not execute the command because the query is invalid.");
        e.printStackTrace();
    } finally {
        log.trace("Shutting down the PCJ Admin Client.");
        if (rya != null) {
            try {
                rya.shutDown();
            } catch (final RepositoryException e) {
                System.err.println("Problem while shutting down the Rya connection.");
                e.printStackTrace();
            }
        }
        if (fluo != null) {
            fluo.close();
        }
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) FluoClient(org.apache.fluo.api.client.FluoClient) ArgumentsException(org.apache.rya.indexing.pcj.fluo.client.PcjAdminClientCommand.ArgumentsException) InputStream(java.io.InputStream) UnsupportedQueryException(org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) RepositoryException(org.openrdf.repository.RepositoryException) IOException(java.io.IOException) Properties(java.util.Properties) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ExecutionException(org.apache.rya.indexing.pcj.fluo.client.PcjAdminClientCommand.ExecutionException)

Example 14 with RyaSailRepository

use of org.apache.rya.rdftriplestore.RyaSailRepository in project incubator-rya by apache.

the class FluoITBase method setupRya.

/**
 * Sets up a Rya instance.
 */
protected RyaSailRepository setupRya() throws AccumuloException, AccumuloSecurityException, RepositoryException, RyaDAOException, NumberFormatException, UnknownHostException, InferenceEngineException, AlreadyInitializedException, RyaDetailsRepositoryException, DuplicateInstanceNameException, RyaClientException, SailException {
    checkNotNull(instanceName);
    checkNotNull(zookeepers);
    // Setup Rya configuration values.
    final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    conf.setTablePrefix(getRyaInstanceName());
    conf.setDisplayQueryPlan(true);
    conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, false);
    conf.set(ConfigUtils.CLOUDBASE_USER, clusterInstance.getUsername());
    conf.set(ConfigUtils.CLOUDBASE_PASSWORD, clusterInstance.getPassword());
    conf.set(ConfigUtils.CLOUDBASE_INSTANCE, clusterInstance.getInstanceName());
    conf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, clusterInstance.getZookeepers());
    conf.set(ConfigUtils.USE_PCJ, "true");
    conf.set(ConfigUtils.FLUO_APP_NAME, getRyaInstanceName());
    conf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinStorageType.ACCUMULO.toString());
    conf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinUpdaterType.FLUO.toString());
    conf.set(ConfigUtils.CLOUDBASE_AUTHS, "");
    // Install the test instance of Rya.
    final Install install = new AccumuloInstall(createConnectionDetails(), accumuloConn);
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).setEnableGeoIndex(true).setFluoPcjAppName(getRyaInstanceName()).build();
    install.install(getRyaInstanceName(), installConfig);
    // Connect to the instance of Rya that was just installed.
    final Sail sail = RyaSailFactory.getInstance(conf);
    final RyaSailRepository ryaRepo = new RyaSailRepository(sail);
    return ryaRepo;
}
Also used : AccumuloInstall(org.apache.rya.api.client.accumulo.AccumuloInstall) Sail(org.openrdf.sail.Sail) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) AccumuloInstall(org.apache.rya.api.client.accumulo.AccumuloInstall) Install(org.apache.rya.api.client.Install) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration)

Example 15 with RyaSailRepository

use of org.apache.rya.rdftriplestore.RyaSailRepository in project incubator-rya by apache.

the class PcjTablesWithMockTest method setupRya.

private static RyaSailRepository setupRya(Connector accumuloConn) throws AccumuloException, AccumuloSecurityException, RepositoryException {
    // Setup the Rya Repository that will be used to create Repository
    // Connections.
    final RdfCloudTripleStore ryaStore = new RdfCloudTripleStore();
    final AccumuloRyaDAO crdfdao = new AccumuloRyaDAO();
    crdfdao.setConnector(accumuloConn);
    // Setup Rya configuration values.
    final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    conf.setTablePrefix("demo_");
    conf.setDisplayQueryPlan(false);
    conf.setBoolean(USE_MOCK_INSTANCE, true);
    conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, RYA_TABLE_PREFIX);
    conf.set(CLOUDBASE_USER, "root");
    conf.set(CLOUDBASE_PASSWORD, "");
    conf.set(CLOUDBASE_INSTANCE, "instance");
    crdfdao.setConf(conf);
    ryaStore.setRyaDAO(crdfdao);
    final RyaSailRepository ryaRepo = new RyaSailRepository(ryaStore);
    ryaRepo.initialize();
    return ryaRepo;
}
Also used : RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Aggregations

RyaSailRepository (org.apache.rya.rdftriplestore.RyaSailRepository)20 RdfCloudTripleStore (org.apache.rya.rdftriplestore.RdfCloudTripleStore)9 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)8 AccumuloRyaDAO (org.apache.rya.accumulo.AccumuloRyaDAO)5 Sail (org.openrdf.sail.Sail)5 Test (org.junit.Test)4 HashSet (java.util.HashSet)3 Connector (org.apache.accumulo.core.client.Connector)3 PcjMetadata (org.apache.rya.indexing.pcj.storage.PcjMetadata)3 MongoDBRyaDAO (org.apache.rya.mongodb.MongoDBRyaDAO)3 StatefulMongoDBRdfConfiguration (org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration)3 NamespaceManager (org.apache.rya.rdftriplestore.namespace.NamespaceManager)3 Statement (org.openrdf.model.Statement)3 LiteralImpl (org.openrdf.model.impl.LiteralImpl)3 NumericLiteralImpl (org.openrdf.model.impl.NumericLiteralImpl)3 StatementImpl (org.openrdf.model.impl.StatementImpl)3 URIImpl (org.openrdf.model.impl.URIImpl)3 SailRepositoryConnection (org.openrdf.repository.sail.SailRepositoryConnection)3 MongoClient (com.mongodb.MongoClient)2 Install (org.apache.rya.api.client.Install)2