/** * Create an {@link Instance} that may be used to create {@link Connector}s * to Accumulo. If the configuration has the {@link #USE_MOCK_INSTANCE} flag * set, then the instance will be be a {@link MockInstance} instead of a * Zookeeper backed instance. * * @param conf - The configuration object that will be interrogated. (not null) * @return The {@link Instance} that may be used to connect to Accumulo. */ public static Instance getInstance(final Configuration conf) { // Pull out the Accumulo specific configuration values. final AccumuloRdfConfiguration accConf = new AccumuloRdfConfiguration(conf); final String instanceName = accConf.getInstanceName(); final String zoookeepers = accConf.getZookeepers(); // Create an Instance a mock if the mock flag is set. if (useMockInstance(conf)) { return new MockInstance(instanceName); } // Otherwise create an Instance to a Zookeeper managed instance of Accumulo. return new ZooKeeperInstance(instanceName, zoookeepers); }
/** * Create an {@link Instance} that may be used to create {@link Connector}s * to Accumulo. If the configuration has the {@link #USE_MOCK_INSTANCE} flag * set, then the instance will be be a {@link MockInstance} instead of a * Zookeeper backed instance. * * @param conf - The configuration object that will be interrogated. (not null) * @return The {@link Instance} that may be used to connect to Accumulo. */ public static Instance getInstance(final Configuration conf) { // Pull out the Accumulo specific configuration values. final AccumuloRdfConfiguration accConf = new AccumuloRdfConfiguration(conf); final String instanceName = accConf.getInstanceName(); final String zoookeepers = accConf.getZookeepers(); // Create an Instance a mock if the mock flag is set. if (useMockInstance(conf)) { return new MockInstance(instanceName); } // Otherwise create an Instance to a Zookeeper managed instance of Accumulo. return new ZooKeeperInstance(instanceName, zoookeepers); }
/** * 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())); } }
/** * 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())); } }