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;
}
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;
}
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");
}
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;
}
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();
}
Aggregations