Search in sources :

Example 1 with SailConfigException

use of org.openrdf.sail.config.SailConfigException in project incubator-rya by apache.

the class RyaAccumuloSailFactory method getSail.

@Override
public Sail getSail(final SailImplConfig config) throws SailConfigException {
    try {
        final RdfCloudTripleStore store = new RdfCloudTripleStore();
        final RyaAccumuloSailConfig cbconfig = (RyaAccumuloSailConfig) config;
        final String instanceName = cbconfig.getInstance();
        final String zooKeepers = cbconfig.getZookeepers();
        Instance i;
        if (cbconfig.isMock()) {
            i = new MockInstance(instanceName);
        } else {
            i = new ZooKeeperInstance(instanceName, zooKeepers);
        }
        final String user = cbconfig.getUser();
        final String pass = cbconfig.getPassword();
        final Connector connector = i.getConnector(user, new PasswordToken(pass));
        final AccumuloRyaDAO crdfdao = new AccumuloRyaDAO();
        crdfdao.setConnector(connector);
        final AccumuloRdfConfiguration conf = cbconfig.toRdfConfiguation();
        ConfigUtils.setIndexers(conf);
        conf.setDisplayQueryPlan(true);
        crdfdao.setConf(conf);
        crdfdao.init();
        store.setRyaDAO(crdfdao);
        return store;
    } catch (RyaDAOException | AccumuloException | AccumuloSecurityException e) {
        throw new SailConfigException(e);
    }
}
Also used : RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) AccumuloException(org.apache.accumulo.core.client.AccumuloException) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) 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) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) SailConfigException(org.openrdf.sail.config.SailConfigException)

Example 2 with SailConfigException

use of org.openrdf.sail.config.SailConfigException in project incubator-rya by apache.

the class RyaAccumuloSailConfig method parse.

@Override
public void parse(final Graph graph, final Resource implNode) throws SailConfigException {
    super.parse(graph, implNode);
    System.out.println("parsing");
    try {
        final Literal userLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, USER);
        if (userLit != null) {
            setUser(userLit.getLabel());
        }
        final Literal pwdLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, PASSWORD);
        if (pwdLit != null) {
            setPassword(pwdLit.getLabel());
        }
        final Literal instLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, INSTANCE);
        if (instLit != null) {
            setInstance(instLit.getLabel());
        }
        final Literal zooLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, ZOOKEEPERS);
        if (zooLit != null) {
            setZookeepers(zooLit.getLabel());
        }
        final Literal mockLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, IS_MOCK);
        if (mockLit != null) {
            setMock(Boolean.parseBoolean(mockLit.getLabel()));
        }
    } catch (final GraphUtilException e) {
        throw new SailConfigException(e.getMessage(), e);
    }
}
Also used : Literal(org.openrdf.model.Literal) GraphUtilException(org.openrdf.model.util.GraphUtilException) SailConfigException(org.openrdf.sail.config.SailConfigException)

Aggregations

SailConfigException (org.openrdf.sail.config.SailConfigException)2 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 AccumuloRyaDAO (org.apache.rya.accumulo.AccumuloRyaDAO)1 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)1 RdfCloudTripleStore (org.apache.rya.rdftriplestore.RdfCloudTripleStore)1 Literal (org.openrdf.model.Literal)1 GraphUtilException (org.openrdf.model.util.GraphUtilException)1