use of org.apache.rya.shell.util.ConnectorFactory 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