use of org.apache.rya.shell.util.InstanceNamesFormatter in project incubator-rya by apache.
the class RyaAdminCommands method listInstances.
@CliCommand(value = LIST_INSTANCES_CMD, help = "List the names of the installed Rya instances.")
public String listInstances() {
// Fetch the command that is connected to the store.
final ShellState shellState = state.getShellState();
final RyaClient commands = shellState.getConnectedCommands().get();
final Optional<String> ryaInstance = shellState.getRyaInstanceName();
try {
final List<String> instanceNames = commands.getListInstances().listInstances();
// Return a special message when there are no instances installed.
if (instanceNames.isEmpty()) {
return "There are no Rya instances installed on this storage.";
}
// Sort the names alphabetically.
Collections.sort(instanceNames);
// Return a pretty print of the instances that have been installed.
final String report;
final InstanceNamesFormatter formatter = new InstanceNamesFormatter();
if (ryaInstance.isPresent()) {
report = formatter.format(instanceNames, ryaInstance.get());
} else {
report = formatter.format(instanceNames);
}
return report;
} catch (final RyaClientException e) {
throw new RuntimeException("Can not list the Rya instances. Reason: " + e.getMessage(), e);
}
}
Aggregations