org.apache.accumulo.minicluster.MiniAccumuloCluster Java Examples
The following examples show how to use
org.apache.accumulo.minicluster.MiniAccumuloCluster.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccumuloQueryRunner.java From presto with Apache License 2.0 | 6 votes |
/** * Gets the AccumuloConnector singleton, starting the MiniAccumuloCluster on initialization. * This singleton instance is required so all test cases access the same MiniAccumuloCluster. * * @return Accumulo connector */ public static Connector getAccumuloConnector() { if (connector != null) { return connector; } try { MiniAccumuloCluster accumulo = createMiniAccumuloCluster(); Instance instance = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers()); connector = instance.getConnector(MAC_USER, new PasswordToken(MAC_PASSWORD)); LOG.info("Connection to MAC instance %s at %s established, user %s password %s", accumulo.getInstanceName(), accumulo.getZooKeepers(), MAC_USER, MAC_PASSWORD); return connector; } catch (AccumuloException | AccumuloSecurityException | InterruptedException | IOException e) { throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to get connector to Accumulo", e); } }
Example #2
Source File: KafkaExportITBase.java From rya with Apache License 2.0 | 6 votes |
private void installRyaInstance() throws Exception { final MiniAccumuloCluster cluster = super.getMiniAccumuloCluster(); final String instanceName = cluster.getInstanceName(); final String zookeepers = cluster.getZooKeepers(); // Install the Rya instance to the mini accumulo cluster. final RyaClient ryaClient = AccumuloRyaClientFactory.build( new AccumuloConnectionDetails(ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), instanceName, zookeepers), super.getAccumuloConnector()); ryaClient.getInstall().install(RYA_INSTANCE_NAME, InstallConfiguration.builder().setEnableTableHashPrefix(false).setEnableFreeTextIndex(false) .setEnableEntityCentricIndex(false).setEnableGeoIndex(false).setEnableTemporalIndex(false).setEnablePcjIndex(true) .setFluoPcjAppName(super.getFluoConfiguration().getApplicationName()).build()); // Connect to the Rya instance that was just installed. final AccumuloRdfConfiguration conf = makeConfig(instanceName, zookeepers); final Sail sail = RyaSailFactory.getInstance(conf); dao = RyaSailFactory.getAccumuloDAOWithUpdatedConfig(conf); ryaSailRepo = new RyaSailRepository(sail); }
Example #3
Source File: KafkaExportITBase.java From rya with Apache License 2.0 | 6 votes |
@After public void teardownRya() { final MiniAccumuloCluster cluster = getMiniAccumuloCluster(); final String instanceName = cluster.getInstanceName(); final String zookeepers = cluster.getZooKeepers(); // Uninstall the instance of Rya. final RyaClient ryaClient = AccumuloRyaClientFactory.build( new AccumuloConnectionDetails(ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), instanceName, zookeepers), super.getAccumuloConnector()); try { ryaClient.getUninstall().uninstall(RYA_INSTANCE_NAME); // Shutdown the repo. if(ryaSailRepo != null) {ryaSailRepo.shutDown();} if(dao != null ) {dao.destroy();} } catch (final Exception e) { System.out.println("Encountered the following Exception when shutting down Rya: " + e.getMessage()); } }
Example #4
Source File: AccumuloRyaConnectionCommandsIT.java From rya with Apache License 2.0 | 6 votes |
@Test public void connectAccumulo() throws IOException { final MiniAccumuloCluster cluster = getCluster(); final Bootstrap bootstrap = getTestBootstrap(); final JLineShellComponent shell = getTestShell(); // Mock the user entering the correct password. final ApplicationContext context = bootstrap.getApplicationContext(); final PasswordPrompt mockPrompt = context.getBean( PasswordPrompt.class ); when(mockPrompt.getPassword()).thenReturn("password".toCharArray()); // Execute the connect command. final String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " "+ "--zookeepers " + cluster.getZooKeepers(); final CommandResult connectResult = shell.executeCommand(cmd); // Ensure the connection was successful. assertTrue( connectResult.isSuccess() ); }
Example #5
Source File: AccumuloRyaConnectionCommandsIT.java From rya with Apache License 2.0 | 6 votes |
@Test public void connectAccumulo_wrongCredentials() throws IOException { final MiniAccumuloCluster cluster = getCluster(); final Bootstrap bootstrap = getTestBootstrap(); final JLineShellComponent shell = getTestShell(); // Mock the user entering the wrong password. final ApplicationContext context = bootstrap.getApplicationContext(); final PasswordPrompt mockPrompt = context.getBean( PasswordPrompt.class ); when(mockPrompt.getPassword()).thenReturn("asjifo[ijwa".toCharArray()); // Execute the command final String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " "+ "--zookeepers " + cluster.getZooKeepers(); final CommandResult connectResult = shell.executeCommand(cmd); // Ensure the command failed. assertFalse( connectResult.isSuccess() ); }
Example #6
Source File: AccumuloRyaConnectionCommandsIT.java From rya with Apache License 2.0 | 6 votes |
@Test public void connectToInstance_instanceDoesNotExist() throws IOException { final MiniAccumuloCluster cluster = getCluster(); final Bootstrap bootstrap = getTestBootstrap(); final JLineShellComponent shell = getTestShell(); // Mock the user entering the correct password. final ApplicationContext context = bootstrap.getApplicationContext(); final PasswordPrompt mockPrompt = context.getBean( PasswordPrompt.class ); when(mockPrompt.getPassword()).thenReturn("password".toCharArray()); // Connect to the mini accumulo instance. String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " "+ "--zookeepers " + cluster.getZooKeepers(); shell.executeCommand(cmd); // Try to connect to a non-existing instance. cmd = RyaConnectionCommands.CONNECT_INSTANCE_CMD + " --instance doesNotExist"; final CommandResult result = shell.executeCommand(cmd); assertFalse( result.isSuccess() ); }
Example #7
Source File: AccumuloRyaConnectionCommandsIT.java From rya with Apache License 2.0 | 6 votes |
@Test public void disconnect() throws IOException { final MiniAccumuloCluster cluster = getCluster(); final Bootstrap bootstrap = getTestBootstrap(); final JLineShellComponent shell = getTestShell(); // Mock the user entering the correct password. final ApplicationContext context = bootstrap.getApplicationContext(); final PasswordPrompt mockPrompt = context.getBean( PasswordPrompt.class ); when(mockPrompt.getPassword()).thenReturn("password".toCharArray()); // Connect to the mini accumulo instance. final String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " "+ "--zookeepers " + cluster.getZooKeepers(); shell.executeCommand(cmd); // Disconnect from it. final CommandResult disconnectResult = shell.executeCommand( RyaConnectionCommands.DISCONNECT_COMMAND_NAME_CMD ); assertTrue( disconnectResult.isSuccess() ); }
Example #8
Source File: ITBase.java From fluo with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUpAccumulo() throws Exception { instanceName = System.getProperty(IT_INSTANCE_NAME_PROP, "it-instance-default"); File instanceDir = new File("target/accumulo2-maven-plugin/" + instanceName); boolean instanceClear = System.getProperty(IT_INSTANCE_CLEAR_PROP, "true").equalsIgnoreCase("true"); if (instanceDir.exists() && instanceClear) { FileUtils.deleteDirectory(instanceDir); } if (!instanceDir.exists()) { MiniAccumuloConfig cfg = new MiniAccumuloConfig(instanceDir, PASSWORD); cfg.setInstanceName(instanceName); cluster = new MiniAccumuloCluster(cfg); cluster.start(); startedCluster = true; } Properties props = MiniAccumuloCluster.getClientProperties(instanceDir); aClient = Accumulo.newClient().from(props).build(); }
Example #9
Source File: TestAccumuloPigCluster.java From spork with Apache License 2.0 | 5 votes |
@BeforeClass public static void setupClusters() throws Exception { MiniAccumuloConfig macConf = new MiniAccumuloConfig(tmpdir, "password"); macConf.setNumTservers(1); accumuloCluster = new MiniAccumuloCluster(macConf); accumuloCluster.start(); }
Example #10
Source File: ScanAccumuloIT.java From nifi with Apache License 2.0 | 5 votes |
@BeforeClass public static void setupInstance() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException, TableExistsException { Assume.assumeTrue("Test only runs on *nix", !SystemUtils.IS_OS_WINDOWS); Path tempDirectory = Files.createTempDirectory("acc"); // JUnit and Guava supply mechanisms for creating temp directories accumulo = new MiniAccumuloCluster(tempDirectory.toFile(), "password"); accumulo.start(); }
Example #11
Source File: PutRecordIT.java From nifi with Apache License 2.0 | 5 votes |
@BeforeClass public static void setupInstance() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException, TableExistsException { Assume.assumeTrue("Test only runs on *nix", !SystemUtils.IS_OS_WINDOWS); Path tempDirectory = Files.createTempDirectory("acc"); // JUnit and Guava supply mechanisms for creating temp directories accumulo = new MiniAccumuloCluster(tempDirectory.toFile(), "password"); accumulo.start(); }
Example #12
Source File: AccumuloRyaConnectionCommandsIT.java From rya with Apache License 2.0 | 5 votes |
@Test public void printConnectionDetails_connectedToAccumulo() throws IOException { final MiniAccumuloCluster cluster = getCluster(); final Bootstrap bootstrap = getTestBootstrap(); final JLineShellComponent shell = getTestShell(); // Mock the user entering the correct password. final ApplicationContext context = bootstrap.getApplicationContext(); final PasswordPrompt mockPrompt = context.getBean( PasswordPrompt.class ); when(mockPrompt.getPassword()).thenReturn("password".toCharArray()); // Connect to the mini accumulo instance. final String cmd = RyaConnectionCommands.CONNECT_ACCUMULO_CMD + " " + "--username root " + "--instanceName " + cluster.getInstanceName() + " "+ "--zookeepers " + cluster.getZooKeepers(); shell.executeCommand(cmd); // Run the print connection details command. final CommandResult printResult = shell.executeCommand( RyaConnectionCommands.PRINT_CONNECTION_DETAILS_CMD ); final String msg = (String) printResult.getResult(); final String expected = "The shell is connected to an instance of Accumulo using the following parameters:\n" + " Username: root\n" + " Instance Name: " + cluster.getInstanceName() + "\n" + " Zookeepers: " + cluster.getZooKeepers(); assertEquals(expected, msg); }
Example #13
Source File: MiniFluoImpl.java From fluo with Apache License 2.0 | 5 votes |
private void startMiniAccumulo() { try { // start mini accumulo cluster MiniAccumuloConfig cfg = new MiniAccumuloConfig(new File(config.getMiniDataDir()), PASSWORD); cluster = new MiniAccumuloCluster(cfg); cluster.start(); log.debug("Started MiniAccumulo(accumulo=" + cluster.getInstanceName() + " zk=" + cluster.getZooKeepers() + ")"); // configuration that must overridden config.setAccumuloInstance(cluster.getInstanceName()); config.setAccumuloUser(USER); config.setAccumuloPassword(PASSWORD); config.setAccumuloZookeepers(cluster.getZooKeepers()); config.setInstanceZookeepers(cluster.getZooKeepers() + "/fluo"); // configuration that only needs to be set if not by user if ((config.containsKey(FluoConfiguration.ACCUMULO_TABLE_PROP) == false) || config.getAccumuloTable().trim().isEmpty()) { config.setAccumuloTable("fluo"); } InitializationOptions opts = new InitializationOptions(); try (FluoAdmin admin = FluoFactory.newAdmin(config)) { admin.initialize(opts); } File miniProps = new File(clientPropsPath(config)); config.getClientConfiguration().save(miniProps); log.debug("Wrote MiniFluo client properties to {}", miniProps.getAbsolutePath()); } catch (Exception e) { throw new RuntimeException(e); } }
Example #14
Source File: AccumuloIndexSetColumnVisibilityTest.java From rya with Apache License 2.0 | 5 votes |
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()); accCon = instance.getConnector("root", new PasswordToken("password")); return accumulo; }
Example #15
Source File: AccumuloInstanceDriver.java From rya with Apache License 2.0 | 5 votes |
/** * Sets up the {@link MiniAccumuloCluster} or the {@link MockInstance}. * @throws Exception */ public void setUpInstance() throws Exception { if (!isMock) { 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"); } else { 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"); } zooKeepers = instance.getZooKeepers(); }
Example #16
Source File: AccumuloMiniClusterDriver.java From accumulo-recipes with Apache License 2.0 | 5 votes |
public void start() throws IOException { try { initInstanceAndConnector(300); } catch (Throwable e) { try { initConfig(); miniAccumuloCluster = new MiniAccumuloCluster(miniAccumuloConfig); miniAccumuloCluster.start(); log.info("started minicluster"); initInstanceAndConnector(null); } catch (Throwable e1) { throw new IOException(e1); } } }
Example #17
Source File: ShardedTableMapFileTest.java From datawave with Apache License 2.0 | 5 votes |
@Test public void testWriteSplitsToAccumuloAndReadThem() throws Exception { Configuration conf = new Configuration(); conf.setInt(ShardIdFactory.NUM_SHARDS, 1); conf.setInt(ShardedTableMapFile.SHARDS_BALANCED_DAYS_TO_VERIFY, 1); String today = formatDay(0) + "_1"; MiniAccumuloCluster accumuloCluster = null; try { SortedSet<Text> sortedSet = new TreeSet<>(); sortedSet.add(new Text(today)); accumuloCluster = createMiniAccumuloWithTestTableAndSplits(sortedSet); configureAccumuloHelper(conf, accumuloCluster); conf.set(ShardedDataTypeHandler.SHARDED_TNAMES, TABLE_NAME + ",shard_ingest_unit_test_table_1,shard_ingest_unit_test_table_2,shard_ingest_unit_test_table_3"); conf.set(ShardedTableMapFile.TABLE_NAMES, TABLE_NAME); setWorkingDirectory(conf); ShardedTableMapFile.setupFile(conf); } finally { if (null != accumuloCluster) { accumuloCluster.stop(); } } TreeMap<Text,String> result = ShardedTableMapFile.getShardIdToLocations(conf, TABLE_NAME); Assert.assertNotNull(result.get(new Text(today)).toString()); Assert.assertEquals(1, result.size()); }
Example #18
Source File: DemoDriver.java From rya with Apache License 2.0 | 5 votes |
/** * 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; }
Example #19
Source File: TableConfigHelperFactoryTest.java From datawave with Apache License 2.0 | 5 votes |
@BeforeClass public static void startCluster() throws Exception { File macDir = new File(System.getProperty("user.dir") + "/target/mac/" + TableConfigHelperFactoryTest.class.getName()); if (macDir.exists()) FileUtils.deleteDirectory(macDir); macDir.mkdirs(); mac = new MiniAccumuloCluster(new MiniAccumuloConfig(macDir, "pass")); mac.start(); }
Example #20
Source File: TwoWaySSLFailureIT.java From qonduit with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() throws Exception { temp.create(); final MiniAccumuloConfig macConfig = new MiniAccumuloConfig(temp.newFolder("mac"), "secret"); mac = new MiniAccumuloCluster(macConfig); mac.start(); conf = TestConfiguration.createMinimalConfigurationForTest(); conf.getAccumulo().setInstanceName(mac.getInstanceName()); conf.getAccumulo().setZookeepers(mac.getZooKeepers()); setupSSL(conf); }
Example #21
Source File: TwoWaySSLIT.java From qonduit with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() throws Exception { final MiniAccumuloConfig macConfig = new MiniAccumuloConfig(temp.newFolder("mac"), "secret"); mac = new MiniAccumuloCluster(macConfig); mac.start(); conf = TestConfiguration.createMinimalConfigurationForTest(); conf.getAccumulo().setInstanceName(mac.getInstanceName()); conf.getAccumulo().setZookeepers(mac.getZooKeepers()); setupSSL(conf); }
Example #22
Source File: AccumuloTestCase.java From aliyun-maxcompute-data-collectors with Apache License 2.0 | 5 votes |
protected static MiniAccumuloCluster createMiniAccumuloCluster(File tempDir, String rootPassword) throws Exception { final String configImplClassName = "org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl", clusterImplClassName = "org.apache.accumulo.minicluster.impl.MiniAccumuloClusterImpl"; try { // Get the MiniAccumuloConfigImpl class Class<?> configImplClz = Class.forName(configImplClassName); // Get the (File,String) constructor Constructor<?> cfgConstructor = configImplClz.getConstructor(new Class[] {File.class, String.class}); Object configImpl = cfgConstructor.newInstance(tempDir, rootPassword); // Get setClasspathItems(String...) Method setClasspathItemsMethod = configImplClz.getDeclaredMethod("setClasspathItems", String[].class); // Get the classpath, removing problematic jars String classpath = getClasspath(new File(tempDir, "conf")); // Call the method setClasspathItemsMethod.invoke(configImpl, (Object) new String[] {classpath}); // Get the private MiniAccumuloCluster(MiniAccumuloConfigImpl constructor) Constructor<?> clusterConstructor = MiniAccumuloCluster.class.getDeclaredConstructor(configImplClz); // Make it accessible (since its private) clusterConstructor.setAccessible(true); Object clusterImpl = clusterConstructor.newInstance(configImpl); return MiniAccumuloCluster.class.cast(clusterImpl); } catch (Exception e) { // Couldn't load the 1.6 MiniAccumuloConfigImpl which has // the classpath control LOG.warn("Could not load 1.6 minicluster classes", e); return new MiniAccumuloCluster(tempDir, ACCUMULO_PASSWORD); } }
Example #23
Source File: TwoWaySSLFailureIT.java From timely with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() throws Exception { temp.create(); final MiniAccumuloConfig macConfig = new MiniAccumuloConfig(temp.newFolder("mac"), "secret"); mac = new MiniAccumuloCluster(macConfig); mac.start(); conf = TestConfiguration.createMinimalConfigurationForTest(); conf.getAccumulo().setInstanceName(mac.getInstanceName()); conf.getAccumulo().setZookeepers(mac.getZooKeepers()); setupSSL(conf); }
Example #24
Source File: MiniAccumuloClusterInstance.java From rya with Apache License 2.0 | 5 votes |
/** * Start the {@link MiniAccumuloCluster}. */ public void startMiniAccumulo() throws IOException, InterruptedException, AccumuloException, AccumuloSecurityException { final File miniDataDir = Files.createTempDir(); // Setup and start the Mini Accumulo. final MiniAccumuloConfig cfg = new MiniAccumuloConfig(miniDataDir, PASSWORD); cluster = new MiniAccumuloCluster(cfg); cluster.start(); }
Example #25
Source File: TwoWaySSLIT.java From timely with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() throws Exception { final MiniAccumuloConfig macConfig = new MiniAccumuloConfig(temp.newFolder("mac"), "secret"); mac = new MiniAccumuloCluster(macConfig); mac.start(); conf = TestConfiguration.createMinimalConfigurationForTest(); conf.getAccumulo().setInstanceName(mac.getInstanceName()); conf.getAccumulo().setZookeepers(mac.getZooKeepers()); setupSSL(conf); }
Example #26
Source File: AmcHelper.java From OSTMap with Apache License 2.0 | 5 votes |
public MiniAccumuloCluster startMiniCluster(File tempFile) { try { amc = new MiniAccumuloCluster(tempFile, "password"); amc.start(); return amc; }catch (IOException | InterruptedException e){ e.printStackTrace(); } return null; }
Example #27
Source File: Demo.java From rya with Apache License 2.0 | 5 votes |
/** * Run the demo. */ public void execute( MiniAccumuloCluster accumulo, Connector accumuloConn, String ryaTablePrefix, RyaSailRepository ryaRepo, RepositoryConnection ryaConn, MiniFluo fluo, FluoClient fluoClient) throws DemoExecutionException;
Example #28
Source File: RyaShellAccumuloITBase.java From rya with Apache License 2.0 | 4 votes |
/** * @return The cluster that is hosting the test. */ public MiniAccumuloCluster getCluster() { return MiniAccumuloSingleton.getInstance().getCluster(); }
Example #29
Source File: ShardedTableMapFileTest.java From datawave with Apache License 2.0 | 4 votes |
private void configureAccumuloHelper(Configuration conf, MiniAccumuloCluster accumuloCluster) { AccumuloHelper.setInstanceName(conf, accumuloCluster.getInstanceName()); AccumuloHelper.setPassword(conf, PASSWORD.getBytes()); AccumuloHelper.setUsername(conf, USERNAME); AccumuloHelper.setZooKeepers(conf, accumuloCluster.getZooKeepers()); }
Example #30
Source File: AmcHelper.java From OSTMap with Apache License 2.0 | 4 votes |
public MiniAccumuloCluster startMiniCluster(String tempStr){ return startMiniCluster(new File(tempStr)); }