Search in sources :

Example 16 with ZooKeeperInstance

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();
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) AccumuloPeriodicQueryResultStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPeriodicQueryResultStorage) IncrementalBindingSetExporter(org.apache.rya.indexing.pcj.fluo.app.export.IncrementalBindingSetExporter) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) AccumuloPeriodicQueryResultStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPeriodicQueryResultStorage) PeriodicQueryResultStorage(org.apache.rya.indexing.pcj.storage.PeriodicQueryResultStorage)

Example 17 with ZooKeeperInstance

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()));
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 18 with ZooKeeperInstance

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;
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) File(java.io.File) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 19 with ZooKeeperInstance

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();
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) MiniAccumuloCluster(org.apache.accumulo.minicluster.MiniAccumuloCluster) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 20 with ZooKeeperInstance

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);
    }
}
Also used : VertexiumException(org.vertexium.VertexiumException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) VertexiumException(org.vertexium.VertexiumException) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Aggregations

ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)52 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)35 Instance (org.apache.accumulo.core.client.Instance)24 Connector (org.apache.accumulo.core.client.Connector)17 AccumuloException (org.apache.accumulo.core.client.AccumuloException)15 MockInstance (org.apache.accumulo.core.client.mock.MockInstance)15 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)13 IOException (java.io.IOException)8 Test (org.junit.Test)8 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)7 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)7 Range (org.apache.accumulo.core.data.Range)6 ArrayList (java.util.ArrayList)5 MiniAccumuloCluster (org.apache.accumulo.minicluster.MiniAccumuloCluster)5 Text (org.apache.hadoop.io.Text)5 File (java.io.File)4 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)4 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)4 Pair (org.apache.accumulo.core.util.Pair)4 AccumuloConnectionParameters (org.apache.hadoop.hive.accumulo.AccumuloConnectionParameters)4