Search in sources :

Example 36 with AccumuloRyaDAO

use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.

the class RulesetCopyIT method runRulesetCopyTest.

private AccumuloRyaDAO runRulesetCopyTest(final RyaStatement[] solutionStatements, final RyaStatement[] copyStatements, final RyaStatement[] irrelevantStatements, final String query, final int numSolutions, final boolean infer) throws Exception {
    log.info("Adding data to parent...");
    parentDao.add(Arrays.asList(solutionStatements).iterator());
    parentDao.add(Arrays.asList(copyStatements).iterator());
    parentDao.add(Arrays.asList(irrelevantStatements).iterator());
    log.info("Copying from parent tables:");
    for (final String table : accumuloDualInstanceDriver.getParentTableList()) {
        AccumuloRyaUtils.printTablePretty(table, parentConfig, false);
    }
    parentConfig.set(RdfCloudTripleStoreConfiguration.CONF_INFER, Boolean.toString(infer));
    childConfig.set(RdfCloudTripleStoreConfiguration.CONF_INFER, Boolean.toString(infer));
    rulesetTool = new CopyTool();
    rulesetTool.setupAndRun(new String[] { makeArgument(MRUtils.AC_MOCK_PROP, Boolean.toString(IS_MOCK)), makeArgument(MRUtils.AC_INSTANCE_PROP, PARENT_INSTANCE), makeArgument(MRUtils.AC_USERNAME_PROP, accumuloDualInstanceDriver.getParentUser()), makeArgument(MRUtils.AC_PWD_PROP, PARENT_PASSWORD), makeArgument(MRUtils.TABLE_PREFIX_PROPERTY, PARENT_TABLE_PREFIX), makeArgument(MRUtils.AC_AUTH_PROP, accumuloDualInstanceDriver.getParentAuth()), makeArgument(MRUtils.AC_ZK_PROP, accumuloDualInstanceDriver.getParentZooKeepers()), makeArgument(CopyTool.PARENT_TOMCAT_URL_PROP, PARENT_TOMCAT_URL), makeArgument(MRUtils.AC_MOCK_PROP + CHILD_SUFFIX, Boolean.toString(IS_MOCK)), makeArgument(MRUtils.AC_INSTANCE_PROP + CHILD_SUFFIX, CHILD_INSTANCE), makeArgument(MRUtils.AC_USERNAME_PROP + CHILD_SUFFIX, accumuloDualInstanceDriver.getChildUser()), makeArgument(MRUtils.AC_PWD_PROP + CHILD_SUFFIX, CHILD_PASSWORD), makeArgument(MRUtils.TABLE_PREFIX_PROPERTY + CHILD_SUFFIX, CHILD_TABLE_PREFIX), makeArgument(MRUtils.AC_AUTH_PROP + CHILD_SUFFIX, accumuloDualInstanceDriver.getChildAuth() != null ? accumuloDualInstanceDriver.getChildAuth() : null), makeArgument(MRUtils.AC_ZK_PROP + CHILD_SUFFIX, accumuloDualInstanceDriver.getChildZooKeepers() != null ? accumuloDualInstanceDriver.getChildZooKeepers() : "localhost"), makeArgument(CopyTool.CHILD_TOMCAT_URL_PROP, CHILD_TOMCAT_URL), makeArgument(CopyTool.CREATE_CHILD_INSTANCE_TYPE_PROP, (IS_MOCK ? InstanceType.MOCK : InstanceType.MINI).toString()), makeArgument(CopyTool.QUERY_STRING_PROP, query), makeArgument(CopyTool.USE_COPY_QUERY_SPARQL, "true"), makeArgument(RdfCloudTripleStoreConfiguration.CONF_INFER, Boolean.toString(infer)), makeArgument("hadoop.tmp.dir", getUnitTestScratchDirectory(RulesetCopyIT.class.getSimpleName()).getAbsolutePath()) });
    final Configuration toolConfig = rulesetTool.getConf();
    final String zooKeepers = toolConfig.get(MRUtils.AC_ZK_PROP + CHILD_SUFFIX);
    MergeTool.setDuplicateKeysForProperty(childConfig, MRUtils.AC_ZK_PROP, zooKeepers);
    log.info("Finished running tool.");
    // Child instance has now been created
    final Connector childConnector = ConfigUtils.getConnector(childConfig);
    accumuloDualInstanceDriver.getChildAccumuloInstanceDriver().setConnector(childConnector);
    accumuloDualInstanceDriver.getChildAccumuloInstanceDriver().setUpTables();
    accumuloDualInstanceDriver.getChildAccumuloInstanceDriver().setUpDao();
    final AccumuloRyaDAO childDao = accumuloDualInstanceDriver.getChildDao();
    log.info("Resulting child tables:");
    for (final String table : accumuloDualInstanceDriver.getChildTableList()) {
        AccumuloRyaUtils.printTablePretty(table, childConfig, false);
    }
    for (final RyaStatement solution : solutionStatements) {
        final Statement stmt = RyaToRdfConversions.convertStatement(solution);
        TestUtils.assertStatementInInstance("Child missing solution statement " + stmt, 1, solution, childDao, childConfig);
    }
    for (final RyaStatement copied : copyStatements) {
        final Statement stmt = RyaToRdfConversions.convertStatement(copied);
        TestUtils.assertStatementInInstance("Child missing relevant statement " + stmt, 1, copied, childDao, childConfig);
    }
    for (final RyaStatement irrelevant : irrelevantStatements) {
        final Statement stmt = RyaToRdfConversions.convertStatement(irrelevant);
        TestUtils.assertStatementInInstance("Should not have copied irrelevant statement " + stmt, 0, irrelevant, childDao, childConfig);
    }
    final Set<BindingSet> parentSolutions = runQuery(query, parentConfig);
    if (parentSolutions.isEmpty()) {
        log.info("No solutions to query in parent");
    } else {
        for (final BindingSet bs : parentSolutions) {
            log.info("Parent yields query solution: " + bs);
        }
    }
    final Set<BindingSet> childSolutions = runQuery(query, childConfig);
    if (childSolutions.isEmpty()) {
        log.info("No solutions to query in child");
    } else {
        for (final BindingSet bs : childSolutions) {
            log.info("Child yields query solution: " + bs);
        }
    }
    Assert.assertEquals("Query results should be the same:", parentSolutions, childSolutions);
    Assert.assertEquals("Incorrect number of solutions:", numSolutions, childSolutions.size());
    return childDao;
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) BindingSet(org.openrdf.query.BindingSet) Configuration(org.apache.hadoop.conf.Configuration) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) RdfCloudTripleStoreConfiguration(org.apache.rya.api.RdfCloudTripleStoreConfiguration) RyaStatement(org.apache.rya.api.domain.RyaStatement) Statement(org.openrdf.model.Statement) RyaStatement(org.apache.rya.api.domain.RyaStatement)

Example 37 with AccumuloRyaDAO

use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.

the class PcjTablesWithMockTest method setupRya.

private static RyaSailRepository setupRya(Connector accumuloConn) throws AccumuloException, AccumuloSecurityException, RepositoryException {
    // Setup the Rya Repository that will be used to create Repository
    // Connections.
    final RdfCloudTripleStore ryaStore = new RdfCloudTripleStore();
    final AccumuloRyaDAO crdfdao = new AccumuloRyaDAO();
    crdfdao.setConnector(accumuloConn);
    // Setup Rya configuration values.
    final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    conf.setTablePrefix("demo_");
    conf.setDisplayQueryPlan(false);
    conf.setBoolean(USE_MOCK_INSTANCE, true);
    conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, RYA_TABLE_PREFIX);
    conf.set(CLOUDBASE_USER, "root");
    conf.set(CLOUDBASE_PASSWORD, "");
    conf.set(CLOUDBASE_INSTANCE, "instance");
    crdfdao.setConf(conf);
    ryaStore.setRyaDAO(crdfdao);
    final RyaSailRepository ryaRepo = new RyaSailRepository(ryaStore);
    ryaRepo.initialize();
    return ryaRepo;
}
Also used : RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Example 38 with AccumuloRyaDAO

use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.

the class TestVertexFormat method testRyaInput.

/*
    Write a simple parent-child directed graph to Cloudbase.
    Run a job which reads the values
    into subclasses that extend CloudbaseVertex I/O formats.
    Check the output after the job.
    */
@Test
public void testRyaInput() throws Exception {
    AccumuloRdfConfiguration conf = getConf();
    AccumuloRyaDAO ryaDAO = RyaSailFactory.getAccumuloDAO(conf);
    ryaDAO.add(new RyaStatement(new RyaURI("urn:test#1234"), new RyaURI("urn:test#pred1"), new RyaURI("urn:test#obj1")));
    ryaDAO.add(new RyaStatement(new RyaURI("urn:test#1234"), new RyaURI("urn:test#pred2"), new RyaURI("urn:test#obj2")));
    ryaDAO.add(new RyaStatement(new RyaURI("urn:test#1234"), new RyaURI("urn:test#pred3"), new RyaURI("urn:test#obj3")));
    ryaDAO.add(new RyaStatement(new RyaURI("urn:test#1234"), new RyaURI("urn:test#pred4"), new RyaURI("urn:test#obj4")));
    ryaDAO.flush();
    GiraphJob job = new GiraphJob(conf, getCallingMethodName());
    setupConfiguration(job);
    GiraphConfiguration giraphConf = job.getConfiguration();
    giraphConf.setComputationClass(EdgeNotification.class);
    giraphConf.setVertexInputFormatClass(RyaVertexInputFormat.class);
    giraphConf.setVertexOutputFormatClass(TestTextOutputFormat.class);
    if (log.isInfoEnabled())
        log.info("Running edge notification job using Rya Vertex input");
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RyaURI(org.apache.rya.api.domain.RyaURI) GiraphConfiguration(org.apache.giraph.conf.GiraphConfiguration) RyaStatement(org.apache.rya.api.domain.RyaStatement) GiraphJob(org.apache.giraph.job.GiraphJob) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) Test(org.junit.Test)

Example 39 with AccumuloRyaDAO

use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.

the class RyaSailFactory method getAccumuloDAO.

/**
 * Creates AccumuloRyaDAO without updating the AccumuloRdfConfiguration.  This method does not force
 * the user's configuration to be consistent with the Rya Instance configuration.  As a result, new index
 * tables might be created when using this method.  This method does not require the {@link AccumuloRyaInstanceDetailsRepository}
 * to exist.  This is for internal use, backwards compatibility and testing purposes only.  It is recommended that
 * {@link RyaSailFactory#getAccumuloDAOWithUpdatedConfig(AccumuloRdfConfiguration)} be used for new installations of Rya.
 *
 * @param config - user configuration
 * @return - AccumuloRyaDAO with Indexers configured according to user's specification
 * @throws AccumuloException
 * @throws AccumuloSecurityException
 * @throws RyaDAOException
 */
public static AccumuloRyaDAO getAccumuloDAO(final AccumuloRdfConfiguration config) throws AccumuloException, AccumuloSecurityException, RyaDAOException {
    final Connector connector = ConfigUtils.getConnector(config);
    final AccumuloRyaDAO dao = new AccumuloRyaDAO();
    dao.setConnector(connector);
    ConfigUtils.setIndexers(config);
    dao.setConf(config);
    dao.init();
    return dao;
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO)

Example 40 with AccumuloRyaDAO

use of org.apache.rya.accumulo.AccumuloRyaDAO in project incubator-rya by apache.

the class InferenceEngineTest method setUp.

@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();
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) SailRepository(org.openrdf.repository.sail.SailRepository) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Aggregations

AccumuloRyaDAO (org.apache.rya.accumulo.AccumuloRyaDAO)45 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)26 MockInstance (org.apache.accumulo.core.client.mock.MockInstance)21 Connector (org.apache.accumulo.core.client.Connector)18 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)10 RyaStatement (org.apache.rya.api.domain.RyaStatement)10 RdfCloudTripleStore (org.apache.rya.rdftriplestore.RdfCloudTripleStore)10 Before (org.junit.Before)9 RyaURI (org.apache.rya.api.domain.RyaURI)7 Test (org.junit.Test)7 Instance (org.apache.accumulo.core.client.Instance)6 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)6 RyaSailRepository (org.apache.rya.rdftriplestore.RyaSailRepository)5 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)4 SecurityOperations (org.apache.accumulo.core.client.admin.SecurityOperations)4 Configuration (org.apache.hadoop.conf.Configuration)4 RyaType (org.apache.rya.api.domain.RyaType)4 ArrayList (java.util.ArrayList)3 Path (org.apache.hadoop.fs.Path)3 SailRepository (org.openrdf.repository.sail.SailRepository)3