Search in sources :

Example 41 with PasswordToken

use of org.apache.accumulo.core.client.security.tokens.PasswordToken in project incubator-rya by apache.

the class AccumuloSelectivityEvalDAOTest 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();
    res = new ProspectorServiceEvalStatsDAO(conn, arc);
    arc.setTableLayoutStrategy(new TablePrefixLayoutStrategy());
    arc.setMaxRangesForScanner(300);
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) ProspectorServiceEvalStatsDAO(org.apache.rya.prospector.service.ProspectorServiceEvalStatsDAO) TablePrefixLayoutStrategy(org.apache.rya.api.layout.TablePrefixLayoutStrategy) BatchWriterConfig(org.apache.accumulo.core.client.BatchWriterConfig) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) Before(org.junit.Before)

Example 42 with PasswordToken

use of org.apache.accumulo.core.client.security.tokens.PasswordToken in project incubator-rya by apache.

the class JoinSelectStatsUtil method initSumMRJob.

public static void initSumMRJob(Job job, String inputPath, String outtable, String auths) throws AccumuloSecurityException, IOException {
    Configuration conf = job.getConfiguration();
    String username = conf.get(USERNAME);
    String password = conf.get(PASSWORD);
    String instance = conf.get(INSTANCE);
    String zookeepers = conf.get(ZOOKEEPERS);
    if (zookeepers != null) {
        AccumuloOutputFormat.setConnectorInfo(job, username, new PasswordToken(password));
        AccumuloOutputFormat.setZooKeeperInstance(job, instance, zookeepers);
    } else {
        throw new IllegalArgumentException("Must specify zookeepers");
    }
    SequenceFileInputFormat.addInputPath(job, new Path(inputPath));
    job.setInputFormatClass(SequenceFileInputFormat.class);
    job.setMapOutputKeyClass(TripleEntry.class);
    job.setMapOutputValueClass(CardList.class);
    AccumuloOutputFormat.setDefaultTableName(job, outtable);
    job.setOutputFormatClass(AccumuloOutputFormat.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Mutation.class);
}
Also used : Path(org.apache.hadoop.fs.Path) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) Configuration(org.apache.hadoop.conf.Configuration)

Example 43 with PasswordToken

use of org.apache.accumulo.core.client.security.tokens.PasswordToken in project incubator-rya by apache.

the class JoinSelectStatsUtil method initTableMRJob.

public static void initTableMRJob(Job job, String intable, String outtable, String auths) throws AccumuloSecurityException {
    Configuration conf = job.getConfiguration();
    String username = conf.get(USERNAME);
    String password = conf.get(PASSWORD);
    String instance = conf.get(INSTANCE);
    String zookeepers = conf.get(ZOOKEEPERS);
    System.out.println("Zookeepers are " + auths);
    if (zookeepers != null) {
        AccumuloInputFormat.setZooKeeperInstance(job, instance, zookeepers);
        AccumuloOutputFormat.setZooKeeperInstance(job, instance, zookeepers);
    } else {
        throw new IllegalArgumentException("Must specify either mock or zookeepers");
    }
    AccumuloInputFormat.setConnectorInfo(job, username, new PasswordToken(password));
    AccumuloInputFormat.setScanAuthorizations(job, new Authorizations(auths));
    AccumuloInputFormat.setInputTableName(job, intable);
    job.setInputFormatClass(AccumuloInputFormat.class);
    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(IntWritable.class);
    // OUTPUT
    AccumuloOutputFormat.setConnectorInfo(job, username, new PasswordToken(password));
    AccumuloOutputFormat.setDefaultTableName(job, outtable);
    job.setOutputFormatClass(AccumuloOutputFormat.class);
    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Mutation.class);
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) Authorizations(org.apache.accumulo.core.security.Authorizations) Configuration(org.apache.hadoop.conf.Configuration)

Example 44 with PasswordToken

use of org.apache.accumulo.core.client.security.tokens.PasswordToken in project incubator-rya by apache.

the class RyaGiraphUtils method initializeAccumuloInputFormat.

public static void initializeAccumuloInputFormat(Configuration conf) {
    // get accumulo connect information
    boolean mock = MRUtils.getACMock(conf, false);
    String zk = MRUtils.getACZK(conf);
    String instance = MRUtils.getACInstance(conf);
    String userName = MRUtils.getACUserName(conf);
    String pwd = MRUtils.getACPwd(conf);
    String tablePrefix = MRUtils.getTablePrefix(conf);
    TABLE_LAYOUT rdfTableLayout = MRUtils.getTableLayout(conf, TABLE_LAYOUT.SPO);
    String authString = conf.get(MRUtils.AC_AUTH_PROP);
    Authorizations authorizations;
    if (authString != null && !authString.isEmpty()) {
        authorizations = new Authorizations(authString.split(","));
        // for consistency
        conf.set(ConfigUtils.CLOUDBASE_AUTHS, authString);
    } else {
        authorizations = AccumuloRdfConstants.ALL_AUTHORIZATIONS;
    }
    // set up the accumulo input format so that we know what table to use and everything
    try {
        Job job = new Job(conf);
        AccumuloInputFormat.setConnectorInfo(job, userName, new PasswordToken(pwd));
        String tableName = RdfCloudTripleStoreUtils.layoutPrefixToTable(rdfTableLayout, tablePrefix);
        AccumuloInputFormat.setInputTableName(job, tableName);
        AccumuloInputFormat.setScanAuthorizations(job, authorizations);
        if (mock) {
            AccumuloInputFormat.setMockInstance(job, instance);
        } else {
            ClientConfiguration clientConfig = ClientConfiguration.loadDefault().withInstance(instance).withZkHosts(zk);
            AccumuloInputFormat.setZooKeeperInstance(job, clientConfig);
        }
    } catch (IOException | AccumuloSecurityException e) {
        // TODO better exception handling here
        e.printStackTrace();
    }
}
Also used : TABLE_LAYOUT(org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT) Authorizations(org.apache.accumulo.core.security.Authorizations) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) Job(org.apache.hadoop.mapreduce.Job) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration)

Example 45 with PasswordToken

use of org.apache.accumulo.core.client.security.tokens.PasswordToken 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)

Aggregations

PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)232 Test (org.junit.Test)104 Connector (org.apache.accumulo.core.client.Connector)96 MockInstance (org.apache.accumulo.core.client.mock.MockInstance)53 Instance (org.apache.accumulo.core.client.Instance)46 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)43 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)40 Authorizations (org.apache.accumulo.core.security.Authorizations)38 AuthenticationToken (org.apache.accumulo.core.client.security.tokens.AuthenticationToken)32 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)31 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)30 Value (org.apache.accumulo.core.data.Value)30 Key (org.apache.accumulo.core.data.Key)29 Mutation (org.apache.accumulo.core.data.Mutation)29 AccumuloException (org.apache.accumulo.core.client.AccumuloException)27 Scanner (org.apache.accumulo.core.client.Scanner)27 Configuration (org.apache.hadoop.conf.Configuration)27 IOException (java.io.IOException)26 BatchWriter (org.apache.accumulo.core.client.BatchWriter)26 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)24