use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class RyaAdminCommands method install.
@CliCommand(value = INSTALL_CMD, help = "Create a new instance of Rya interactively.")
public String install() {
// Fetch the commands that are connected to the store.
final RyaClient commands = state.getShellState().getConnectedCommands().get();
String instanceName = null;
InstallConfiguration installConfig = null;
try {
boolean verified = false;
while (!verified) {
// Use the install prompt to fetch the user's installation options.
instanceName = installPrompt.promptInstanceName();
installConfig = installPrompt.promptInstallConfiguration(instanceName);
// Verify the configuration is what the user actually wants to do.
verified = installPrompt.promptVerified(instanceName, installConfig);
}
// Execute the command.
commands.getInstall().install(instanceName, installConfig);
return String.format("The Rya instance named '%s' has been installed.", instanceName);
} catch (final DuplicateInstanceNameException e) {
throw new RuntimeException(String.format("A Rya instance named '%s' already exists. Try again with a different name.", instanceName), e);
} catch (final IOException | RyaClientException e) {
throw new RuntimeException("Could not install a new instance of Rya. Reason: " + e.getMessage(), e);
}
}
use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class AccumuloRyaConnectionCommandsIT method connectToInstance.
@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());
}
use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class RyaAdminCommandsTest method install.
@Test
public void install() throws DuplicateInstanceNameException, RyaClientException, IOException {
// Mock the object that performs the install operation.
final Install mockInstall = mock(Install.class);
final RyaClient mockCommands = mock(RyaClient.class);
when(mockCommands.getInstall()).thenReturn(mockInstall);
final SharedShellState state = new SharedShellState();
state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
// Execute the command.
final String instanceName = "unitTests";
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableGeoIndex(true).setEnablePcjIndex(true).build();
final InstallPrompt mockInstallPrompt = mock(InstallPrompt.class);
when(mockInstallPrompt.promptInstanceName()).thenReturn(instanceName);
when(mockInstallPrompt.promptInstallConfiguration(instanceName)).thenReturn(installConfig);
when(mockInstallPrompt.promptVerified(eq(instanceName), eq(installConfig))).thenReturn(true);
final RyaAdminCommands commands = new RyaAdminCommands(state, mockInstallPrompt, mock(SparqlPrompt.class), mock(UninstallPrompt.class));
final String message = commands.install();
// Verify the values that were provided to the command were passed through to the Install.
verify(mockInstall).install(eq(instanceName), eq(installConfig));
// Verify a message is returned that indicates the success of the operation.
final String expected = "The Rya instance named 'unitTests' has been installed.";
assertEquals(expected, message);
}
use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class MongoRyaShellIT method connectToInstance_noAuths.
@Test
public void connectToInstance_noAuths() throws IOException {
final Bootstrap bootstrap = getTestBootstrap();
final JLineShellComponent shell = getTestShell();
// Connect to the Mongo instance.
String cmd = RyaConnectionCommands.CONNECT_MONGO_CMD + " " + "--hostname " + super.conf.getMongoHostname() + " " + "--port " + super.conf.getMongoPort();
shell.executeCommand(cmd);
// Install an instance of rya.
final String instanceName = "testInstance";
final InstallConfiguration installConf = InstallConfiguration.builder().build();
final ApplicationContext context = bootstrap.getApplicationContext();
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);
CommandResult 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());
}
use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class AccumuloUninstallIT method uninstall.
@Test
public void uninstall() throws Exception {
// Install an instance of Rya.
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).setEnableGeoIndex(true).build();
final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
final RyaClient ryaClient = AccumuloRyaClientFactory.build(connectionDetails, getConnector());
ryaClient.getInstall().install(getRyaInstanceName(), installConfig);
// Check that the instance exists.
assertTrue(ryaClient.getInstanceExists().exists(getRyaInstanceName()));
// Uninstall the instance of Rya.
ryaClient.getUninstall().uninstall(getRyaInstanceName());
// Verify that it no longer exists.
assertFalse(ryaClient.getInstanceExists().exists(getRyaInstanceName()));
}
Aggregations