Search in sources :

Example 1 with DatabaseEntry

use of com.torodb.mongodb.commands.signatures.diagnostic.ListDatabasesCommand.ListDatabasesReply.DatabaseEntry in project torodb by torodb.

the class ListDatabasesImplementation method apply.

@Override
public Status<ListDatabasesReply> apply(Request req, Command<? super Empty, ? super ListDatabasesReply> command, Empty arg, MongodTransaction context) {
    List<String> databases = context.getTorodTransaction().getDatabases();
    long totalSize = 0;
    List<DatabaseEntry> databaseEntries = Lists.newArrayListWithCapacity(databases.size());
    for (String databaseName : databases) {
        long databaseSize = context.getTorodTransaction().getDatabaseSize(databaseName);
        databaseEntries.add(new DatabaseEntry(databaseName, databaseSize, databaseSize == 0));
        totalSize += databaseSize;
    }
    return Status.ok(new ListDatabasesReply(ImmutableList.copyOf(databaseEntries), totalSize));
}
Also used : DatabaseEntry(com.torodb.mongodb.commands.signatures.diagnostic.ListDatabasesCommand.ListDatabasesReply.DatabaseEntry) ListDatabasesReply(com.torodb.mongodb.commands.signatures.diagnostic.ListDatabasesCommand.ListDatabasesReply)

Aggregations

ListDatabasesReply (com.torodb.mongodb.commands.signatures.diagnostic.ListDatabasesCommand.ListDatabasesReply)1 DatabaseEntry (com.torodb.mongodb.commands.signatures.diagnostic.ListDatabasesCommand.ListDatabasesReply.DatabaseEntry)1