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