@Test public void updateCounters() { MongoConnection connection = connectionFactory.getConnection(); assumeNotNull(connection); MongoDocumentStore store = new MongoDocumentStore( connection.getMongoClient(), connection.getDatabase(), newMongoDocumentNodeStoreBuilder()); try { MongoDocumentStoreMetrics metrics = new MongoDocumentStoreMetrics(store, statsProvider); assertEquals(0, getCount("MongoDB.fsUsedSize")); assertEquals(0, getCount("MongoDB.fsTotalSize")); metrics.run(); assertThat(getCount("MongoDB.fsUsedSize"), greaterThan(0L)); assertThat(getCount("MongoDB.fsTotalSize"), greaterThan(0L)); assertEquals(1, getCount("MongoDB.nodes.count")); assertEquals(1, getCount("MongoDB.clusterNodes.count")); List<UpdateOp> updates = new ArrayList<>(); for (int i = 0; i < 10; i++) { updates.add(new UpdateOp("id-" + i, true)); } assertTrue(store.create(Collection.NODES, updates)); metrics.run(); assertEquals(11, getCount("MongoDB.nodes.count")); } finally { store.dispose(); } }
private void updateCounters() { LOG.debug("Updating counters"); try { Set<String> collectionNames = new TreeSet<>(); db.listCollectionNames().into(collectionNames); for (Collection<? extends Document> c : COLLECTIONS) { if (!collectionNames.contains(c.toString())) { LOG.debug("Collection {} does not exist", c); continue; } CollectionStats stats = getStats(c); updateCounter(getCounter(c, "count"), stats.count); updateCounter(getCounter(c, "size"), stats.size); updateCounter(getCounter(c, "storageSize"), stats.storageSize); updateCounter(getCounter(c, "totalIndexSize"), stats.totalIndexSize); } DatabaseStats dbStats = getDBStats(); updateCounter(getDBCounter("fsUsedSize"), dbStats.fsUsedSize); updateCounter(getDBCounter("fsTotalSize"), dbStats.fsTotalSize); } catch (MongoException e) { LOG.warn("Updating counters failed: {}", e.toString()); } }
MongoDocumentStoreMetrics implements Runnable { private void updateCounters() { LOG.debug("Updating counters"); try { Set<String> collectionNames = new TreeSet<>(); db.listCollectionNames().into(collectionNames); for (Collection<? extends Document> c : COLLECTIONS) { if (!collectionNames.contains(c.toString())) { LOG.debug("Collection {} does not exist", c); continue; } CollectionStats stats = getStats(c); updateCounter(getCounter(c, "count"), stats.count); updateCounter(getCounter(c, "size"), stats.size); updateCounter(getCounter(c, "storageSize"), stats.storageSize); updateCounter(getCounter(c, "totalIndexSize"), stats.totalIndexSize); } DatabaseStats dbStats = getDBStats(); updateCounter(getDBCounter("fsUsedSize"), dbStats.fsUsedSize); updateCounter(getDBCounter("fsTotalSize"), dbStats.fsTotalSize); } catch (MongoException e) { LOG.warn("Updating counters failed: {}", e.toString()); } } }
MongoDocumentStoreMetrics implements Runnable { private void updateCounters() { LOG.debug("Updating counters"); try { Set<String> collectionNames = new TreeSet<>(); db.listCollectionNames().into(collectionNames); for (Collection<? extends Document> c : COLLECTIONS) { if (!collectionNames.contains(c.toString())) { LOG.debug("Collection {} does not exist", c); continue; } CollectionStats stats = getStats(c); updateCounter(getCounter(c, "count"), stats.count); updateCounter(getCounter(c, "size"), stats.size); updateCounter(getCounter(c, "storageSize"), stats.storageSize); updateCounter(getCounter(c, "totalIndexSize"), stats.totalIndexSize); } DatabaseStats dbStats = getDBStats(); updateCounter(getDBCounter("fsUsedSize"), dbStats.fsUsedSize); updateCounter(getDBCounter("fsTotalSize"), dbStats.fsTotalSize); } catch (MongoException e) { LOG.warn("Updating counters failed: {}", e.toString()); } } MongoDocumentStoreMetrics(MongoDocumentStore store,
                                     StatisticsProvider statsProvider); }
MongoDocumentStoreMetrics implements Runnable { private void updateCounters() { LOG.debug("Updating counters"); try { Set<String> collectionNames = new TreeSet<>(); db.listCollectionNames().into(collectionNames); for (Collection<? extends Document> c : COLLECTIONS) { if (!collectionNames.contains(c.toString())) { LOG.debug("Collection {} does not exist", c); continue; } CollectionStats stats = getStats(c); updateCounter(getCounter(c, "count"), stats.count); updateCounter(getCounter(c, "size"), stats.size); updateCounter(getCounter(c, "storageSize"), stats.storageSize); updateCounter(getCounter(c, "totalIndexSize"), stats.totalIndexSize); } DatabaseStats dbStats = getDBStats(); updateCounter(getDBCounter("fsUsedSize"), dbStats.fsUsedSize); updateCounter(getDBCounter("fsTotalSize"), dbStats.fsTotalSize); } catch (MongoException e) { LOG.warn("Updating counters failed: {}", e.toString()); } } MongoDocumentStoreMetrics(MongoDocumentStore store,
                                     StatisticsProvider statsProvider); @Override void run(); }
MongoDocumentStoreMetrics implements Runnable { private void updateCounters() { LOG.debug("Updating counters"); try { Set<String> collectionNames = new TreeSet<>(); db.listCollectionNames().into(collectionNames); for (Collection<? extends Document> c : COLLECTIONS) { if (!collectionNames.contains(c.toString())) { LOG.debug("Collection {} does not exist", c); continue; } CollectionStats stats = getStats(c); updateCounter(getCounter(c, "count"), stats.count); updateCounter(getCounter(c, "size"), stats.size); updateCounter(getCounter(c, "storageSize"), stats.storageSize); updateCounter(getCounter(c, "totalIndexSize"), stats.totalIndexSize); } DatabaseStats dbStats = getDBStats(); updateCounter(getDBCounter("fsUsedSize"), dbStats.fsUsedSize); updateCounter(getDBCounter("fsTotalSize"), dbStats.fsTotalSize); } catch (MongoException e) { LOG.warn("Updating counters failed: {}", e.toString()); } } MongoDocumentStoreMetrics(MongoDocumentStore store,
                                     StatisticsProvider statsProvider); @Override void run();  }