use of io.lumeer.engine.api.data.DataStorageStats in project engine by Lumeer.
the class MongoDbStorage method getCollectionStats.
@Override
public DataStorageStats getCollectionStats(final String collectionName) {
final Document collStats = database.runCommand(Document.parse("{ collStats: \"" + collectionName + "\", scale: 1, verbose: false }"));
final DataStorageStats dss = new DataStorageStats();
final String ns = collStats.getString("ns");
dss.setDatabaseName(ns.substring(0, ns.indexOf(".")));
dss.setCollectionName(ns.substring(ns.indexOf(".") + 1));
dss.setDocuments(collStats.getInteger("count"));
dss.setDataSize(collStats.getInteger("size"));
dss.setStorageSize(collStats.getInteger("storageSize"));
dss.setIndexes(collStats.getInteger("nindexes"));
dss.setIndexSize(collStats.getInteger("totalIndexSize"));
return dss;
}
use of io.lumeer.engine.api.data.DataStorageStats in project engine by Lumeer.
the class MongoDbStorage method getDbStats.
@Override
public DataStorageStats getDbStats() {
final Document dbStats = database.runCommand(Document.parse("{ dbStats: 1, scale: 1 }"));
final DataStorageStats dss = new DataStorageStats();
dss.setDatabaseName(dbStats.getString("db"));
dss.setCollections(dbStats.getInteger("collections"));
dss.setDocuments(dbStats.getInteger("objects"));
dss.setDataSize(dbStats.getDouble("dataSize").longValue());
dss.setStorageSize(dbStats.getDouble("storageSize").longValue());
dss.setIndexes(dbStats.getInteger("indexes"));
dss.setIndexSize(dbStats.getDouble("indexSize").longValue());
return dss;
}
use of io.lumeer.engine.api.data.DataStorageStats in project engine by Lumeer.
the class MongoDbStorageTest method collectionStatsTest.
@Test
public void collectionStatsTest() {
mongoDbStorage.createCollection(COLLECTION_CSTATS);
mongoDbStorage.createDocument(COLLECTION_CSTATS, new DataDocument("stats", 4));
mongoDbStorage.createIndex(COLLECTION_CSTATS, new DataDocument("stats", 1), false);
final DataStorageStats dss = mongoDbStorage.getCollectionStats(COLLECTION_CSTATS);
assertThat(dss.getDatabaseName()).isEqualTo(EmbeddedMongoDb.NAME);
assertThat(dss.getCollectionName()).isEqualTo(COLLECTION_CSTATS);
assertThat(dss.getDocuments()).isEqualTo(1);
assertThat(dss.getIndexes()).isEqualTo(2);
assertThat(dss.getDataSize()).isGreaterThan(0);
assertThat(dss.getStorageSize()).isGreaterThan(0);
assertThat(dss.getIndexSize()).isGreaterThan(0);
mongoDbStorage.dropCollection(COLLECTION_CSTATS);
}
use of io.lumeer.engine.api.data.DataStorageStats in project engine by Lumeer.
the class MongoDbStorageTest method dataStatsTest.
@Test
public void dataStatsTest() {
mongoDbStorage.createCollection(COLLECTION_STATS);
mongoDbStorage.createDocument(COLLECTION_STATS, new DataDocument("stats", 4));
mongoDbStorage.createIndex(COLLECTION_STATS, new DataDocument("stats", 1), false);
final DataStorageStats dss = mongoDbStorage.getDbStats();
assertThat(dss.getDatabaseName()).isEqualTo(EmbeddedMongoDb.NAME);
assertThat(dss.getCollections()).isGreaterThan(0);
assertThat(dss.getDocuments()).isGreaterThan(0);
assertThat(dss.getIndexes()).isGreaterThan(0);
assertThat(dss.getDataSize()).isGreaterThan(0);
assertThat(dss.getStorageSize()).isGreaterThan(0);
assertThat(dss.getIndexSize()).isGreaterThan(0);
mongoDbStorage.dropCollection(COLLECTION_STATS);
}
Aggregations