use of org.apache.rya.api.client.accumulo.AccumuloConnectionDetails in project incubator-rya by apache.
the class GeoFunctionsIT method runTest.
public void runTest(final String sparql, final Collection<Statement> statements, final Collection<BindingSet> expectedResults) throws Exception {
requireNonNull(sparql);
requireNonNull(statements);
requireNonNull(expectedResults);
// Register the PCJ with Rya.
final Instance accInstance = super.getAccumuloConnector().getInstance();
final Connector accumuloConn = super.getAccumuloConnector();
final RyaClient ryaClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), accInstance.getInstanceName(), accInstance.getZooKeepers()), accumuloConn);
ryaClient.getCreatePCJ().createPCJ(getRyaInstanceName(), sparql);
// Write the data to Rya.
final SailRepositoryConnection ryaConn = super.getRyaSailRepository().getConnection();
ryaConn.begin();
ryaConn.add(statements);
ryaConn.commit();
ryaConn.close();
// Wait for the Fluo application to finish computing the end result.
super.getMiniFluo().waitForObservers();
// 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);
}
}
use of org.apache.rya.api.client.accumulo.AccumuloConnectionDetails in project incubator-rya by apache.
the class KafkaExportITBase method loadDataAndCreateQuery.
protected String loadDataAndCreateQuery(final String sparql, final Collection<Statement> statements) throws Exception {
requireNonNull(sparql);
requireNonNull(statements);
// Register the PCJ with Rya.
final Instance accInstance = super.getAccumuloConnector().getInstance();
final Connector accumuloConn = super.getAccumuloConnector();
final RyaClient ryaClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), accInstance.getInstanceName(), accInstance.getZooKeepers()), accumuloConn);
final String pcjId = ryaClient.getCreatePCJ().createPCJ(RYA_INSTANCE_NAME, sparql, Sets.newHashSet(ExportStrategy.KAFKA));
loadData(statements);
// The PCJ Id is the topic name the results will be written to.
return pcjId;
}
use of org.apache.rya.api.client.accumulo.AccumuloConnectionDetails in project incubator-rya by apache.
the class KafkaExportITBase method installRyaInstance.
private void installRyaInstance() throws Exception {
final MiniAccumuloCluster cluster = super.getMiniAccumuloCluster();
final String instanceName = cluster.getInstanceName();
final String zookeepers = cluster.getZooKeepers();
// Install the Rya instance to the mini accumulo cluster.
final RyaClient ryaClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), instanceName, zookeepers), super.getAccumuloConnector());
ryaClient.getInstall().install(RYA_INSTANCE_NAME, InstallConfiguration.builder().setEnableTableHashPrefix(false).setEnableFreeTextIndex(false).setEnableEntityCentricIndex(false).setEnableGeoIndex(false).setEnableTemporalIndex(false).setEnablePcjIndex(true).setFluoPcjAppName(super.getFluoConfiguration().getApplicationName()).build());
// Connect to the Rya instance that was just installed.
final AccumuloRdfConfiguration conf = makeConfig(instanceName, zookeepers);
final Sail sail = RyaSailFactory.getInstance(conf);
dao = RyaSailFactory.getAccumuloDAOWithUpdatedConfig(conf);
ryaSailRepo = new RyaSailRepository(sail);
}
use of org.apache.rya.api.client.accumulo.AccumuloConnectionDetails in project incubator-rya by apache.
the class RyaConnectionCommands method printConnectionDetails.
@CliCommand(value = PRINT_CONNECTION_DETAILS_CMD, help = "Print information about the Shell's Rya storage connection.")
public String printConnectionDetails() {
// Check to see if the shell is connected to any storages.
final com.google.common.base.Optional<StorageType> storageType = sharedState.getShellState().getStorageType();
if (!storageType.isPresent()) {
return "The shell is not connected to anything.";
}
// Create a print out based on what it is connected to.
switch(storageType.get()) {
case ACCUMULO:
final AccumuloConnectionDetails accDetails = sharedState.getShellState().getAccumuloDetails().get();
return "The shell is connected to an instance of Accumulo using the following parameters:\n" + " Username: " + accDetails.getUsername() + "\n" + " Instance Name: " + accDetails.getInstanceName() + "\n" + " Zookeepers: " + accDetails.getZookeepers();
case MONGO:
final MongoConnectionDetails mongoDetails = sharedState.getShellState().getMongoDetails().get();
final StringBuilder message = new StringBuilder().append("The shell is connected to an instance of MongoDB using the following parameters:\n").append(" Hostname: " + mongoDetails.getHostname() + "\n").append(" Port: " + mongoDetails.getPort() + "\n");
if (mongoDetails.getUsername().isPresent()) {
message.append(" Username: " + mongoDetails.getUsername().get() + "\n");
}
return message.toString();
default:
throw new RuntimeException("Unrecognized StorageType: " + storageType.get());
}
}
use of org.apache.rya.api.client.accumulo.AccumuloConnectionDetails in project incubator-rya by apache.
the class RyaConnectionCommands method connectToAccumulo.
@CliCommand(value = CONNECT_ACCUMULO_CMD, help = "Connect the shell to an instance of Accumulo.")
public String connectToAccumulo(@CliOption(key = { "username" }, mandatory = true, help = "The username that will be used to connect to Accummulo.") final String username, @CliOption(key = { "instanceName" }, mandatory = true, help = "The name of the Accumulo instance that will be connected to.") final String instanceName, @CliOption(key = { "zookeepers" }, mandatory = true, help = "A comma delimited list of zookeeper server hostnames.") final String zookeepers) {
try {
// Prompt the user for their password.
final char[] password = passwordPrompt.getPassword();
final Connector connector = new ConnectorFactory().connect(username, CharBuffer.wrap(password), instanceName, zookeepers);
// Initialize the connected to Accumulo shared state.
final AccumuloConnectionDetails accumuloDetails = new AccumuloConnectionDetails(username, password, instanceName, zookeepers);
final RyaClient commands = AccumuloRyaClientFactory.build(accumuloDetails, connector);
sharedState.connectedToAccumulo(accumuloDetails, commands);
} catch (IOException | AccumuloException | AccumuloSecurityException e) {
throw new RuntimeException("Could not connect to Accumulo. Reason: " + e.getMessage(), e);
}
return "Connected. You must select a Rya instance to interact with next.";
}
Aggregations