use of org.apache.rya.api.persist.query.RyaQueryEngine in project incubator-rya by apache.
the class RyaQueryEngineFactory method getQueryEngine.
@SuppressWarnings("unchecked")
public static <C extends RdfCloudTripleStoreConfiguration> RyaQueryEngine<C> getQueryEngine(RdfCloudTripleStoreConfiguration conf) {
if (conf instanceof AccumuloRdfConfiguration) {
AccumuloRdfConfiguration aConf = (AccumuloRdfConfiguration) conf;
Instance instance;
String instanceName = aConf.get("sc.cloudbase.instancename");
String user = aConf.get("sc.cloudbase.username");
String password = aConf.get("sc.cloudbase.password");
if (aConf.getBoolean(".useMockInstance", false)) {
instance = new MockInstance(instanceName);
} else {
String zookeepers = aConf.get("sc.cloudbase.zookeepers");
instance = new ZooKeeperInstance(instanceName, zookeepers);
}
Connector conn;
try {
conn = instance.getConnector(user, new PasswordToken(password));
} catch (AccumuloException | AccumuloSecurityException e) {
throw new RuntimeException(e);
}
return (RyaQueryEngine<C>) new AccumuloRyaQueryEngine(conn, aConf);
} else if (conf instanceof StatefulMongoDBRdfConfiguration && ConfigUtils.getUseMongo(conf)) {
StatefulMongoDBRdfConfiguration mongoConf = (StatefulMongoDBRdfConfiguration) conf;
MongoDBQueryEngine mongoQueryEngine = new MongoDBQueryEngine();
mongoQueryEngine.setConf(mongoConf);
return (RyaQueryEngine<C>) mongoQueryEngine;
} else {
throw new IllegalArgumentException("Invalid configuration type.");
}
}
Aggregations