Search in sources :

Example 41 with AccumuloRdfConfiguration

use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.

the class AccumuloAddUserIT method userAddedCanInsert.

/**
 * Ensure a user that has been added to the Rya instance can interact with it.
 */
@Test
public void userAddedCanInsert() throws Exception {
    final String user = testInstance.createUniqueUser();
    final SecurityOperations secOps = super.getConnector().securityOperations();
    final RyaClient userAClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ADMIN_USER, ADMIN_USER.toCharArray(), getInstanceName(), getZookeepers()), super.getClusterInstance().getCluster().getConnector(ADMIN_USER, ADMIN_USER));
    // Create the user that will not be added to the instance of Rya, but will try to scan it.
    secOps.createLocalUser(user, new PasswordToken(user));
    // Install the instance of Rya.
    userAClient.getInstall().install(getRyaInstanceName(), InstallConfiguration.builder().build());
    // Add the user.
    userAClient.getAddUser().get().addUser(getRyaInstanceName(), user);
    // Try to add a statement to the Rya instance. This should succeed.
    Sail sail = null;
    SailConnection sailConn = null;
    try {
        final AccumuloRdfConfiguration userDConf = makeRyaConfig(getRyaInstanceName(), user, user, getInstanceName(), getZookeepers());
        sail = RyaSailFactory.getInstance(userDConf);
        sailConn = sail.getConnection();
        final ValueFactory vf = sail.getValueFactory();
        sailConn.begin();
        sailConn.addStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"));
        sailConn.close();
    } finally {
        if (sailConn != null) {
            sailConn.close();
        }
        if (sail != null) {
            sail.shutDown();
        }
    }
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) SailConnection(org.openrdf.sail.SailConnection) Sail(org.openrdf.sail.Sail) SecurityOperations(org.apache.accumulo.core.client.admin.SecurityOperations) RyaClient(org.apache.rya.api.client.RyaClient) ValueFactory(org.openrdf.model.ValueFactory) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) Test(org.junit.Test)

Example 42 with AccumuloRdfConfiguration

use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.

the class AccumuloAddUserIT method userNotAddedCanNotInsert.

/**
 * Ensure a user that has not been added to the Rya instance can not interact with it.
 */
@Test
public void userNotAddedCanNotInsert() throws Exception {
    final String user = testInstance.createUniqueUser();
    final SecurityOperations secOps = super.getConnector().securityOperations();
    final RyaClient userAClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ADMIN_USER, ADMIN_USER.toCharArray(), getInstanceName(), getZookeepers()), super.getClusterInstance().getCluster().getConnector(ADMIN_USER, ADMIN_USER));
    // Install the instance of Rya.
    userAClient.getInstall().install(getRyaInstanceName(), InstallConfiguration.builder().build());
    // Create the user that will not be added to the instance of Rya, but will try to scan it.
    secOps.createLocalUser(user, new PasswordToken(user));
    // Try to add a statement the Rya instance with the unauthorized user. This should fail.
    boolean securityExceptionThrown = false;
    Sail sail = null;
    SailConnection sailConn = null;
    try {
        final AccumuloRdfConfiguration userCConf = makeRyaConfig(getRyaInstanceName(), user, user, getInstanceName(), getZookeepers());
        sail = RyaSailFactory.getInstance(userCConf);
        sailConn = sail.getConnection();
        final ValueFactory vf = sail.getValueFactory();
        sailConn.addStatement(vf.createURI("urn:Alice"), vf.createURI("urn:talksTo"), vf.createURI("urn:Bob"));
    } catch (final RuntimeException e) {
        final Throwable cause = e.getCause();
        if (cause instanceof AccumuloSecurityException) {
            securityExceptionThrown = true;
        }
    } finally {
        if (sailConn != null) {
            sailConn.close();
        }
        if (sail != null) {
            sail.shutDown();
        }
    }
    assertTrue(securityExceptionThrown);
}
Also used : SecurityOperations(org.apache.accumulo.core.client.admin.SecurityOperations) RyaClient(org.apache.rya.api.client.RyaClient) ValueFactory(org.openrdf.model.ValueFactory) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) SailConnection(org.openrdf.sail.SailConnection) Sail(org.openrdf.sail.Sail) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) Test(org.junit.Test)

Example 43 with AccumuloRdfConfiguration

use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.

the class StatementPatternStorageTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
    connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
    SecurityOperations secOps = connector.securityOperations();
    secOps.createUser(user, pwd.getBytes(), auths);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
    secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
    conf = new AccumuloRdfConfiguration();
    ryaDAO = new AccumuloRyaDAO();
    ryaDAO.setConnector(connector);
    conf.setTablePrefix(tablePrefix);
    ryaDAO.setConf(conf);
    ryaDAO.init();
}
Also used : AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) SecurityOperations(org.apache.accumulo.core.client.admin.SecurityOperations) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Example 44 with AccumuloRdfConfiguration

use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.

the class SparqlQueryPigEngine method init.

public void init() throws Exception {
    Preconditions.checkNotNull(sparqlToPigTransformVisitor, "Sparql To Pig Transform Visitor must not be null");
    logger.info("Initializing Sparql Query Pig Engine");
    if (hadoopDir != null) {
        // set hadoop dir property
        System.setProperty("HADOOPDIR", hadoopDir);
    }
    if (pigServer == null) {
        pigServer = new PigServer(execType);
    }
    if (inference || stats) {
        final String instance = sparqlToPigTransformVisitor.getInstance();
        final String zoo = sparqlToPigTransformVisitor.getZk();
        final String user = sparqlToPigTransformVisitor.getUser();
        final String pass = sparqlToPigTransformVisitor.getPassword();
        final Connector connector = new ZooKeeperInstance(instance, zoo).getConnector(user, new PasswordToken(pass.getBytes(StandardCharsets.UTF_8)));
        final String tablePrefix = sparqlToPigTransformVisitor.getTablePrefix();
        conf.setTablePrefix(tablePrefix);
        if (inference) {
            logger.info("Using inference");
            inferenceEngine = new InferenceEngine();
            ryaDAO = new AccumuloRyaDAO();
            ryaDAO.setConf(conf);
            ryaDAO.setConnector(connector);
            ryaDAO.init();
            inferenceEngine.setRyaDAO(ryaDAO);
            inferenceEngine.setConf(conf);
            inferenceEngine.setSchedule(false);
            inferenceEngine.init();
        }
        if (stats) {
            logger.info("Using stats");
            rdfEvalStatsDAO = new AccumuloRdfEvalStatsDAO();
            rdfEvalStatsDAO.setConf(conf);
            rdfEvalStatsDAO.setConnector(connector);
            // rdfEvalStatsDAO.setEvalTable(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
            rdfEvalStatsDAO.init();
            rdfCloudTripleStoreEvaluationStatistics = new RdfCloudTripleStoreEvaluationStatistics<AccumuloRdfConfiguration>(conf, rdfEvalStatsDAO);
        }
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) InferenceEngine(org.apache.rya.rdftriplestore.inference.InferenceEngine) PigServer(org.apache.pig.PigServer) AccumuloRdfEvalStatsDAO(org.apache.rya.accumulo.AccumuloRdfEvalStatsDAO) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 45 with AccumuloRdfConfiguration

use of org.apache.rya.accumulo.AccumuloRdfConfiguration in project incubator-rya by apache.

the class QueryJoinSelectOptimizerTest method init.

@Before
public void init() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
    mock = new MockInstance("accumulo");
    PasswordToken pToken = new PasswordToken("pass".getBytes());
    conn = mock.getConnector("user", pToken);
    config = new BatchWriterConfig();
    config.setMaxMemory(1000);
    config.setMaxLatency(1000, TimeUnit.SECONDS);
    config.setMaxWriteThreads(10);
    if (conn.tableOperations().exists("rya_prospects")) {
        conn.tableOperations().delete("rya_prospects");
    }
    if (conn.tableOperations().exists("rya_selectivity")) {
        conn.tableOperations().delete("rya_selectivity");
    }
    arc = new AccumuloRdfConfiguration();
    arc.setTableLayoutStrategy(new TablePrefixLayoutStrategy());
    arc.setMaxRangesForScanner(300);
    res = new ProspectorServiceEvalStatsDAO(conn, arc);
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) TablePrefixLayoutStrategy(org.apache.rya.api.layout.TablePrefixLayoutStrategy) ProspectorServiceEvalStatsDAO(org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAO) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) Before(org.junit.Before)

Aggregations

AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)108 MockInstance (org.apache.accumulo.core.client.mock.MockInstance)26 AccumuloRyaDAO (org.apache.rya.accumulo.AccumuloRyaDAO)25 Test (org.junit.Test)24 RyaURI (org.apache.rya.api.domain.RyaURI)22 Connector (org.apache.accumulo.core.client.Connector)21 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)20 RyaStatement (org.apache.rya.api.domain.RyaStatement)20 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)15 Sail (org.openrdf.sail.Sail)15 RyaType (org.apache.rya.api.domain.RyaType)14 StatementPattern (org.openrdf.query.algebra.StatementPattern)14 AccumuloException (org.apache.accumulo.core.client.AccumuloException)13 Before (org.junit.Before)13 ArrayList (java.util.ArrayList)12 RdfCloudTripleStore (org.apache.rya.rdftriplestore.RdfCloudTripleStore)12 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)11 LiteralImpl (org.openrdf.model.impl.LiteralImpl)10 BindingSet (org.openrdf.query.BindingSet)10 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)10