org.apache.accumulo.core.client.Instance Java Examples

The following examples show how to use org.apache.accumulo.core.client.Instance. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectorFactory.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@link Connector} that uses the provided connection details.
 *
 * @param username - The username the connection will use. (not null)
 * @param password - The password the connection will use. (not null)
 * @param instanceName - The name of the Accumulo instance. (not null)
 * @param zookeeperHostnames - A comma delimited list of the Zookeeper server hostnames. (not null)
 * @return A {@link Connector} that may be used to access the instance of Accumulo.
 * @throws AccumuloSecurityException Could not connect for security reasons.
 * @throws AccumuloException Could not connect for other reasons.
 */
public Connector connect(
        final String username,
        final CharSequence password,
        final String instanceName,
        final String zookeeperHostnames) throws AccumuloException, AccumuloSecurityException {
    requireNonNull(username);
    requireNonNull(password);
    requireNonNull(instanceName);
    requireNonNull(zookeeperHostnames);

    // Setup the password token that will be used.
    final PasswordToken token = new PasswordToken( password );

    // Connect to the instance of Accumulo.
    final Instance instance = new ZooKeeperInstance(instanceName, zookeeperHostnames);
    return instance.getConnector(username, token);
}
 
Example #2
Source File: DateIndexHelper.java    From datawave with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the instance with a provided update interval.
 * 
 * @param connector
 *            A Connector to Accumulo
 * @param dateIndexTableName
 *            The name of the date index table
 * @param auths
 *            Any {@link Authorizations} to use
 */
protected DateIndexHelper initialize(Connector connector, Instance instance, String dateIndexTableName, Set<Authorizations> auths, int numQueryThreads,
                float collapseDatePercentThreshold) {
    this.connector = connector;
    this.instance = instance;
    this.dateIndexTableName = dateIndexTableName;
    this.auths = auths;
    this.numQueryThreads = numQueryThreads;
    this.collapseDatePercentThreshold = collapseDatePercentThreshold;
    
    if (log.isTraceEnabled()) {
        log.trace("Constructor  connector: " + (connector != null ? connector.getClass().getCanonicalName() : connector) + " with auths: " + auths
                        + " and date index table name: " + dateIndexTableName + "; " + numQueryThreads + " threads and " + collapseDatePercentThreshold
                        + " collapse date percent threshold");
    }
    return this;
}
 
Example #3
Source File: DailyShardSplitter.java    From accumulo-recipes with Apache License 2.0 6 votes vote down vote up
public static void main(String args[]) throws AccumuloSecurityException, AccumuloException, TableNotFoundException {

        if (args.length != 7) {
            System.out.println("Usage: " + DailyShardSplitter.class.getName() + "<zookeepers> <instance> <username> <password> <tableName> <start day: yyyy-mm-dd> <stop day: yyyy-mm-dd>");
            System.exit(1);
        }

        String zookeepers = args[0];
        String instance = args[1];
        String username = args[2];
        String password = args[3];
        String tableName = args[4];
        DateTime start = DateTime.parse(args[5]);
        DateTime stop = DateTime.parse(args[6]);


        Instance accInst = new ZooKeeperInstance(instance, zookeepers);
        Connector connector = accInst.getConnector(username, password.getBytes());

        SortedSet<Text> shards = new DailyShardBuilder(Constants.DEFAULT_PARTITION_SIZE)
                .buildShardsInRange(start.toDate(), stop.toDate());

        connector.tableOperations().addSplits(tableName, shards);
    }
 
Example #4
Source File: EntityInputFormat.java    From accumulo-recipes with Apache License 2.0 6 votes vote down vote up
public static void setQueryInfo(Job job, Set<String> entityTypes, Node query, EntityShardBuilder shardBuilder, TypeRegistry<String> typeRegistry) throws AccumuloSecurityException, AccumuloException, TableNotFoundException, IOException {

        validateOptions(job);

        checkNotNull(shardBuilder);
        checkNotNull(query);
        checkNotNull(entityTypes);
        checkNotNull(typeRegistry);

        Instance instance = getInstance(job);
        Connector connector = instance.getConnector(getPrincipal(job), getAuthenticationToken(job));
        BatchScanner scanner = connector.createBatchScanner(DEFAULT_IDX_TABLE_NAME, getScanAuthorizations(job), 5);
        GlobalIndexVisitor globalIndexVisitor = new EntityGlobalIndexVisitor(scanner, shardBuilder, entityTypes);

        configureScanner(job, entityTypes, query, new NodeToJexl(typeRegistry), globalIndexVisitor, typeRegistry, OptimizedQueryIterator.class);

        job.getConfiguration().setBoolean(QUERY, true);
        job.getConfiguration().set(TYPE_REGISTRY, new String(toBase64(typeRegistry)));
    }
 
Example #5
Source File: DataStore.java    From qonduit with Apache License 2.0 6 votes vote down vote up
public DataStore(Configuration conf) throws QonduitException {

        try {
            final HashMap<String, String> apacheConf = new HashMap<>();
            Configuration.Accumulo accumuloConf = conf.getAccumulo();
            apacheConf.put("instance.name", accumuloConf.getInstanceName());
            apacheConf.put("instance.zookeeper.host", accumuloConf.getZookeepers());
            final ClientConfiguration aconf = ClientConfiguration.fromMap(apacheConf);
            final Instance instance = new ZooKeeperInstance(aconf);
            connector = instance.getConnector(accumuloConf.getUsername(),
                    new PasswordToken(accumuloConf.getPassword()));
        } catch (Exception e) {
            throw new QonduitException(HttpResponseStatus.INTERNAL_SERVER_ERROR.code(), "Error creating DataStoreImpl",
                    e.getMessage(), e);
        }
    }
 
Example #6
Source File: GetMetricTableSplitPoints.java    From timely with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {

        try (ConfigurableApplicationContext ctx = new SpringApplicationBuilder(SpringBootstrap.class)
                .bannerMode(Mode.OFF).web(WebApplicationType.NONE).run(args)) {
            Configuration conf = ctx.getBean(Configuration.class);

            final Map<String, String> properties = new HashMap<>();
            Accumulo accumuloConf = conf.getAccumulo();
            properties.put("instance.name", accumuloConf.getInstanceName());
            properties.put("instance.zookeeper.host", accumuloConf.getZookeepers());
            final ClientConfiguration aconf = ClientConfiguration.fromMap(properties);
            final Instance instance = new ZooKeeperInstance(aconf);
            Connector con = instance.getConnector(accumuloConf.getUsername(),
                    new PasswordToken(accumuloConf.getPassword()));
            Scanner s = con.createScanner(conf.getMetaTable(),
                    con.securityOperations().getUserAuthorizations(con.whoami()));
            try {
                s.setRange(new Range(Meta.METRIC_PREFIX, true, Meta.TAG_PREFIX, false));
                for (Entry<Key, Value> e : s) {
                    System.out.println(e.getKey().getRow().toString().substring(Meta.METRIC_PREFIX.length()));
                }
            } finally {
                s.close();
            }
        }
    }
 
Example #7
Source File: TabletMetadataConsole.java    From timely with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    try (ConfigurableApplicationContext ctx = new SpringApplicationBuilder(SpringBootstrap.class)
            .bannerMode(Banner.Mode.OFF).web(WebApplicationType.NONE).run(args)) {
        Configuration conf = ctx.getBean(Configuration.class);
        HashMap<String, String> apacheConf = new HashMap<>();
        Accumulo accumuloConf = conf.getAccumulo();
        apacheConf.put("instance.name", accumuloConf.getInstanceName());
        apacheConf.put("instance.zookeeper.host", accumuloConf.getZookeepers());
        ClientConfiguration aconf = ClientConfiguration.fromMap(apacheConf);
        Instance instance = new ZooKeeperInstance(aconf);
        Connector con = instance.getConnector(accumuloConf.getUsername(),
                new PasswordToken(accumuloConf.getPassword()));

        TabletMetadataQuery query = new TabletMetadataQuery(con, conf.getMetricsTable());
        TabletMetadataView view = query.run();

        System.out.println(view.toText(TimeUnit.DAYS));
    }
}
 
Example #8
Source File: ArbitraryLengthQueryTest.java    From rya with Apache License 2.0 6 votes vote down vote up
public MockRdfCloudStore() {
    super();
    final Instance instance = new MockInstance();
    try {
        final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
        setConf(conf);

        final Connector connector = instance.getConnector("", "");
        final AccumuloRyaDAO cdao = new AccumuloRyaDAO();
        cdao.setConf(conf);
        cdao.setConnector(connector);
        setRyaDAO(cdao);
        inferenceEngine = new InferenceEngine();
        inferenceEngine.setRyaDAO(cdao);
        inferenceEngine.setRefreshGraphSchedule(5000); //every 5 sec
        inferenceEngine.setConf(conf);
        setInferenceEngine(inferenceEngine);
    } catch (final Exception e) {
        e.printStackTrace();
    }
}
 
Example #9
Source File: RdfCloudTripleStoreConnectionTest.java    From rya with Apache License 2.0 6 votes vote down vote up
public MockRdfCloudStore() {
    super();
    Instance instance = new MockInstance();
    try {
        AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
        conf.setInfer(true);
        setConf(conf);
        Connector connector = instance.getConnector("", "");
        AccumuloRyaDAO cdao = new AccumuloRyaDAO();
        cdao.setConf(conf);
        cdao.setConnector(connector);
        setRyaDAO(cdao);
        inferenceEngine = new InferenceEngine();
        inferenceEngine.setRyaDAO(cdao);
        inferenceEngine.setRefreshGraphSchedule(5000); //every 5 sec
        inferenceEngine.setConf(conf);
        setInferenceEngine(inferenceEngine);
        internalInferenceEngine = inferenceEngine;
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #10
Source File: ConnectorPool.java    From geowave with Apache License 2.0 6 votes vote down vote up
public synchronized Connector getConnector(
    final String zookeeperUrl,
    final String instanceName,
    final String userName,
    final String password) throws AccumuloException, AccumuloSecurityException {

  final ConnectorConfig config =
      new ConnectorConfig(zookeeperUrl, instanceName, userName, password);
  Connector connector = connectorCache.get(config);
  if (connector == null) {
    final Instance inst = new ZooKeeperInstance(instanceName, zookeeperUrl);
    connector = inst.getConnector(userName, password);
    connectorCache.put(config, connector);
  }
  return connector;
}
 
Example #11
Source File: KafkaExportITBase.java    From rya with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #12
Source File: AccumuloConnector.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
/**
 * For testing.
 *
 * @param instance
 * @param user
 * @param pass
 * @return
 */
public static Connector getMockConnector(String instance, String user,
    String pass) throws DataProviderException
{
  Instance mock = new MockInstance(instance);
  Connector conn = null;
  try
  {
    conn = mock.getConnector(user, pass.getBytes());
  }
  catch (Exception e)
  {
    throw new DataProviderException(
        "problem creating mock connector - " + e.getMessage(), e);
  }

  return conn;
}
 
Example #13
Source File: AccumuloConnector.java    From mrgeo with Apache License 2.0 6 votes vote down vote up
public static synchronized Connector getConnector(String instance, String zookeepers,
    String user, String pass) throws DataProviderException
{

  if (conn != null)
  {
    return conn;
  }
  if (checkMock())
  {
    return getMockConnector(instance, user, pass);
  }

  Instance inst = new ZooKeeperInstance(instance, zookeepers);
  try
  {
    conn = inst.getConnector(user, new PasswordToken(pass.getBytes()));
    return conn;
  }
  catch (Exception e)
  {
    throw new DataProviderException("problem creating connector", e);
  }
}
 
Example #14
Source File: CbSailTest.java    From rya with Apache License 2.0 6 votes vote down vote up
public MockRdfCloudStore() {
    super();
    Instance instance = new MockInstance();
    try {
        Connector connector = instance.getConnector("", "");
        setConf(new AccumuloRdfConfiguration());
        AccumuloRyaDAO cdao = new AccumuloRyaDAO();
        cdao.setConnector(connector);
        setRyaDAO(cdao);
        inferenceEngine = new InferenceEngine();
        inferenceEngine.setRyaDAO(cdao);
        inferenceEngine.setRefreshGraphSchedule(1000); //every sec
        setInferenceEngine(inferenceEngine);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #15
Source File: GeoWaveGeoIndexer.java    From rya with Apache License 2.0 6 votes vote down vote up
public Map<String, Serializable> getParams(final Configuration conf) {
    // get the configuration parameters
    final Instance instance = ConfigUtils.getInstance(conf);
    final String instanceId = instance.getInstanceName();
    final String zookeepers = instance.getZooKeepers();
    final String user = ConfigUtils.getUsername(conf);
    final String password = ConfigUtils.getPassword(conf);
    final String auths = ConfigUtils.getAuthorizations(conf).toString();
    final String tableName = getTableName(conf);
    final String tablePrefix = ConfigUtils.getTablePrefix(conf);

    final Map<String, Serializable> params = new HashMap<>();
    params.put("zookeeper", zookeepers);
    params.put("instance", instanceId);
    params.put("user", user);
    params.put("password", password);
    params.put("namespace", tableName);
    params.put("gwNamespace", tablePrefix + getClass().getSimpleName());

    params.put("Lock Management", LockManagementType.MEMORY.toString());
    params.put("Authorization Management Provider", AuthorizationManagementProviderType.EMPTY.toString());
    params.put("Authorization Data URL", null);
    params.put("Transaction Buffer Size", 10000);
    params.put("Query Index Strategy", QueryIndexStrategyType.HEURISTIC_MATCH.toString());
    return params;
}
 
Example #16
Source File: AccumuloQueryRunner.java    From presto with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the AccumuloConnector singleton, starting the MiniAccumuloCluster on initialization.
 * This singleton instance is required so all test cases access the same MiniAccumuloCluster.
 *
 * @return Accumulo connector
 */
public static Connector getAccumuloConnector()
{
    if (connector != null) {
        return connector;
    }

    try {
        MiniAccumuloCluster accumulo = createMiniAccumuloCluster();
        Instance instance = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers());
        connector = instance.getConnector(MAC_USER, new PasswordToken(MAC_PASSWORD));
        LOG.info("Connection to MAC instance %s at %s established, user %s password %s", accumulo.getInstanceName(), accumulo.getZooKeepers(), MAC_USER, MAC_PASSWORD);
        return connector;
    }
    catch (AccumuloException | AccumuloSecurityException | InterruptedException | IOException e) {
        throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to get connector to Accumulo", e);
    }
}
 
Example #17
Source File: GeoWaveGeoIndexer.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the {@link DataStore} for the {@link GeoWaveGeoIndexer}.
 * @param conf the {@link Configuration}.
 * @return the {@link DataStore}.
 */
public DataStore createDataStore(final Configuration conf) throws IOException, GeoWavePluginException {
    final Map<String, Serializable> params = getParams(conf);
    final Instance instance = ConfigUtils.getInstance(conf);
    final boolean useMock = instance instanceof MockInstance;

    final StoreFactoryFamilySpi storeFactoryFamily;
    if (useMock) {
        storeFactoryFamily = new MemoryStoreFactoryFamily();
    } else {
        storeFactoryFamily = new AccumuloStoreFactoryFamily();
    }

    final GeoWaveGTDataStoreFactory geoWaveGTDataStoreFactory = new GeoWaveGTDataStoreFactory(storeFactoryFamily);
    final DataStore dataStore = geoWaveGTDataStoreFactory.createNewDataStore(params);

    return dataStore;
}
 
Example #18
Source File: EventKeyValueIndexTest.java    From accumulo-recipes with Apache License 2.0 5 votes vote down vote up
@Test
public void testTypes() throws AccumuloSecurityException, AccumuloException, TableExistsException, TableNotFoundException {

    Instance instance = new MockInstance();
    Connector connector = instance.getConnector("root", "".getBytes());
    EventStore eventStore = new AccumuloEventStore(connector);


    KeyValueIndex eventKeyValueIndex = new KeyValueIndex(
        connector, "eventStore_index", DEFAULT_SHARD_BUILDER, DEFAULT_STORE_CONFIG,
        LEXI_TYPES
    );

    Event event = EventBuilder.create("type1", "id", System.currentTimeMillis())
        .attr(new Attribute("key1", "val1"))
        .attr(new Attribute("key2", "val2")).build();

    Event event2 = EventBuilder.create("type2", "id2", System.currentTimeMillis())
        .attr(new Attribute("key1", "val1"))
        .attr(new Attribute("key2", "val2"))
        .attr(new Attribute("key3", true))
        .attr(new Attribute("aKey", 1)).build();


    eventStore.save(Arrays.asList(new Event[] {event, event2}));

    dumpTable(connector, DEFAULT_IDX_TABLE_NAME);

    CloseableIterable<String> types = eventKeyValueIndex.getTypes("", Auths.EMPTY);

    assertEquals(2, Iterables.size(types));

    assertEquals("type1", Iterables.get(types, 0));
    assertEquals("type2", Iterables.get(types, 1));
}
 
Example #19
Source File: DemoDriver.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source File: PeriodicNotificationApplicationFactory.java    From rya with Apache License 2.0 5 votes vote down vote up
private static PeriodicQueryResultStorage getPeriodicQueryResultStorage(final PeriodicNotificationApplicationConfiguration conf)
        throws AccumuloException, AccumuloSecurityException {
    final Instance instance = new ZooKeeperInstance(conf.getAccumuloInstance(), conf.getAccumuloZookeepers());
    final Connector conn = instance.getConnector(conf.getAccumuloUser(), new PasswordToken(conf.getAccumuloPassword()));
    final String ryaInstance = conf.getTablePrefix();
    return new AccumuloPeriodicQueryResultStorage(conn, ryaInstance);
}
 
Example #21
Source File: ConfigUtils.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #22
Source File: FluoITBase.java    From rya with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);

    // Setup and start the Mini Accumulo.
    cluster = clusterInstance.getCluster();

    // Store a connector to the Mini Accumulo.
    instanceName = cluster.getInstanceName();
    zookeepers = cluster.getZooKeepers();

    final Instance instance = new ZooKeeperInstance(instanceName, zookeepers);
    accumuloConn = instance.getConnector(clusterInstance.getUsername(), new PasswordToken(clusterInstance.getPassword()));
}
 
Example #23
Source File: AccumuloIndexSetColumnVisibilityTest.java    From rya with Apache License 2.0 5 votes vote down vote up
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());
    accCon = instance.getConnector("root", new PasswordToken("password"));

    return accumulo;
}
 
Example #24
Source File: AccumuloIndexAgeDisplay.java    From datawave with Apache License 2.0 5 votes vote down vote up
public AccumuloIndexAgeDisplay(Instance instance, String tableName, String columns, String userName, PasswordToken password, Integer[] buckets)
                throws AccumuloException, AccumuloSecurityException {
    this.tableName = tableName;
    setColumns(columns);
    this.userName = userName;
    setBuckets(buckets);
    
    conn = instance.getConnector(userName, password);
}
 
Example #25
Source File: AccumuloModule.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public Connector get()
{
    try {
        Instance inst = new ZooKeeperInstance(instance, zooKeepers);
        Connector connector = inst.getConnector(username, new PasswordToken(password.getBytes(UTF_8)));
        LOG.info("Connection to instance %s at %s established, user %s", instance, zooKeepers, username);
        return connector;
    }
    catch (AccumuloException | AccumuloSecurityException e) {
        throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to get connector to Accumulo", e);
    }
}
 
Example #26
Source File: GeoMesaGeoIndexer.java    From rya with Apache License 2.0 5 votes vote down vote up
private static DataStore createDataStore(final Configuration conf) throws IOException {
    // get the configuration parameters
    final Instance instance = ConfigUtils.getInstance(conf);
    final boolean useMock = instance instanceof MockInstance;
    final String instanceId = instance.getInstanceName();
    final String zookeepers = instance.getZooKeepers();
    final String user = ConfigUtils.getUsername(conf);
    final String password = ConfigUtils.getPassword(conf);
    final String auths = ConfigUtils.getAuthorizations(conf).toString();
    final String tableName = getTableName(conf);
    final int numParitions = OptionalConfigUtils.getGeoNumPartitions(conf);

    final String featureSchemaFormat = "%~#s%" + numParitions + "#r%" + FEATURE_NAME
            + "#cstr%0,3#gh%yyyyMMdd#d::%~#s%3,2#gh::%~#s%#id";
    // build the map of parameters
    final Map<String, Serializable> params = new HashMap<String, Serializable>();
    params.put("instanceId", instanceId);
    params.put("zookeepers", zookeepers);
    params.put("user", user);
    params.put("password", password);
    params.put("auths", auths);
    params.put("tableName", tableName);
    params.put("indexSchemaFormat", featureSchemaFormat);
    params.put("useMock", Boolean.toString(useMock));

    // fetch the data store from the finder
    return DataStoreFinder.getDataStore(params);
}
 
Example #27
Source File: ProspectorUtils.java    From rya with Apache License 2.0 5 votes vote down vote up
public static Instance instance(final Configuration conf) {
    assert conf != null;

    final String instance_str = conf.get(INSTANCE);
    final String zookeepers = conf.get(ZOOKEEPERS);
    final String mock = conf.get(MOCK);
    if (Boolean.parseBoolean(mock)) {
        return new MockInstance(instance_str);
    } else if (zookeepers != null) {
        return new ZooKeeperInstance(instance_str, zookeepers);
    } else {
        throw new IllegalArgumentException("Must specify either mock or zookeepers");
    }
}
 
Example #28
Source File: ProspectorUtils.java    From rya with Apache License 2.0 5 votes vote down vote up
public static Connector connector(Instance instance, final Configuration conf) throws AccumuloException, AccumuloSecurityException {
    final String username = conf.get(USERNAME);
    final String password = conf.get(PASSWORD);
    if (instance == null) {
        instance = instance(conf);
    }
    return instance.getConnector(username, new PasswordToken(password));
}
 
Example #29
Source File: PcjTablesWithMockTest.java    From rya with Apache License 2.0 5 votes vote down vote up
@Before
public void init() throws AccumuloException, AccumuloSecurityException, RepositoryException {
	Instance instance = new MockInstance("instance");
	accumuloConn = instance.getConnector("root", new PasswordToken(""));
	ryaRepo = setupRya(accumuloConn);
	ryaConn = ryaRepo.getConnection();
}
 
Example #30
Source File: FluoITBase.java    From rya with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);

    // Setup and start the Mini Accumulo.
    cluster = clusterInstance.getCluster();

    // Store a connector to the Mini Accumulo.
    instanceName = cluster.getInstanceName();
    zookeepers = cluster.getZooKeepers();

    final Instance instance = new ZooKeeperInstance(instanceName, zookeepers);
    accumuloConn = instance.getConnector(clusterInstance.getUsername(), new PasswordToken(clusterInstance.getPassword()));
}