use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class QueryIT method runTest.
public void runTest(final String sparql, final Collection<Statement> statements, final Collection<BindingSet> expectedResults, final ExportStrategy strategy) throws Exception {
requireNonNull(sparql);
requireNonNull(statements);
requireNonNull(expectedResults);
// Register the PCJ with Rya.
final Connector accumuloConn = super.getAccumuloConnector();
final RyaClient ryaClient = AccumuloRyaClientFactory.build(createConnectionDetails(), accumuloConn);
switch(strategy) {
case RYA:
ryaClient.getCreatePCJ().createPCJ(getRyaInstanceName(), sparql);
addStatementsAndWait(statements);
// Fetch the value that is stored within the PCJ table.
try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumuloConn, getRyaInstanceName())) {
final String pcjId = pcjStorage.listPcjs().get(0);
final Set<BindingSet> results = Sets.newHashSet(pcjStorage.listResults(pcjId));
// Ensure the result of the query matches the expected result.
assertEquals(expectedResults, results);
}
break;
case PERIODIC:
final PeriodicQueryResultStorage periodicStorage = new AccumuloPeriodicQueryResultStorage(accumuloConn, getRyaInstanceName());
final String periodicId = periodicStorage.createPeriodicQuery(sparql);
try (FluoClient fluo = new FluoClientImpl(super.getFluoConfiguration())) {
new CreateFluoPcj().createPcj(periodicId, sparql, Sets.newHashSet(ExportStrategy.PERIODIC), fluo);
}
addStatementsAndWait(statements);
final Set<BindingSet> results = Sets.newHashSet();
try (CloseableIterator<BindingSet> resultIter = periodicStorage.listResults(periodicId, Optional.empty())) {
while (resultIter.hasNext()) {
results.add(resultIter.next());
}
}
assertEquals(expectedResults, results);
break;
default:
throw new RuntimeException("Invalid export option");
}
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class KafkaExportITBase method teardownRya.
@After
public void teardownRya() {
final MiniAccumuloCluster cluster = getMiniAccumuloCluster();
final String instanceName = cluster.getInstanceName();
final String zookeepers = cluster.getZooKeepers();
// Uninstall the instance of Rya.
final RyaClient ryaClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), instanceName, zookeepers), super.getAccumuloConnector());
try {
ryaClient.getUninstall().uninstall(RYA_INSTANCE_NAME);
// Shutdown the repo.
if (ryaSailRepo != null) {
ryaSailRepo.shutDown();
}
if (dao != null) {
dao.destroy();
}
} catch (final Exception e) {
System.out.println("Encountered the following Exception when shutting down Rya: " + e.getMessage());
}
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class AccumuloInstallIT method install.
@Test
public void install() throws AccumuloException, AccumuloSecurityException, DuplicateInstanceNameException, RyaClientException, NotInitializedException, RyaDetailsRepositoryException {
// Install an instance of Rya.
final String instanceName = getRyaInstanceName();
final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
final RyaClient ryaClient = AccumuloRyaClientFactory.build(connectionDetails, getConnector());
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(false).setEnableEntityCentricIndex(false).setEnableFreeTextIndex(false).setEnableTemporalIndex(false).setEnablePcjIndex(false).setEnableGeoIndex(false).build();
ryaClient.getInstall().install(instanceName, installConfig);
// Check that the instance exists.
assertTrue(ryaClient.getInstanceExists().exists(instanceName));
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class AccumuloInstallIT method install_withIndexers.
@Test
public void install_withIndexers() throws AccumuloException, AccumuloSecurityException, DuplicateInstanceNameException, RyaClientException, NotInitializedException, RyaDetailsRepositoryException {
// Install an instance of Rya.
final String instanceName = getRyaInstanceName();
final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
final RyaClient ryaClient = AccumuloRyaClientFactory.build(connectionDetails, getConnector());
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).setEnableGeoIndex(true).build();
ryaClient.getInstall().install(instanceName, installConfig);
// Check that the instance exists.
assertTrue(ryaClient.getInstanceExists().exists(instanceName));
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class AccumuloInstallIT method install_alreadyExists.
@Test(expected = DuplicateInstanceNameException.class)
public void install_alreadyExists() throws DuplicateInstanceNameException, RyaClientException, AccumuloException, AccumuloSecurityException {
// Install an instance of Rya.
final String instanceName = getRyaInstanceName();
final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
final RyaClient ryaClient = AccumuloRyaClientFactory.build(connectionDetails, getConnector());
final InstallConfiguration installConfig = InstallConfiguration.builder().build();
ryaClient.getInstall().install(instanceName, installConfig);
// Install it again.
ryaClient.getInstall().install(instanceName, installConfig);
}
Aggregations