Search in sources :

Example 1 with RyaDetailsFormatter

use of org.apache.rya.shell.util.RyaDetailsFormatter in project incubator-rya by apache.

the class RyaAdminCommands method printInstanceDetails.

@CliCommand(value = PRINT_INSTANCE_DETAILS_CMD, help = "Print information about how the Rya instance is configured.")
public String printInstanceDetails() {
    // Fetch the command that is connected to the store.
    final ShellState shellState = state.getShellState();
    final RyaClient commands = shellState.getConnectedCommands().get();
    final String ryaInstance = shellState.getRyaInstanceName().get();
    try {
        final Optional<RyaDetails> details = commands.getGetInstanceDetails().getDetails(ryaInstance);
        if (details.isPresent()) {
            return new RyaDetailsFormatter().format(shellState.getStorageType().get(), details.get());
        } else {
            return "This instance of Rya does not have a Rya Details table. Consider migrating to a newer version of Rya.";
        }
    } catch (final InstanceDoesNotExistException e) {
        throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstance), e);
    } catch (final RyaClientException e) {
        throw new RuntimeException("Could not get the instance details. Reason: " + e.getMessage(), e);
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) ShellState(org.apache.rya.shell.SharedShellState.ShellState) RyaDetailsFormatter(org.apache.rya.shell.util.RyaDetailsFormatter) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Aggregations

InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)1 RyaClient (org.apache.rya.api.client.RyaClient)1 RyaClientException (org.apache.rya.api.client.RyaClientException)1 RyaDetails (org.apache.rya.api.instance.RyaDetails)1 ShellState (org.apache.rya.shell.SharedShellState.ShellState)1 RyaDetailsFormatter (org.apache.rya.shell.util.RyaDetailsFormatter)1 CliCommand (org.springframework.shell.core.annotation.CliCommand)1