Search in sources :

Example 36 with ClientConfiguration

use of org.apache.accumulo.core.client.ClientConfiguration in project incubator-rya by apache.

the class GraphXGraphGenerator method getEdgeRDD.

public RDD<Tuple2<Object, Edge>> getEdgeRDD(SparkContext sc, Configuration conf) throws IOException, AccumuloSecurityException {
    // Load configuration parameters
    zk = MRUtils.getACZK(conf);
    instance = MRUtils.getACInstance(conf);
    userName = MRUtils.getACUserName(conf);
    pwd = MRUtils.getACPwd(conf);
    mock = MRUtils.getACMock(conf, false);
    tablePrefix = MRUtils.getTablePrefix(conf);
    // Set authorizations if specified
    String authString = conf.get(MRUtils.AC_AUTH_PROP);
    if (authString != null && !authString.isEmpty()) {
        authorizations = new Authorizations(authString.split(","));
        // for consistency
        conf.set(ConfigUtils.CLOUDBASE_AUTHS, authString);
    } else {
        authorizations = AccumuloRdfConstants.ALL_AUTHORIZATIONS;
    }
    // Set table prefix to the default if not set
    if (tablePrefix == null) {
        tablePrefix = RdfCloudTripleStoreConstants.TBL_PRFX_DEF;
        MRUtils.setTablePrefix(conf, tablePrefix);
    }
    // Check for required configuration parameters
    Preconditions.checkNotNull(instance, "Accumulo instance name [" + MRUtils.AC_INSTANCE_PROP + "] not set.");
    Preconditions.checkNotNull(userName, "Accumulo username [" + MRUtils.AC_USERNAME_PROP + "] not set.");
    Preconditions.checkNotNull(pwd, "Accumulo password [" + MRUtils.AC_PWD_PROP + "] not set.");
    Preconditions.checkNotNull(tablePrefix, "Table prefix [" + MRUtils.TABLE_PREFIX_PROPERTY + "] not set.");
    RdfCloudTripleStoreConstants.prefixTables(tablePrefix);
    // for consistency
    if (!mock)
        conf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, zk);
    // Ensure consistency between alternative configuration properties
    conf.set(ConfigUtils.CLOUDBASE_INSTANCE, instance);
    conf.set(ConfigUtils.CLOUDBASE_USER, userName);
    conf.set(ConfigUtils.CLOUDBASE_PASSWORD, pwd);
    conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, mock);
    conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, tablePrefix);
    Job job = Job.getInstance(conf, sc.appName());
    ClientConfiguration clientConfig = new ClientConfiguration().with(ClientProperty.INSTANCE_NAME, instance).with(ClientProperty.INSTANCE_ZK_HOST, zk);
    RyaInputFormat.setTableLayout(job, TABLE_LAYOUT.SPO);
    RyaInputFormat.setConnectorInfo(job, userName, new PasswordToken(pwd));
    RyaInputFormat.setZooKeeperInstance(job, clientConfig);
    RyaInputFormat.setScanAuthorizations(job, authorizations);
    String tableName = RdfCloudTripleStoreUtils.layoutPrefixToTable(TABLE_LAYOUT.SPO, tablePrefix);
    InputFormatBase.setInputTableName(job, tableName);
    return sc.newAPIHadoopRDD(job.getConfiguration(), GraphXEdgeInputFormat.class, Object.class, Edge.class);
}
Also used : Authorizations(org.apache.accumulo.core.security.Authorizations) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) Job(org.apache.hadoop.mapreduce.Job) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration)

Example 37 with ClientConfiguration

use of org.apache.accumulo.core.client.ClientConfiguration in project vertexium by visallo.

the class AccumuloElementOutputFormat method setOutputInfo.

public static void setOutputInfo(Job job, String instanceName, String zooKeepers, String principal, AuthenticationToken token) throws AccumuloSecurityException {
    AccumuloOutputFormat.setConnectorInfo(job, principal, token);
    ClientConfiguration clientConfig = new ClientConfiguration().withInstance(instanceName).withZkHosts(zooKeepers);
    AccumuloOutputFormat.setZooKeeperInstance(job, clientConfig);
    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(Mutation.class);
}
Also used : ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration)

Example 38 with ClientConfiguration

use of org.apache.accumulo.core.client.ClientConfiguration in project hive by apache.

the class AccumuloConnectionParameters method getInstance.

public Instance getInstance() {
    String instanceName = getAccumuloInstanceName();
    // Fail with a good message
    if (null == instanceName) {
        throw new IllegalArgumentException("Accumulo instance name must be provided in hiveconf using " + INSTANCE_NAME);
    }
    if (useMockInstance()) {
        return new MockInstance(instanceName);
    }
    String zookeepers = getZooKeepers();
    // Fail with a good message
    if (null == zookeepers) {
        throw new IllegalArgumentException("ZooKeeper quorum string must be provided in hiveconf using " + ZOOKEEPERS);
    }
    ClientConfiguration clientConf = ClientConfiguration.loadDefault().withInstance(instanceName).withZkHosts(zookeepers).withSasl(useSasl());
    return new ZooKeeperInstance(clientConf);
}
Also used : MockInstance(org.apache.accumulo.core.client.mock.MockInstance) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 39 with ClientConfiguration

use of org.apache.accumulo.core.client.ClientConfiguration in project hive by apache.

the class HiveAccumuloHelper method setInputFormatZooKeeperInstance.

/**
 * Calls {@link AccumuloInputFormat#setZooKeeperInstance(JobConf, ClientConfiguration)},
 * suppressing exceptions due to setting the configuration multiple times.
 */
public void setInputFormatZooKeeperInstance(JobConf conf, String instanceName, String zookeepers, boolean isSasl) throws IOException {
    try {
        ClientConfiguration clientConf = getClientConfiguration(zookeepers, instanceName, isSasl);
        AccumuloInputFormat.setZooKeeperInstance(conf, clientConf);
    } catch (IllegalStateException ise) {
        // AccumuloInputFormat complains if you re-set an already set value. We just don't care.
        log.debug("Ignoring exception setting ZooKeeper instance of " + instanceName + " at " + zookeepers, ise);
    }
}
Also used : ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration)

Example 40 with ClientConfiguration

use of org.apache.accumulo.core.client.ClientConfiguration in project incubator-rya by apache.

the class AbstractAccumuloMRTool method setupAccumuloOutput.

/**
 * Sets up Accumulo output for a job: allows the job to write (String,
 * Mutation) pairs, where the Mutation will be written to the table named by
 * the String.
 * @param   job Job to configure
 * @param   outputTable Default table to send output to
 * @throws  AccumuloSecurityException if connecting to Accumulo with the
 *          given username and password fails
 */
protected void setupAccumuloOutput(Job job, String outputTable) throws AccumuloSecurityException {
    AccumuloOutputFormat.setConnectorInfo(job, userName, new PasswordToken(pwd));
    AccumuloOutputFormat.setCreateTables(job, true);
    AccumuloOutputFormat.setDefaultTableName(job, outputTable);
    if (mock) {
        AccumuloOutputFormat.setMockInstance(job, instance);
    } else {
        ClientConfiguration clientConfig = ClientConfiguration.loadDefault().withInstance(instance).withZkHosts(zk);
        AccumuloOutputFormat.setZooKeeperInstance(job, clientConfig);
    }
    job.setOutputFormatClass(AccumuloOutputFormat.class);
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration)

Aggregations

ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)78 Test (org.junit.Test)40 Connector (org.apache.accumulo.core.client.Connector)28 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)27 IOException (java.io.IOException)16 TestIngest (org.apache.accumulo.test.TestIngest)15 BatchWriterOpts (org.apache.accumulo.core.cli.BatchWriterOpts)13 ScannerOpts (org.apache.accumulo.core.cli.ScannerOpts)12 KerberosToken (org.apache.accumulo.core.client.security.tokens.KerberosToken)12 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)11 VerifyIngest (org.apache.accumulo.test.VerifyIngest)11 ClusterUser (org.apache.accumulo.cluster.ClusterUser)9 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)9 ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)8 Map (java.util.Map)7 AccumuloException (org.apache.accumulo.core.client.AccumuloException)6 Instance (org.apache.accumulo.core.client.Instance)6 AuthenticationToken (org.apache.accumulo.core.client.security.tokens.AuthenticationToken)6 Authorizations (org.apache.accumulo.core.security.Authorizations)6 Path (org.apache.hadoop.fs.Path)6