test_class.declarator: executorService = Executors.newSingleThreadScheduledExecutor()
test_class.modifier: private
test_class.original_string: private ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
test_class.type: ScheduledExecutorService
test_class.var_name: executorService
test_class.declarator: statsProvider = new DefaultStatisticsProvider(executorService)
test_class.modifier: private
test_class.original_string: private StatisticsProvider statsProvider = new DefaultStatisticsProvider(executorService);
test_class.type: StatisticsProvider
test_class.var_name: statsProvider
test_class.file: oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStoreMetricsTest.java
test_class.identifier: MongoDocumentStoreMetricsTest
test_class.superclass: extends AbstractMongoConnectionTest
test_case.body: @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));
  
              // document for root node
              assertEquals(1, getCount("MongoDB.nodes.count"));
              // one cluster node
              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();
          }
      }
test_case.class_method_signature: MongoDocumentStoreMetricsTest.updateCounters()
test_case.full_signature: @Test public void updateCounters()
test_case.identifier: updateCounters
test_case.invocations: getConnection assumeNotNull getMongoClient getDatabase newMongoDocumentNodeStoreBuilder assertEquals getCount assertEquals getCount run assertThat getCount greaterThan assertThat getCount greaterThan assertEquals getCount assertEquals getCount add assertTrue create run assertEquals getCount dispose
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void updateCounters()
focal_class.declarator: LOG = LoggerFactory.getLogger(MongoDocumentStoreMetrics.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(MongoDocumentStoreMetrics.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: COLLECTIONS = ImmutableList.of(
              Collection.NODES, Collection.JOURNAL, Collection.CLUSTER_NODES, Collection.SETTINGS, Collection.BLOBS
      )
focal_class.modifier: private static final
focal_class.original_string: private static final ImmutableList<Collection<? extends Document>> COLLECTIONS = ImmutableList.of(
              Collection.NODES, Collection.JOURNAL, Collection.CLUSTER_NODES, Collection.SETTINGS, Collection.BLOBS
      );
focal_class.type: ImmutableList<Collection<? extends Document>>
focal_class.var_name: COLLECTIONS
focal_class.declarator: db
focal_class.modifier: private final
focal_class.original_string: private final MongoDatabase db;
focal_class.type: MongoDatabase
focal_class.var_name: db
focal_class.declarator: statsProvider
focal_class.modifier: private final
focal_class.original_string: private final StatisticsProvider statsProvider;
focal_class.type: StatisticsProvider
focal_class.var_name: statsProvider
focal_class.file: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStoreMetrics.java
focal_class.identifier: MongoDocumentStoreMetrics
focal_class.interfaces: implements Runnable
focal_class.class_method_signature: MongoDocumentStoreMetrics.MongoDocumentStoreMetrics(MongoDocumentStore store,
                                       StatisticsProvider statsProvider)
focal_class.full_signature: public  MongoDocumentStoreMetrics(MongoDocumentStore store,
                                       StatisticsProvider statsProvider)
focal_class.identifier: MongoDocumentStoreMetrics
focal_class.modifiers: public
focal_class.parameters: (MongoDocumentStore store,
                                       StatisticsProvider statsProvider)
focal_class.signature:  MongoDocumentStoreMetrics(MongoDocumentStore store,
                                       StatisticsProvider statsProvider)
focal_class.class_method_signature: MongoDocumentStoreMetrics.run()
focal_class.full_signature: @Override public void run()
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_class.class_method_signature: MongoDocumentStoreMetrics.updateCounters()
focal_class.full_signature: private void updateCounters()
focal_class.identifier: updateCounters
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void updateCounters()
focal_class.class_method_signature: MongoDocumentStoreMetrics.updateCounter(CounterStats counter, long value)
focal_class.full_signature: private void updateCounter(CounterStats counter, long value)
focal_class.identifier: updateCounter
focal_class.modifiers: private
focal_class.parameters: (CounterStats counter, long value)
focal_class.return: void
focal_class.signature: void updateCounter(CounterStats counter, long value)
focal_class.class_method_signature: MongoDocumentStoreMetrics.getStats(Collection<? extends Document> c)
focal_class.full_signature: private CollectionStats getStats(Collection<? extends Document> c)
focal_class.identifier: getStats
focal_class.modifiers: private
focal_class.parameters: (Collection<? extends Document> c)
focal_class.return: CollectionStats
focal_class.signature: CollectionStats getStats(Collection<? extends Document> c)
focal_class.class_method_signature: MongoDocumentStoreMetrics.getDBStats()
focal_class.full_signature: private DatabaseStats getDBStats()
focal_class.identifier: getDBStats
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: DatabaseStats
focal_class.signature: DatabaseStats getDBStats()
focal_class.class_method_signature: MongoDocumentStoreMetrics.getCounter(Collection<? extends Document> c,
                                      String name)
focal_class.full_signature: private CounterStats getCounter(Collection<? extends Document> c,
                                      String name)
focal_class.identifier: getCounter
focal_class.modifiers: private
focal_class.parameters: (Collection<? extends Document> c,
                                      String name)
focal_class.return: CounterStats
focal_class.signature: CounterStats getCounter(Collection<? extends Document> c,
                                      String name)
focal_class.class_method_signature: MongoDocumentStoreMetrics.getDBCounter(String name)
focal_class.full_signature: private CounterStats getDBCounter(String name)
focal_class.identifier: getDBCounter
focal_class.modifiers: private
focal_class.parameters: (String name)
focal_class.return: CounterStats
focal_class.signature: CounterStats getDBCounter(String name)
focal_method.body: 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());
          }
      }
focal_method.class_method_signature: MongoDocumentStoreMetrics.updateCounters()
focal_method.full_signature: private void updateCounters()
focal_method.identifier: updateCounters
focal_method.invocations: debug into listCollectionNames contains toString debug getStats updateCounter getCounter updateCounter getCounter updateCounter getCounter updateCounter getCounter getDBStats updateCounter getDBCounter updateCounter getDBCounter warn toString
focal_method.modifiers: private
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void updateCounters()