org.apache.accumulo.core.client.mock.MockInstance Java Examples

The following examples show how to use org.apache.accumulo.core.client.mock.MockInstance. 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: HiveAccumuloTableInputFormat.java    From accumulo-hive-storage-manager with Apache License 2.0 6 votes vote down vote up
private void configure(Job job, JobConf conf, Connector connector, List<String> colQualFamPairs)
        throws AccumuloSecurityException, AccumuloException, SerDeException {
    String instanceId = job.getConfiguration().get(AccumuloSerde.INSTANCE_ID);
    String zookeepers = job.getConfiguration().get(AccumuloSerde.ZOOKEEPERS);
    String user = job.getConfiguration().get(AccumuloSerde.USER_NAME);
    String pass = job.getConfiguration().get(AccumuloSerde.USER_PASS);
    String tableName = job.getConfiguration().get(AccumuloSerde.TABLE_NAME);
    if (instance instanceof MockInstance) {
        setMockInstance(job, instanceId);
    }  else {
        setZooKeeperInstance(job, instanceId, zookeepers);
    }
    setConnectorInfo(job, user, new PasswordToken(pass.getBytes()));
    setInputTableName(job, tableName);
    setScanAuthorizations(job, connector.securityOperations().getUserAuthorizations(user));
    List<IteratorSetting> iterators = predicateHandler.getIterators(conf); //restrict with any filters found from WHERE predicates.
    for(IteratorSetting is : iterators)
        addIterator(job, is);
    Collection<Range> ranges = predicateHandler.getRanges(conf); //restrict with any ranges found from WHERE predicates.
    if(ranges.size() > 0)
        setRanges(job, ranges);
    fetchColumns(job, getPairCollection(colQualFamPairs));
}
 
Example #2
Source File: RdfCloudTripleStoreTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();
    connector = new MockInstance().getConnector("", "");

    RdfCloudTripleStore sail = new RdfCloudTripleStore();
    AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    conf.setTablePrefix("lubm_");
    sail.setConf(conf);
    AccumuloRyaDAO crdfdao = new AccumuloRyaDAO();
    crdfdao.setConnector(connector);
    crdfdao.setConf(conf);
    sail.setRyaDAO(crdfdao);

    repository = new SailRepository(sail);
    repository.initialize();
    connection = repository.getConnection();

    loadData();
}
 
Example #3
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 #4
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 #5
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 #6
Source File: SameAsTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
    super.setUp();
    connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
    SecurityOperations secOps = connector.securityOperations();
    secOps.createUser(user, pwd.getBytes(), auths);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);

    conf = new AccumuloRdfConfiguration();
    ryaDAO = new AccumuloRyaDAO();
    ryaDAO.setConnector(connector);
    conf.setTablePrefix(tablePrefix);
    ryaDAO.setConf(conf);
    ryaDAO.init();
}
 
Example #7
Source File: PropertyChainTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
    super.setUp();
    connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
    SecurityOperations secOps = connector.securityOperations();
    secOps.createUser(user, pwd.getBytes(), auths);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);

    conf = new AccumuloRdfConfiguration();
    ryaDAO = new AccumuloRyaDAO();
    ryaDAO.setConnector(connector);
    conf.setTablePrefix(tablePrefix);
    ryaDAO.setConf(conf);
    ryaDAO.init();
}
 
Example #8
Source File: InferenceEngineTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
    super.setUp();
    dao = new AccumuloRyaDAO();
    connector = new MockInstance().getConnector("", new PasswordToken(""));
    dao.setConnector(connector);
    conf = new AccumuloRdfConfiguration();
    dao.setConf(conf);
    dao.init();
    store = new RdfCloudTripleStore();
    store.setConf(conf);
    store.setRyaDAO(dao);
    inferenceEngine = new InferenceEngine();
    inferenceEngine.setRyaDAO(dao);
    store.setInferenceEngine(inferenceEngine);
    inferenceEngine.refreshGraph();
    store.initialize();
    repository = new SailRepository(store);
    conn = repository.getConnection();
}
 
Example #9
Source File: RdfCloudTripleStoreSelectivityEvaluationStatisticsTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {

    mock = new MockInstance("accumulo");
    PasswordToken pToken = new PasswordToken("pass".getBytes());
    conn = mock.getConnector("user", pToken);

    config = new BatchWriterConfig();
    config.setMaxMemory(1000);
    config.setMaxLatency(1000, TimeUnit.SECONDS);
    config.setMaxWriteThreads(10);

    if (conn.tableOperations().exists("rya_prospects")) {
        conn.tableOperations().delete("rya_prospects");
    }
    if (conn.tableOperations().exists("rya_selectivity")) {
        conn.tableOperations().delete("rya_selectivity");
    }

    arc = new AccumuloRdfConfiguration();
    arc.setTableLayoutStrategy(new TablePrefixLayoutStrategy());
    arc.setMaxRangesForScanner(300);

}
 
Example #10
Source File: QueryJoinSelectOptimizerTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {

  mock = new MockInstance("accumulo");
  PasswordToken pToken = new PasswordToken("pass".getBytes());
  conn = mock.getConnector("user", pToken);

  config = new BatchWriterConfig();
  config.setMaxMemory(1000);
  config.setMaxLatency(1000, TimeUnit.SECONDS);
  config.setMaxWriteThreads(10);

  if (conn.tableOperations().exists("rya_prospects")) {
    conn.tableOperations().delete("rya_prospects");
  }
  if (conn.tableOperations().exists("rya_selectivity")) {
    conn.tableOperations().delete("rya_selectivity");
  }

  arc = new AccumuloRdfConfiguration();
  arc.setTableLayoutStrategy(new TablePrefixLayoutStrategy());
  arc.setMaxRangesForScanner(300);
  res = new ProspectorServiceEvalStatsDAO(conn, arc);

}
 
Example #11
Source File: StatementPatternStorageTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Override
public void setUp() throws Exception {
    super.setUp();
    connector = new MockInstance(instance).getConnector(user, new PasswordToken(pwd.getBytes(StandardCharsets.UTF_8)));
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
    final SecurityOperations secOps = connector.securityOperations();
    secOps.createLocalUser(user, new PasswordToken(pwd.getBytes(StandardCharsets.UTF_8)));
    secOps.changeUserAuthorizations(user, auths);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);

    conf = new AccumuloRdfConfiguration();
    ryaDAO = new AccumuloRyaDAO();
    ryaDAO.setConnector(connector);
    conf.setTablePrefix(tablePrefix);
    ryaDAO.setConf(conf);
    ryaDAO.init();
}
 
Example #12
Source File: TextOutputExample.java    From rya with Apache License 2.0 6 votes vote down vote up
static void setUpRya() throws AccumuloException, AccumuloSecurityException, RyaDAOException {
    MockInstance mock = new MockInstance(INSTANCE_NAME);
    Connector conn = mock.getConnector(USERNAME, new PasswordToken(USERP));
    AccumuloRyaDAO dao = new AccumuloRyaDAO();
    dao.setConnector(conn);
    AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    conf.setTablePrefix(PREFIX);
    dao.setConf(conf);
    dao.init();
    String ns = "http://example.com/";
    dao.add(new RyaStatement(new RyaIRI(ns+"s1"), new RyaIRI(ns+"p1"), new RyaIRI(ns+"o1")));
    dao.add(new RyaStatement(new RyaIRI(ns+"s1"), new RyaIRI(ns+"p2"), new RyaIRI(ns+"o2")));
    dao.add(new RyaStatement(new RyaIRI(ns+"s2"), new RyaIRI(ns+"p1"), new RyaIRI(ns+"o3"),
            new RyaIRI(ns+"g1")));
    dao.add(new RyaStatement(new RyaIRI(ns+"s3"), new RyaIRI(ns+"p3"), new RyaIRI(ns+"o3"),
            new RyaIRI(ns+"g2")));
    dao.destroy();
}
 
Example #13
Source File: RdfFileInputToolTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    connector = new MockInstance(instance).getConnector(user, new PasswordToken(pwd));
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
    SecurityOperations secOps = connector.securityOperations();
    secOps.createLocalUser(user, new PasswordToken(pwd));
    secOps.changeUserAuthorizations(user, auths);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.WRITE);
}
 
Example #14
Source File: AccumuloRdfCountToolTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
    SecurityOperations secOps = connector.securityOperations();
    secOps.createUser(user, pwd.getBytes(), auths);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX, TablePermission.WRITE);

    dao = new AccumuloRyaDAO();
    dao.setConnector(connector);
    conf.setTablePrefix(tablePrefix);
    dao.setConf(conf);
    dao.init();
}
 
Example #15
Source File: RyaOutputFormatTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws Exception {
    MRUtils.setACMock(conf, true);
    MRUtils.setACInstance(conf, INSTANCE_NAME);
    MRUtils.setACUserName(conf, USERNAME);
    MRUtils.setACPwd(conf, PASSWORD);
    MRUtils.setTablePrefix(conf, PREFIX);
    conf.setTablePrefix(PREFIX);
    conf.setAuths(CV);
    conf.set(ConfigUtils.CLOUDBASE_INSTANCE, INSTANCE_NAME);
    conf.set(ConfigUtils.CLOUDBASE_USER, USERNAME);
    conf.set(ConfigUtils.CLOUDBASE_PASSWORD, PASSWORD);
    conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, true);
    conf.setClass(ConfigUtils.TOKENIZER_CLASS, SimpleTokenizer.class, Tokenizer.class);
    ryaContext = RyaTripleContext.getInstance(conf);
    instance = new MockInstance(INSTANCE_NAME);
    connector = instance.getConnector(USERNAME, new PasswordToken(PASSWORD));
    job = Job.getInstance(conf);
    RyaOutputFormat.setMockInstance(job, instance.getInstanceName());
    AccumuloOutputFormat.setConnectorInfo(job, USERNAME, new PasswordToken(PASSWORD));
    AccumuloOutputFormat.setCreateTables(job, true);
    AccumuloOutputFormat.setDefaultTableName(job, PREFIX + "default");
    RyaOutputFormat.setTablePrefix(job, PREFIX);
}
 
Example #16
Source File: GraphXInputFormatTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws Exception {
    instance = new MockInstance(GraphXInputFormatTest.class.getName() + ".mock_instance");
    final Connector connector = instance.getConnector(username, password);
    connector.tableOperations().create(table);

    final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    conf.setTablePrefix("rya_");
    conf.setDisplayQueryPlan(false);
    conf.setBoolean("sc.use_entity", true);

    apiImpl = new AccumuloRyaDAO();
    apiImpl.setConf(conf);
    apiImpl.setConnector(connector);
    apiImpl.init();
}
 
Example #17
Source File: AccumuloDocIndexerTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws Exception {
    final String INSTANCE = "instance";
    Configuration config = new Configuration();
    config.set(ConfigUtils.CLOUDBASE_AUTHS, "U");
    config.set(ConfigUtils.CLOUDBASE_INSTANCE, INSTANCE);
    config.set(ConfigUtils.CLOUDBASE_USER, "root");
    config.set(ConfigUtils.CLOUDBASE_PASSWORD, "");
   
    conf = new AccumuloRdfConfiguration(config);
    conf.set(ConfigUtils.USE_MOCK_INSTANCE, "true");
    conf.setAdditionalIndexers(EntityCentricIndex.class);
    conf.setTablePrefix("EntityCentric_");
    tableName =  EntityCentricIndex.getTableName(conf);

    // Access the accumulo instance.  If you assign a name, it persists statically, but otherwise, can't get it by name.
    accCon = new MockInstance(INSTANCE).getConnector("root", new PasswordToken(""));
    if(accCon.tableOperations().exists(tableName)) {
            throw new Exception("New mock accumulo already has a table!  Should be deleted in AfterTest.");
    } 
    // This should happen in the index initialization, but some tests need it before: 
    accCon.tableOperations().create(tableName);
}
 
Example #18
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 #19
Source File: JoinSelectStatisticsTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
  
    MockInstance mockInstance = new MockInstance(INSTANCE_NAME);
    c = mockInstance.getConnector("root", new PasswordToken(""));
    
    if (c.tableOperations().exists("rya_prospects")) {
        c.tableOperations().delete("rya_prospects");
    } 
    if (c.tableOperations().exists("rya_selectivity")) {
        c.tableOperations().delete("rya_selectivity");
    }
    if (c.tableOperations().exists("rya_spo")) {
        c.tableOperations().delete("rya_spo");
    } 
    
    
    c.tableOperations().create("rya_spo");
    c.tableOperations().create("rya_prospects");
    c.tableOperations().create("rya_selectivity");
    ryaContext = RyaTripleContext.getInstance(new AccumuloRdfConfiguration(getConfig()));
}
 
Example #20
Source File: AccumuloSelectivityEvalDAOTest.java    From rya with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {

    mock = new MockInstance("accumulo");
    PasswordToken pToken = new PasswordToken("pass".getBytes());
    conn = mock.getConnector("user", pToken);

    config = new BatchWriterConfig();
    config.setMaxMemory(1000);
    config.setMaxLatency(1000, TimeUnit.SECONDS);
    config.setMaxWriteThreads(10);

    if (conn.tableOperations().exists("rya_prospects")) {
        conn.tableOperations().delete("rya_prospects");
    }
    if (conn.tableOperations().exists("rya_selectivity")) {
        conn.tableOperations().delete("rya_selectivity");
    }

    arc = new AccumuloRdfConfiguration();
    res = new ProspectorServiceEvalStatsDAO(conn, arc);
    arc.setTableLayoutStrategy(new TablePrefixLayoutStrategy());
    arc.setMaxRangesForScanner(300);

}
 
Example #21
Source File: PcjTables.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Add a collection of results to a PCJ table. The table's cardinality will
 * be updated to include the new results.
 * <p>
 * This method assumes the PCJ table has already been created.
 *
 * @param accumuloConn - A connection to the Accumulo that hosts the PCJ table. (not null)
 * @param pcjTableName - The name of the PCJ table that will receive the results. (not null)
 * @param results - Binding sets that will be written to the PCJ table. (not null)
 * @throws PCJStorageException The provided PCJ table doesn't exist, is missing the
 *   PCJ metadata, or the result could not be written to it.
 */
public void addResults(
        final Connector accumuloConn,
        final String pcjTableName,
        final Collection<VisibilityBindingSet> results) throws PCJStorageException {
    checkNotNull(accumuloConn);
    checkNotNull(pcjTableName);
    checkNotNull(results);

    // Write a result to each of the variable orders that are in the table.
    writeResults(accumuloConn, pcjTableName, results);

    // Increment the cardinality of the query by the number of new results.
    if(accumuloConn.getInstance().getClass().equals(MockInstance.class)) {
    	updateMockCardinality(accumuloConn, pcjTableName, results.size());
    } else {
    	updateCardinality(accumuloConn, pcjTableName, results.size());
    }
}
 
Example #22
Source File: VertexInputFormat.java    From AccumuloGraph with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(InputSplit inSplit, TaskAttemptContext attempt) throws IOException {

  super.initialize(inSplit, attempt);
  rowIterator = new RowIterator(scannerIterator);

  currentK = new Text();

  try {
    conf = new AccumuloGraphConfiguration();
    conf.setZooKeeperHosts(VertexInputFormat.getInstance(attempt).getZooKeepers());
    conf.setInstanceName(VertexInputFormat.getInstance(attempt).getInstanceName());
    conf.setUser(VertexInputFormat.getPrincipal(attempt));
    conf.setTokenWithFallback(VertexInputFormat.getToken(attempt));
    conf.setGraphName(attempt.getConfiguration().get(GRAPH_NAME));
    if (VertexInputFormat.getInstance(attempt) instanceof MockInstance) {
      conf.setInstanceType(InstanceType.Mock);
    }

    parent = AccumuloGraph.open(conf.getConfiguration());
  } catch (AccumuloException e) {
    throw new AccumuloGraphException(e);
  }
}
 
Example #23
Source File: EdgeInputFormat.java    From AccumuloGraph with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(InputSplit inSplit, TaskAttemptContext attempt) throws IOException {

  super.initialize(inSplit, attempt);
  rowIterator = new RowIterator(scannerIterator);

  currentK = new Text();

  try {
    conf = new AccumuloGraphConfiguration();
    conf.setZooKeeperHosts(EdgeInputFormat.getInstance(attempt).getZooKeepers());
    conf.setInstanceName(EdgeInputFormat.getInstance(attempt).getInstanceName());
    conf.setUser(EdgeInputFormat.getPrincipal(attempt));
    conf.setTokenWithFallback(EdgeInputFormat.getToken(attempt));
    conf.setGraphName(attempt.getConfiguration().get(GRAPH_NAME));
    if (EdgeInputFormat.getInstance(attempt) instanceof MockInstance) {
      conf.setInstanceType(InstanceType.Mock);
    }
    parent = AccumuloGraph.open(conf.getConfiguration());
  } catch (AccumuloException e) {
    throw new AccumuloGraphException(e);
  }

}
 
Example #24
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 #25
Source File: AccumuloRangeQueryTest.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Before
public void ingestGeometries() throws AccumuloException, AccumuloSecurityException, IOException {
  final MockInstance mockInstance = new MockInstance();
  final Connector mockConnector =
      mockInstance.getConnector("root", new PasswordToken(new byte[0]));

  final AccumuloOptions options = new AccumuloOptions();
  mockDataStore = new AccumuloDataStore(new AccumuloOperations(mockConnector, options), options);

  index = new SpatialDimensionalityTypeProvider().createIndex(new SpatialOptions());
  adapter = new TestGeometryAdapter();
  mockDataStore.addType(adapter, index);
  try (Writer writer = mockDataStore.createWriter(adapter.getTypeName())) {
    writer.write(testdata);
  }
}
 
Example #26
Source File: AccumuloDataStoreStatsTest.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws AccumuloException, AccumuloSecurityException {
  final MockInstance mockInstance = new MockInstance();
  Connector mockConnector = null;
  try {
    mockConnector = mockInstance.getConnector("root", new PasswordToken(new byte[0]));
  } catch (AccumuloException | AccumuloSecurityException e) {
    LOGGER.error("Failed to create mock accumulo connection", e);
  }
  final AccumuloOptions options = new AccumuloOptions();

  accumuloOperations = new AccumuloOperations(mockConnector, options);

  statsStore = new DataStatisticsStoreImpl(accumuloOperations, options);

  internalAdapterStore = new InternalAdapterStoreImpl(accumuloOperations);

  mockDataStore = new AccumuloDataStore(accumuloOperations, options);
}
 
Example #27
Source File: AccumuloOptionsTest.java    From geowave with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
  final MockInstance mockInstance = new MockInstance();
  Connector mockConnector = null;
  try {
    mockConnector = mockInstance.getConnector("root", new PasswordToken(new byte[0]));
  } catch (AccumuloException | AccumuloSecurityException e) {
    LOGGER.error("Failed to create mock accumulo connection", e);
  }
  final AccumuloOptions options = new AccumuloOptions();
  accumuloOperations = new AccumuloOperations(mockConnector, accumuloOptions);

  indexStore = new IndexStoreImpl(accumuloOperations, accumuloOptions);

  adapterStore = new AdapterStoreImpl(accumuloOperations, accumuloOptions);

  internalAdapterStore = new InternalAdapterStoreImpl(accumuloOperations);

  mockDataStore = new AccumuloDataStore(accumuloOperations, options);
}
 
Example #28
Source File: AccumuloAdapterTest.java    From cognition with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetAccumuloConfiguration() throws AccumuloSecurityException, IOException {
  // Create Criteria
  Criteria criteria = new Criteria();
  criteria.setDates(Instant.parse("2015-02-28T00:00:00.00Z"), Instant.parse("2015-02-28T23:59:59.99Z"));

  SchemaAdapter schema = new SchemaAdapter();
  schema.loadJson("moreover-schema.json");
  criteria.setSchema(schema);

  // Create CognitionConfiguration
  AccumuloConfiguration accumuloConfig = new AccumuloConfiguration(new MockInstance("test"), "root", "", true);
  CognitionConfiguration cognitionConfig = new CognitionConfiguration(accumuloConfig);

  // Now, we can get the AccumuloConfiguration
  AccumuloConfiguration newAccumoloConfig = AccumuloAdapter.getAccumuloConfiguration(criteria, cognitionConfig);

  assertNotNull(newAccumoloConfig);
  assertNotNull(newAccumoloConfig.getConfiguration());
  assertNotNull(newAccumoloConfig.getJob());
  assertEquals("moreover",criteria.getAccumuloTable());
}
 
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: EventKeyValueIndexTest.java    From accumulo-recipes with Apache License 2.0 5 votes vote down vote up
@Test
public void test() 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("", "id", System.currentTimeMillis())
        .attr(new Attribute("key1", "val1"))
        .attr(new Attribute("key2", "val2")).build();

    Event event2 = EventBuilder.create("", "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);

    assertEquals(4, Iterables.size(eventKeyValueIndex.uniqueKeys("", "", Auths.EMPTY)));

    assertEquals("aKey", Iterables.<Pair<String,String>>get(eventKeyValueIndex.uniqueKeys("", "", Auths.EMPTY), 0).getOne());
    assertEquals("key1", Iterables.<Pair<String,String>>get(eventKeyValueIndex.uniqueKeys("", "", Auths.EMPTY), 1).getOne());
    assertEquals("key2", Iterables.<Pair<String,String>>get(eventKeyValueIndex.uniqueKeys("", "", Auths.EMPTY), 2).getOne());
    assertEquals("key3", Iterables.<Pair<String,String>>get(eventKeyValueIndex.uniqueKeys("", "", Auths.EMPTY), 3).getOne());
}