Search in sources :

Example 26 with InstallConfiguration

use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.

the class AccumuloLoadStatementsFileIT method loadTurtleFile.

@Test
public void loadTurtleFile() throws Exception {
    // Install an instance of Rya.
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(false).setEnableEntityCentricIndex(false).setEnableFreeTextIndex(false).setEnableTemporalIndex(false).setEnablePcjIndex(false).setEnableGeoIndex(false).setFluoPcjAppName("fluo_app_name").build();
    final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
    final RyaClient ryaClient = AccumuloRyaClientFactory.build(connectionDetails, getConnector());
    final Install install = ryaClient.getInstall();
    install.install(getRyaInstanceName(), installConfig);
    // Load the test statement file.
    ryaClient.getLoadStatementsFile().loadStatements(getRyaInstanceName(), Paths.get("src/test/resources/example.ttl"), RDFFormat.TURTLE);
    // Verify that the statements were loaded.
    final ValueFactory vf = new ValueFactoryImpl();
    final List<Statement> expected = new ArrayList<>();
    expected.add(vf.createStatement(vf.createURI("http://example#alice"), vf.createURI("http://example#talksTo"), vf.createURI("http://example#bob")));
    expected.add(vf.createStatement(vf.createURI("http://example#bob"), vf.createURI("http://example#talksTo"), vf.createURI("http://example#charlie")));
    expected.add(vf.createStatement(vf.createURI("http://example#charlie"), vf.createURI("http://example#likes"), vf.createURI("http://example#icecream")));
    final List<Statement> statements = new ArrayList<>();
    final WholeRowTripleResolver tripleResolver = new WholeRowTripleResolver();
    final Scanner scanner = getConnector().createScanner(getRyaInstanceName() + "spo", new Authorizations());
    final Iterator<Entry<Key, Value>> it = scanner.iterator();
    while (it.hasNext()) {
        final Entry<Key, Value> next = it.next();
        final Key key = next.getKey();
        final byte[] row = key.getRow().getBytes();
        final byte[] columnFamily = key.getColumnFamily().getBytes();
        final byte[] columnQualifier = key.getColumnQualifier().getBytes();
        final TripleRow tripleRow = new TripleRow(row, columnFamily, columnQualifier);
        final RyaStatement ryaStatement = tripleResolver.deserialize(TABLE_LAYOUT.SPO, tripleRow);
        final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
        // Filter out the rya version statement if it is present.
        if (!isRyaMetadataStatement(vf, statement)) {
            statements.add(statement);
        }
    }
    assertEquals(expected, statements);
}
Also used : Scanner(org.apache.accumulo.core.client.Scanner) Authorizations(org.apache.accumulo.core.security.Authorizations) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement) ValueFactoryImpl(org.openrdf.model.impl.ValueFactoryImpl) ArrayList(java.util.ArrayList) RyaStatement(org.apache.rya.api.domain.RyaStatement) RyaClient(org.apache.rya.api.client.RyaClient) ValueFactory(org.openrdf.model.ValueFactory) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) Entry(java.util.Map.Entry) TripleRow(org.apache.rya.api.resolver.triple.TripleRow) WholeRowTripleResolver(org.apache.rya.api.resolver.triple.impl.WholeRowTripleResolver) Value(org.apache.accumulo.core.data.Value) Install(org.apache.rya.api.client.Install) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 27 with InstallConfiguration

use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.

the class MongoUninstallIT method uninstall.

@Test
public void uninstall() throws MongoException, RyaClientException {
    // Install an instance of Rya.
    final String instanceName = "testInstance_";
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).setEnableGeoIndex(true).setFluoPcjAppName("fluo_app_name").build();
    final RyaClient ryaClient = MongoRyaClientFactory.build(getConnectionDetails(), getMongoClient());
    final Install install = ryaClient.getInstall();
    install.install(instanceName, installConfig);
    // Show that the instance exists.
    final InstanceExists instanceExists = ryaClient.getInstanceExists();
    assertTrue(instanceExists.exists(instanceName));
    // Uninstall the instance
    final Uninstall uninstall = ryaClient.getUninstall();
    uninstall.uninstall(instanceName);
    // Check that the instance no longer exists.
    assertFalse(instanceExists.exists(instanceName));
}
Also used : InstanceExists(org.apache.rya.api.client.InstanceExists) Uninstall(org.apache.rya.api.client.Uninstall) RyaClient(org.apache.rya.api.client.RyaClient) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) Install(org.apache.rya.api.client.Install) Test(org.junit.Test)

Example 28 with InstallConfiguration

use of org.apache.rya.api.client.Install.InstallConfiguration 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.
    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 : Sail(org.openrdf.sail.Sail) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) Install(org.apache.rya.api.client.Install) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration)

Example 29 with InstallConfiguration

use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.

the class MongoCreatePCJIT method createPCJ_invalidSparql.

@Test(expected = RyaClientException.class)
public void createPCJ_invalidSparql() throws DuplicateInstanceNameException, RyaClientException {
    final MongoConnectionDetails connectionDetails = getConnectionDetails();
    final RyaClient ryaClient = MongoRyaClientFactory.build(connectionDetails, getMongoClient());
    // Initialize the commands that will be used by this test.
    final CreatePCJ createPCJ = ryaClient.getCreatePCJ();
    final Install installRya = ryaClient.getInstall();
    final InstallConfiguration installConf = InstallConfiguration.builder().setEnablePcjIndex(true).build();
    installRya.install(conf.getRyaInstanceName(), installConf);
    // Create a PCJ.
    final String sparql = "not valid sparql";
    createPCJ.createPCJ(conf.getRyaInstanceName(), sparql);
}
Also used : CreatePCJ(org.apache.rya.api.client.CreatePCJ) AccumuloCreatePCJ(org.apache.rya.api.client.accumulo.AccumuloCreatePCJ) RyaClient(org.apache.rya.api.client.RyaClient) Install(org.apache.rya.api.client.Install) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) Test(org.junit.Test)

Example 30 with InstallConfiguration

use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.

the class MongoCreatePCJIT method createPCJ.

@Test
public void createPCJ() throws Exception {
    final MongoConnectionDetails connectionDetails = getConnectionDetails();
    final RyaClient ryaClient = MongoRyaClientFactory.build(connectionDetails, getMongoClient());
    // Initialize the commands that will be used by this test.
    final CreatePCJ createPCJ = ryaClient.getCreatePCJ();
    final Install installRya = ryaClient.getInstall();
    final InstallConfiguration installConf = InstallConfiguration.builder().setEnablePcjIndex(true).build();
    installRya.install(conf.getRyaInstanceName(), installConf);
    System.out.println(getMongoClient().getDatabase(conf.getRyaInstanceName()).getCollection("instance_details").find().first().toJson());
    // Create a PCJ.
    final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://TacoJoint>." + "}";
    final String pcjId = createPCJ.createPCJ(conf.getRyaInstanceName(), sparql);
    // Verify the RyaDetails were updated to include the new PCJ.
    final Optional<RyaDetails> ryaDetails = ryaClient.getGetInstanceDetails().getDetails(conf.getRyaInstanceName());
    final ImmutableMap<String, PCJDetails> details = ryaDetails.get().getPCJIndexDetails().getPCJDetails();
    final PCJDetails pcjDetails = details.get(pcjId);
    assertEquals(pcjId, pcjDetails.getId());
    assertFalse(pcjDetails.getLastUpdateTime().isPresent());
    try (final PrecomputedJoinStorage pcjStorage = new MongoPcjStorage(getMongoClient(), conf.getRyaInstanceName())) {
        final PcjMetadata pcjMetadata = pcjStorage.getPcjMetadata(pcjId);
        // confirm that the pcj was added to the pcj store.
        assertEquals(sparql, pcjMetadata.getSparql());
        assertEquals(0L, pcjMetadata.getCardinality());
    }
}
Also used : CreatePCJ(org.apache.rya.api.client.CreatePCJ) AccumuloCreatePCJ(org.apache.rya.api.client.accumulo.AccumuloCreatePCJ) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails) MongoPcjStorage(org.apache.rya.indexing.pcj.storage.mongo.MongoPcjStorage) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) PcjMetadata(org.apache.rya.indexing.pcj.storage.PcjMetadata) Install(org.apache.rya.api.client.Install) Test(org.junit.Test)

Aggregations

InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)32 RyaClient (org.apache.rya.api.client.RyaClient)26 Test (org.junit.Test)26 Install (org.apache.rya.api.client.Install)20 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)6 Statement (org.openrdf.model.Statement)5 CreatePCJ (org.apache.rya.api.client.CreatePCJ)4 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)4 RyaDetails (org.apache.rya.api.instance.RyaDetails)4 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)4 UninstallPrompt (org.apache.rya.shell.util.UninstallPrompt)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 DuplicateInstanceNameException (org.apache.rya.api.client.Install.DuplicateInstanceNameException)3 InstanceExists (org.apache.rya.api.client.InstanceExists)3 RyaClientException (org.apache.rya.api.client.RyaClientException)3 AccumuloCreatePCJ (org.apache.rya.api.client.accumulo.AccumuloCreatePCJ)3 ValueFactory (org.openrdf.model.ValueFactory)3 Sail (org.openrdf.sail.Sail)3 CliCommand (org.springframework.shell.core.annotation.CliCommand)3