Search in sources :

Example 1 with StorageType

use of org.apache.rya.shell.SharedShellState.StorageType in project incubator-rya by apache.

the class RyaConnectionCommands method printConnectionDetails.

@CliCommand(value = PRINT_CONNECTION_DETAILS_CMD, help = "Print information about the Shell's Rya storage connection.")
public String printConnectionDetails() {
    // Check to see if the shell is connected to any storages.
    final com.google.common.base.Optional<StorageType> storageType = sharedState.getShellState().getStorageType();
    if (!storageType.isPresent()) {
        return "The shell is not connected to anything.";
    }
    // Create a print out based on what it is connected to.
    switch(storageType.get()) {
        case ACCUMULO:
            final AccumuloConnectionDetails accDetails = sharedState.getShellState().getAccumuloDetails().get();
            return "The shell is connected to an instance of Accumulo using the following parameters:\n" + "    Username: " + accDetails.getUsername() + "\n" + "    Instance Name: " + accDetails.getInstanceName() + "\n" + "    Zookeepers: " + accDetails.getZookeepers();
        case MONGO:
            final MongoConnectionDetails mongoDetails = sharedState.getShellState().getMongoDetails().get();
            final StringBuilder message = new StringBuilder().append("The shell is connected to an instance of MongoDB using the following parameters:\n").append("    Hostname: " + mongoDetails.getHostname() + "\n").append("    Port: " + mongoDetails.getPort() + "\n");
            if (mongoDetails.getUsername().isPresent()) {
                message.append("    Username: " + mongoDetails.getUsername().get() + "\n");
            }
            return message.toString();
        default:
            throw new RuntimeException("Unrecognized StorageType: " + storageType.get());
    }
}
Also used : MongoConnectionDetails(org.apache.rya.api.client.mongo.MongoConnectionDetails) StorageType(org.apache.rya.shell.SharedShellState.StorageType) AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Aggregations

AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)1 MongoConnectionDetails (org.apache.rya.api.client.mongo.MongoConnectionDetails)1 StorageType (org.apache.rya.shell.SharedShellState.StorageType)1 CliCommand (org.springframework.shell.core.annotation.CliCommand)1