Utils.markOkay(response);
return response;
}
private BSONObject commandDatabaseStats() throws MongoServerException {
BSONObject response = new BasicBSONObject("db", getDatabaseName());
response.put("collections", Integer.valueOf(namespaces.count()));
long indexSize = 0;
long objects = 0;
long dataSize = 0;
double averageObjectSize = 0;
for (MongoCollection collection : collections.values()) {
BSONObject stats = collection.getStats();
objects += ((Number) stats.get("count")).longValue();
dataSize += ((Number) stats.get("size")).longValue();
BSONObject indexSizes = (BSONObject) stats.get("indexSize");
for (String indexName : indexSizes.keySet()) {
indexSize += ((Number) indexSizes.get(indexName)).longValue();
}
}
if (objects > 0) {
averageObjectSize = dataSize / ((double) objects);
}
response.put("objects", Long.valueOf(objects));
response.put("avgObjSize", Double.valueOf(averageObjectSize));
response.put("dataSize", Long.valueOf(dataSize));
response.put("storageSize", Long.valueOf(0));
response.put("numExtents", Integer.valueOf(0));
response.put("indexes", Integer.valueOf(indexes.count()));
response.put("indexSize", Long.valueOf(indexSize));
response.put("fileSize", Integer.valueOf(0));
response.put("nsSizeMB", Integer.valueOf(0));
Utils.markOkay(response);
return response;
}