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);
}
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);
}
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);
}
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);
}
}
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);
}
Aggregations