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));
}
Aggregations