Java Code Examples for org.apache.accumulo.minicluster.MiniAccumuloCluster#getZooKeepers()
The following examples show how to use
org.apache.accumulo.minicluster.MiniAccumuloCluster#getZooKeepers() .
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 |
@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 3
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 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: 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 9
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 10
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 11
Source File: QueryBenchmarkRunIT.java From rya with Apache License 2.0 | 4 votes |
@BeforeClass public static void setup() throws Exception { // Squash loud logs. Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR); // Setup the Mini Accumulo Cluster. final File miniDataDir = com.google.common.io.Files.createTempDir(); final MiniAccumuloConfig cfg = new MiniAccumuloConfig( miniDataDir, ACCUMULO_PASSWORD); cluster = new MiniAccumuloCluster(cfg); cluster.start(); // Create a Rya Client connected to the Mini Accumulo Cluster. final AccumuloConnectionDetails connDetails = new AccumuloConnectionDetails( ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), cluster.getInstanceName(), cluster.getZooKeepers()); final Connector connector = cluster.getConnector(ACCUMULO_USER, ACCUMULO_PASSWORD); final RyaClient ryaClient = AccumuloRyaClientFactory.build(connDetails, connector); // Install an instance of Rya on the mini cluster. installRya(ryaClient); // Get a Sail object that is backed by the Rya store that is on the mini cluster. final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration(); ryaConf.setTablePrefix(RYA_INSTANCE_NAME); ryaConf.set(ConfigUtils.CLOUDBASE_USER, ACCUMULO_USER); ryaConf.set(ConfigUtils.CLOUDBASE_PASSWORD, ACCUMULO_PASSWORD); ryaConf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, cluster.getZooKeepers()); ryaConf.set(ConfigUtils.CLOUDBASE_INSTANCE, cluster.getInstanceName()); ryaConf.set(ConfigUtils.USE_PCJ, "true"); ryaConf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinStorageType.ACCUMULO.toString()); ryaConf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinUpdaterType.NO_UPDATE.toString()); sail = RyaSailFactory.getInstance( ryaConf ); // Load some data into the cluster that will match the query we're testing against. loadTestStatements(); // Add a PCJ to the application that summarizes the query. createTestPCJ(ryaClient); }
Example 12
Source File: AccumuloRyaCommandsIT.java From rya with Apache License 2.0 | 4 votes |
@Test public void loadsAndQueryData() throws Exception { 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(); CommandResult result = shell.executeCommand(cmd); // Install an instance of rya. final String instanceName = "testInstance"; final InstallConfiguration installConf = InstallConfiguration.builder().build(); final InstallPrompt installPrompt = context.getBean( InstallPrompt.class ); when(installPrompt.promptInstanceName()).thenReturn("testInstance"); when(installPrompt.promptInstallConfiguration("testInstance")).thenReturn( installConf ); when(installPrompt.promptVerified(instanceName, installConf)).thenReturn(true); result = shell.executeCommand( RyaAdminCommands.INSTALL_CMD ); assertTrue( result.isSuccess() ); // Connect to the instance that was just installed. cmd = RyaConnectionCommands.CONNECT_INSTANCE_CMD + " --instance " + instanceName; result = shell.executeCommand(cmd); assertTrue( result.isSuccess() ); // Load a statements file into the instance. cmd = RyaCommands.LOAD_DATA_CMD + " --file src/test/resources/test-statements.nt"; result = shell.executeCommand(cmd); assertTrue( result.isSuccess() ); // Query for all of the statements that were loaded. final SparqlPrompt sparqlPrompt = context.getBean(SparqlPrompt.class); when(sparqlPrompt.getSparql()).thenReturn(Optional.of("select * where { ?s ?p ?o .}")); cmd = RyaCommands.SPARQL_QUERY_CMD; result = shell.executeCommand(cmd); assertTrue( result.isSuccess() ); }
Example 13
Source File: AccumuloRyaConnectionCommandsIT.java From rya with Apache License 2.0 | 4 votes |
@Test public void connectToInstance() 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(); CommandResult result = shell.executeCommand(cmd); // Install an instance of rya. final String instanceName = "testInstance"; final InstallConfiguration installConf = InstallConfiguration.builder().build(); final InstallPrompt installPrompt = context.getBean( InstallPrompt.class ); when(installPrompt.promptInstanceName()).thenReturn("testInstance"); when(installPrompt.promptInstallConfiguration("testInstance")).thenReturn( installConf ); when(installPrompt.promptVerified(instanceName, installConf)).thenReturn(true); result = shell.executeCommand( RyaAdminCommands.INSTALL_CMD ); assertTrue( result.isSuccess() ); // Connect to the instance that was just installed. cmd = RyaConnectionCommands.CONNECT_INSTANCE_CMD + " --instance " + instanceName; result = shell.executeCommand(cmd); assertTrue( result.isSuccess() ); // Verify the shell state indicates it is connected to an instance. final SharedShellState sharedState = context.getBean( SharedShellState.class ); final ShellState state = sharedState.getShellState(); assertEquals(ConnectionState.CONNECTED_TO_INSTANCE, state.getConnectionState()); }