use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project incubator-rya by apache.
the class DemoDriver method startMiniAccumulo.
/**
* Setup a Mini Accumulo cluster that uses a temporary directory to store its data.
*
* @return A Mini Accumulo cluster.
*/
private static MiniAccumuloCluster startMiniAccumulo() throws IOException, InterruptedException, AccumuloException, AccumuloSecurityException {
final File miniDataDir = Files.createTempDir();
// Setup and start the Mini Accumulo.
final MiniAccumuloCluster accumulo = new MiniAccumuloCluster(miniDataDir, "password");
accumulo.start();
// Store a connector to the Mini Accumulo.
final Instance instance = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers());
accumuloConn = instance.getConnector("root", new PasswordToken("password"));
return accumulo;
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project incubator-rya by apache.
the class AccumuloInstanceDriver method setUpInstance.
/**
* Sets up the {@link MiniAccumuloCluster} or the {@link MockInstance} or
* distribution instance
* @throws Exception
*/
public void setUpInstance() throws Exception {
switch(instanceType) {
case DISTRIBUTION:
log.info("Setting up " + driverName + " distribution instance...");
if (instanceName == null) {
throw new IllegalArgumentException("Must specify instance name for distributed mode");
} else if (zooKeepers == null) {
throw new IllegalArgumentException("Must specify ZooKeeper hosts for distributed mode");
}
instance = new ZooKeeperInstance(instanceName, zooKeepers);
connector = instance.getConnector(user, new PasswordToken(userpwd));
log.info("Created connector to " + driverName + " distribution instance");
break;
case MINI:
log.info("Setting up " + driverName + " MiniAccumulo cluster...");
// Create and Run MiniAccumulo Cluster
tempDir = Files.createTempDir();
tempDir.deleteOnExit();
miniAccumuloCluster = new MiniAccumuloCluster(tempDir, userpwd);
copyHadoopHomeToTemp();
miniAccumuloCluster.getConfig().setInstanceName(instanceName);
log.info(driverName + " MiniAccumulo instance starting up...");
miniAccumuloCluster.start();
Thread.sleep(1000);
log.info(driverName + " MiniAccumulo instance started");
log.info("Creating connector to " + driverName + " MiniAccumulo instance...");
zooKeeperInstance = new ZooKeeperInstance(miniAccumuloCluster.getClientConfig());
instance = zooKeeperInstance;
connector = zooKeeperInstance.getConnector(user, new PasswordToken(userpwd));
log.info("Created connector to " + driverName + " MiniAccumulo instance");
break;
case MOCK:
log.info("Setting up " + driverName + " mock instance...");
mockInstance = new MockInstance(instanceName);
instance = mockInstance;
connector = mockInstance.getConnector(user, new PasswordToken(userpwd));
log.info("Created connector to " + driverName + " mock instance");
break;
default:
throw new AccumuloException("Unexpected instance type: " + instanceType);
}
zooKeepers = instance.getZooKeepers();
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project hive by apache.
the class AccumuloTestSetup method setupWithHiveConf.
private void setupWithHiveConf(HiveConf conf) throws Exception {
if (null == miniCluster) {
String testTmpDir = System.getProperty("test.tmp.dir");
File tmpDir = new File(testTmpDir, "accumulo");
if (tmpDir.exists()) {
FileUtils.deleteDirectory(tmpDir);
}
MiniAccumuloConfig cfg = new MiniAccumuloConfig(tmpDir, PASSWORD);
cfg.setNumTservers(1);
miniCluster = new MiniAccumuloCluster(cfg);
appendZooKeeperConf(EXTRA_ZOOKEEPER_CONFIG, tmpDir);
miniCluster.start();
createAccumuloTable(miniCluster.getConnector("root", PASSWORD));
}
updateConf(conf);
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project Gaffer by gchq.
the class RFileReaderRddIT method throwRTX_whenRDDHasUserWithoutPermission.
@Test
public void throwRTX_whenRDDHasUserWithoutPermission() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException, TableNotFoundException, TableExistsException {
// Given
final MiniAccumuloCluster cluster = createAccumuloCluster(tableName, config, Arrays.asList("Bananas"));
final RFileReaderRDD rdd = new RFileReaderRDD(sparkSession.sparkContext(), cluster.getInstanceName(), cluster.getZooKeepers(), MiniAccumuloClusterProvider.USER_NO_GRANTED_PERMISSION, MiniAccumuloClusterProvider.PASSWORD, tableName, new HashSet<>(), serialiseConfiguration(config));
// When / Then
assertThatExceptionOfType(RuntimeException.class).isThrownBy(rdd::getPartitions).withMessage("User user2 does not have access to table " + tableName);
}
use of org.apache.accumulo.minicluster.MiniAccumuloCluster in project Gaffer by gchq.
the class RFileReaderRddIT method testRFileReaderRDDAppliesIteratorCorrectly.
@Test
public void testRFileReaderRDDAppliesIteratorCorrectly() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException, TableNotFoundException, TableExistsException {
// Given
final List<String> data = Arrays.asList("no", "not", "value");
final Job job = Job.getInstance(config);
final MiniAccumuloCluster cluster = createAccumuloCluster(tableName, job.getConfiguration(), data);
// Create an iterator and an option to grep for "val"
final Map<String, String> options = new HashMap<>();
options.put("term", "val");
AccumuloInputFormat.addIterator(job, new IteratorSetting(2, "NAME", GrepIterator.class.getName(), options));
// When
final RFileReaderRDD rdd = new RFileReaderRDD(sparkSession.sparkContext(), cluster.getInstanceName(), cluster.getZooKeepers(), MiniAccumuloClusterProvider.USER, MiniAccumuloClusterProvider.PASSWORD, tableName, new HashSet<>(), serialiseConfiguration(job.getConfiguration()));
// Then
assertThat(rdd.count()).isEqualTo(1L);
}
Aggregations