Search in sources :

Example 21 with Install

use of org.apache.rya.api.client.Install 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)

Example 22 with Install

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

the class MongoInstallIT method install.

@Test
public void install() throws DuplicateInstanceNameException, RyaClientException {
    // Install an instance of Rya.
    final String ryaInstance = conf.getMongoDBName();
    // Setup the connection details that were used for the embedded Mongo DB instance we are testing with.
    final MongoConnectionDetails connectionDetails = getConnectionDetails();
    // Check that the instance does not exist.
    final InstanceExists instanceExists = new MongoInstanceExists(getMongoClient());
    assertFalse(instanceExists.exists(ryaInstance));
    // Install an instance of Rya with all the valid options turned on.
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).build();
    final RyaClient ryaClient = MongoRyaClientFactory.build(connectionDetails, getMongoClient());
    final Install install = ryaClient.getInstall();
    install.install(ryaInstance, installConfig);
    // Check that the instance exists.
    assertTrue(instanceExists.exists(ryaInstance));
    // Show that the expected collections were created within the database.
    final List<String> expected = Arrays.asList(INSTANCE_DETAILS_COLLECTION_NAME, "rya_triples");
    int count = 0;
    final List<String> found = new ArrayList<>();
    for (final String collection : getMongoClient().getDatabase(conf.getMongoDBName()).listCollectionNames()) {
        count += expected.contains(collection) ? 1 : 0;
        found.add(collection);
    }
    assertTrue("Tables missing from:" + expected + " actual:" + found, expected.size() == count);
    assertTrue("Instance should exist.", instanceExists.exists(ryaInstance));
}
Also used : InstanceExists(org.apache.rya.api.client.InstanceExists) ArrayList(java.util.ArrayList) 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)

Aggregations

Install (org.apache.rya.api.client.Install)22 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)20 Test (org.junit.Test)20 RyaClient (org.apache.rya.api.client.RyaClient)17 CreatePCJ (org.apache.rya.api.client.CreatePCJ)4 RyaDetails (org.apache.rya.api.instance.RyaDetails)4 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)4 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)4 UninstallPrompt (org.apache.rya.shell.util.UninstallPrompt)4 ArrayList (java.util.ArrayList)3 InstanceExists (org.apache.rya.api.client.InstanceExists)3 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)3 AccumuloCreatePCJ (org.apache.rya.api.client.accumulo.AccumuloCreatePCJ)3 Date (java.util.Date)2 GetInstanceDetails (org.apache.rya.api.client.GetInstanceDetails)2 ListInstances (org.apache.rya.api.client.ListInstances)2 EntityCentricIndexDetails (org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails)2 FreeTextIndexDetails (org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails)2 JoinSelectivityDetails (org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails)2 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)2