use of org.apache.accumulo.core.client.ZooKeeperInstance in project incubator-rya by apache.
the class PeriodicBindingSetExporterFactory method build.
@Override
public Optional<IncrementalResultExporter> build(Context context) throws IncrementalExporterFactoryException, ConfigurationException {
checkNotNull(context);
// Wrap the context's parameters for parsing.
final RyaExportParameters params = new RyaExportParameters(context.getObserverConfiguration().toMap());
if (params.getUsePeriodicBindingSetExporter()) {
// Setup Zookeeper connection info.
final String accumuloInstance = params.getAccumuloInstanceName().get();
final String zookeeperServers = params.getZookeeperServers().get().replaceAll(";", ",");
final Instance inst = new ZooKeeperInstance(accumuloInstance, zookeeperServers);
try {
// Setup Accumulo connection info.
final String exporterUsername = params.getExporterUsername().get();
final String exporterPassword = params.getExporterPassword().get();
final Connector accumuloConn = inst.getConnector(exporterUsername, new PasswordToken(exporterPassword));
// Setup Rya PCJ Storage.
final String ryaInstanceName = params.getRyaInstanceName().get();
final PeriodicQueryResultStorage periodicStorage = new AccumuloPeriodicQueryResultStorage(accumuloConn, ryaInstanceName);
// Make the exporter.
final IncrementalBindingSetExporter exporter = new PeriodicBindingSetExporter(periodicStorage);
return Optional.of(exporter);
} catch (final AccumuloException | AccumuloSecurityException e) {
throw new IncrementalExporterFactoryException("Could not initialize the Accumulo connector using the provided configuration.", e);
}
} else {
return Optional.absent();
}
}
use of org.apache.accumulo.core.client.ZooKeeperInstance in project incubator-rya by apache.
the class ConnectorFactory method connect.
/**
* Create a {@link Connector} that connects to an Accumulo instance. The {@link AccumuloRdfConfiguration#USE_MOCK_INSTANCE}
* flag must be set if the configuration information needs to connect to a mock instance of Accumulo. If this is
* the case, then the Zookeepers information should not be set.
*
* @param config - The configuration that will be used to initialize the connector. (not null)
* @return The {@link Connector} that was created by {@code config}.
* @throws AccumuloException The connector couldn't be created because of an Accumulo problem.
* @throws AccumuloSecurityException The connector couldn't be created because of an Accumulo security violation.
*/
public static Connector connect(AccumuloRdfConfiguration config) throws AccumuloException, AccumuloSecurityException {
requireNonNull(config);
// Wrap the configuration as the Accumulo configuration so that we may have access
// to Accumulo specific configuration values.
final AccumuloRdfConfiguration accConf = new AccumuloRdfConfiguration(config);
// Create the Mock or Zookeeper backed Instance depending on the configuration.
final Instance instance;
if (accConf.useMockInstance()) {
instance = new MockInstance(accConf.getInstanceName());
} else {
instance = new ZooKeeperInstance(accConf.getInstanceName(), accConf.getZookeepers());
}
// Return a connector using the configured username and password.
return instance.getConnector(accConf.getUsername(), new PasswordToken(accConf.getPassword()));
}
use of org.apache.accumulo.core.client.ZooKeeperInstance in project incubator-rya by apache.
the class DemoDriver method startMiniAccumulo.
/**
* Setup a Mini Accumulo cluster that uses a temporary directory to store its data.
*
* @return A Mini Accumulo cluster.
*/
private static MiniAccumuloCluster startMiniAccumulo() throws IOException, InterruptedException, AccumuloException, AccumuloSecurityException {
final File miniDataDir = Files.createTempDir();
// Setup and start the Mini Accumulo.
final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(miniDataDir, "password");
accumulo.start();
// Store a connector to the Mini Accumulo.
final Instance instance = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers());
accumuloConn = instance.getConnector("root", new PasswordToken("password"));
return accumulo;
}
use of org.apache.accumulo.core.client.ZooKeeperInstance in project incubator-rya by apache.
the class AccumuloInstanceDriver method setUpInstance.
/**
* Sets up the {@link MiniAccumuloCluster} or the {@link MockInstance} or
* distribution instance
* @throws Exception
*/
public void setUpInstance() throws Exception {
switch(instanceType) {
case DISTRIBUTION:
log.info("Setting up " + driverName + " distribution instance...");
if (instanceName == null) {
throw new IllegalArgumentException("Must specify instance name for distributed mode");
} else if (zooKeepers == null) {
throw new IllegalArgumentException("Must specify ZooKeeper hosts for distributed mode");
}
instance = new ZooKeeperInstance(instanceName, zooKeepers);
connector = instance.getConnector(user, new PasswordToken(userpwd));
log.info("Created connector to " + driverName + " distribution instance");
break;
case MINI:
log.info("Setting up " + driverName + " MiniAccumulo cluster...");
// Create and Run MiniAccumulo Cluster
tempDir = Files.createTempDir();
tempDir.deleteOnExit();
miniAccumuloCluster = new MiniAccumuloCluster(tempDir, userpwd);
copyHadoopHomeToTemp();
miniAccumuloCluster.getConfig().setInstanceName(instanceName);
log.info(driverName + " MiniAccumulo instance starting up...");
miniAccumuloCluster.start();
Thread.sleep(1000);
log.info(driverName + " MiniAccumulo instance started");
log.info("Creating connector to " + driverName + " MiniAccumulo instance...");
zooKeeperInstance = new ZooKeeperInstance(miniAccumuloCluster.getClientConfig());
instance = zooKeeperInstance;
connector = zooKeeperInstance.getConnector(user, new PasswordToken(userpwd));
log.info("Created connector to " + driverName + " MiniAccumulo instance");
break;
case MOCK:
log.info("Setting up " + driverName + " mock instance...");
mockInstance = new MockInstance(instanceName);
instance = mockInstance;
connector = mockInstance.getConnector(user, new PasswordToken(userpwd));
log.info("Created connector to " + driverName + " mock instance");
break;
default:
throw new AccumuloException("Unexpected instance type: " + instanceType);
}
zooKeepers = instance.getZooKeepers();
}
use of org.apache.accumulo.core.client.ZooKeeperInstance in project vertexium by visallo.
the class AccumuloGraphConfiguration method createConnector.
public Connector createConnector() {
try {
LOGGER.info("Connecting to accumulo instance [%s] zookeeper servers [%s]", this.getAccumuloInstanceName(), this.getZookeeperServers());
ZooKeeperInstance instance = new ZooKeeperInstance(getClientConfiguration());
return instance.getConnector(this.getAccumuloUsername(), this.getAuthenticationToken());
} catch (Exception ex) {
throw new VertexiumException(String.format("Could not connect to Accumulo instance [%s] zookeeper servers [%s]", this.getAccumuloInstanceName(), this.getZookeeperServers()), ex);
}
}
Aggregations