Search in sources :

Example 1 with RyaQueryEngine

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.");
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) StatefulMongoDBRdfConfiguration(org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) AccumuloRyaQueryEngine(org.apache.rya.accumulo.query.AccumuloRyaQueryEngine) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) AccumuloRyaQueryEngine(org.apache.rya.accumulo.query.AccumuloRyaQueryEngine) RyaQueryEngine(org.apache.rya.api.persist.query.RyaQueryEngine) MongoDBQueryEngine(org.apache.rya.mongodb.MongoDBQueryEngine)

Aggregations

AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 Connector (org.apache.accumulo.core.client.Connector)1 Instance (org.apache.accumulo.core.client.Instance)1 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)1 MockInstance (org.apache.accumulo.core.client.mock.MockInstance)1 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)1 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)1 AccumuloRyaQueryEngine (org.apache.rya.accumulo.query.AccumuloRyaQueryEngine)1 RyaQueryEngine (org.apache.rya.api.persist.query.RyaQueryEngine)1 MongoDBQueryEngine (org.apache.rya.mongodb.MongoDBQueryEngine)1 StatefulMongoDBRdfConfiguration (org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration)1