use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class StatementPatternEvalTest method getConf.
private static AccumuloRdfConfiguration getConf() {
final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
conf.set("sc.cloudbase.username", "root");
conf.set("sc.cloudbase.password", "");
conf.set("sc.cloudbase.instancename", "instance");
conf.set("sc.cloudbase.authorizations", "");
return conf;
}
use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class InferenceIT 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();
conf.setInfer(true);
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();
solutions = new LinkedList<>();
resultHandler = new TupleQueryResultHandler() {
@Override
public void endQueryResult() throws TupleQueryResultHandlerException {
}
@Override
public void handleBoolean(final boolean value) throws QueryResultHandlerException {
}
@Override
public void handleLinks(final List<String> linkUrls) throws QueryResultHandlerException {
}
@Override
public void handleSolution(final BindingSet bindingSet) throws TupleQueryResultHandlerException {
if (bindingSet != null && bindingSet.iterator().hasNext()) {
solutions.add(bindingSet);
}
}
@Override
public void startQueryResult(final List<String> bindingNames) throws TupleQueryResultHandlerException {
solutions.clear();
}
};
}
use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class RdfFileInputToolTest method testInputContext.
@Test
public void testInputContext() throws Exception {
RdfFileInputTool.main(new String[] { "-Dac.mock=true", "-Dac.instance=" + instance, "-Dac.username=" + user, "-Dac.pwd=" + pwd, "-Dac.auth=" + auths.toString(), "-Dac.cv=" + auths.toString(), "-Drdf.tablePrefix=" + tablePrefix, "-Drdf.format=" + RDFFormat.TRIG.getName(), "src/test/resources/namedgraphs.trig" });
RyaStatement rs = new RyaStatement(new RyaURI("http://www.example.org/exampleDocument#Monica"), new RyaURI("http://www.example.org/vocabulary#name"), new RyaType("Monica Murphy"), new RyaURI("http://www.example.org/exampleDocument#G1"));
rs.setColumnVisibility(auths.toString().getBytes());
AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
conf.setTablePrefix(tablePrefix);
conf.setAuths(auths.toString());
TestUtils.verify(connector, conf, rs);
}
use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class GeoRyaSailFactory method getRyaSail.
private static Sail getRyaSail(final Configuration config) throws InferenceEngineException, RyaDAOException, AccumuloException, AccumuloSecurityException, SailException {
final RdfCloudTripleStore store = new RdfCloudTripleStore();
final RyaDAO<?> dao;
final RdfCloudTripleStoreConfiguration rdfConfig;
final String user;
final String pswd;
// XXX Should(?) be MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX inside the if below. RYA-135
final String ryaInstance = config.get(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX);
Objects.requireNonNull(ryaInstance, "RyaInstance or table prefix is missing from configuration." + RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX);
if (ConfigUtils.getUseMongo(config)) {
// Get a reference to a Mongo DB configuration object.
final MongoDBRdfConfiguration mongoConfig = (config instanceof MongoDBRdfConfiguration) ? (MongoDBRdfConfiguration) config : new MongoDBRdfConfiguration(config);
// Create the MongoClient that will be used by the Sail object's components.
final MongoClient client = createMongoClient(mongoConfig);
// Add the Indexer and Optimizer names to the configuration object that are configured to be used.
OptionalConfigUtils.setIndexers(mongoConfig);
// Populate the configuration using previously stored Rya Details if this instance uses them.
try {
final MongoRyaInstanceDetailsRepository ryaDetailsRepo = new MongoRyaInstanceDetailsRepository(client, mongoConfig.getRyaInstanceName());
RyaDetailsToConfiguration.addRyaDetailsToConfiguration(ryaDetailsRepo.getRyaInstanceDetails(), mongoConfig);
} catch (final RyaDetailsRepositoryException e) {
LOG.info("Instance does not have a rya details collection, skipping.");
}
// Set the configuration to the stateful configuration that is used to pass the constructed objects around.
final StatefulMongoDBRdfConfiguration statefulConfig = new StatefulMongoDBRdfConfiguration(mongoConfig, client);
final List<MongoSecondaryIndex> indexers = statefulConfig.getInstances(AccumuloRdfConfiguration.CONF_ADDITIONAL_INDEXERS, MongoSecondaryIndex.class);
statefulConfig.setIndexers(indexers);
rdfConfig = statefulConfig;
// Create the DAO that is able to interact with MongoDB.
final MongoDBRyaDAO mongoDao = new MongoDBRyaDAO();
mongoDao.setConf(statefulConfig);
mongoDao.init();
dao = mongoDao;
} else {
rdfConfig = new AccumuloRdfConfiguration(config);
user = rdfConfig.get(ConfigUtils.CLOUDBASE_USER);
pswd = rdfConfig.get(ConfigUtils.CLOUDBASE_PASSWORD);
Objects.requireNonNull(user, "Accumulo user name is missing from configuration." + ConfigUtils.CLOUDBASE_USER);
Objects.requireNonNull(pswd, "Accumulo user password is missing from configuration." + ConfigUtils.CLOUDBASE_PASSWORD);
rdfConfig.setTableLayoutStrategy(new TablePrefixLayoutStrategy(ryaInstance));
RyaSailFactory.updateAccumuloConfig((AccumuloRdfConfiguration) rdfConfig, user, pswd, ryaInstance);
dao = getAccumuloDAO((AccumuloRdfConfiguration) rdfConfig);
}
store.setRyaDAO(dao);
rdfConfig.setTablePrefix(ryaInstance);
if (rdfConfig.isInfer()) {
final InferenceEngine inferenceEngine = new InferenceEngine();
inferenceEngine.setConf(rdfConfig);
inferenceEngine.setRyaDAO(dao);
inferenceEngine.init();
store.setInferenceEngine(inferenceEngine);
}
store.initialize();
return store;
}
use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.
the class PcjVisibilityIT method visibilitySimplified.
@Test
public void visibilitySimplified() throws Exception {
// Create a PCJ index within Rya.
final String sparql = "SELECT ?customer ?worker ?city " + "{ " + "?customer <" + TALKS_TO + "> ?worker. " + "?worker <" + LIVES_IN + "> ?city. " + "?worker <" + WORKS_AT + "> <" + BURGER_JOINT + ">. " + "}";
final Connector accumuloConn = super.getAccumuloConnector();
final String instanceName = super.getMiniAccumuloCluster().getInstanceName();
final String zookeepers = super.getMiniAccumuloCluster().getZooKeepers();
final RyaClient ryaClient = AccumuloRyaClientFactory.build(createConnectionDetails(), accumuloConn);
final String pcjId = ryaClient.getCreatePCJ().createPCJ(getRyaInstanceName(), sparql);
// Grant the root user the "u" authorization.
super.getAccumuloConnector().securityOperations().changeUserAuthorizations(getUsername(), new Authorizations("u"));
// Setup a connection to the Rya instance that uses the "u" authorizations. This ensures
// any statements that are inserted will have the "u" authorization on them and that the
// PCJ updating application will have to maintain visibilities.
final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration();
ryaConf.setTablePrefix(getRyaInstanceName());
// Accumulo connection information.
ryaConf.setAccumuloUser(getUsername());
ryaConf.setAccumuloPassword(getPassword());
ryaConf.setAccumuloInstance(super.getAccumuloConnector().getInstance().getInstanceName());
ryaConf.setAccumuloZookeepers(super.getAccumuloConnector().getInstance().getZooKeepers());
ryaConf.set(ConfigUtils.CLOUDBASE_AUTHS, "u");
ryaConf.set(RdfCloudTripleStoreConfiguration.CONF_CV, "u");
// PCJ configuration information.
ryaConf.set(ConfigUtils.USE_PCJ, "true");
ryaConf.set(ConfigUtils.USE_PCJ_UPDATER_INDEX, "true");
ryaConf.set(ConfigUtils.FLUO_APP_NAME, super.getFluoConfiguration().getApplicationName());
ryaConf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinStorageType.ACCUMULO.toString());
ryaConf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinUpdaterType.FLUO.toString());
Sail sail = null;
RyaSailRepository ryaRepo = null;
RepositoryConnection ryaConn = null;
try {
sail = RyaSailFactory.getInstance(ryaConf);
ryaRepo = new RyaSailRepository(sail);
ryaConn = ryaRepo.getConnection();
// Load a few Statements into Rya.
ryaConn.add(VF.createStatement(ALICE, TALKS_TO, BOB));
ryaConn.add(VF.createStatement(BOB, LIVES_IN, HAPPYVILLE));
ryaConn.add(VF.createStatement(BOB, WORKS_AT, BURGER_JOINT));
// Wait for Fluo to finish processing.
super.getMiniFluo().waitForObservers();
// Fetch the exported result and show that its column visibility has been simplified.
final String pcjTableName = new PcjTableNameFactory().makeTableName(getRyaInstanceName(), pcjId);
final Scanner scan = accumuloConn.createScanner(pcjTableName, new Authorizations("u"));
scan.fetchColumnFamily(new Text("customer;worker;city"));
final Entry<Key, Value> result = scan.iterator().next();
final Key key = result.getKey();
assertEquals(new Text("u"), key.getColumnVisibility());
} finally {
if (ryaConn != null) {
try {
ryaConn.close();
} finally {
}
}
if (ryaRepo != null) {
try {
ryaRepo.shutDown();
} finally {
}
}
if (sail != null) {
try {
sail.shutDown();
} finally {
}
}
}
}
Aggregations