### Question:
RocksDBStoreMBean implements DynamicMBean, MetricsSource { @Override public void getMetrics(MetricsCollector metricsCollector, boolean b) { MetricsRecordBuilder rb = metricsCollector.addRecord(contextName); getHistogramData(rb); getTickerTypeData(rb); } RocksDBStoreMBean(Statistics statistics, String dbName); static RocksDBStoreMBean create(Statistics statistics,
                                         String contextName); @Override Object getAttribute(String attribute); @Override void setAttribute(Attribute attribute); @Override AttributeList getAttributes(String[] attributes); @Override AttributeList setAttributes(AttributeList attributes); @Override Object invoke(String actionName, Object[] params, String[] signature); @Override MBeanInfo getMBeanInfo(); @Override void getMetrics(MetricsCollector metricsCollector, boolean b); final static String ROCKSDB_CONTEXT_PREFIX; }### Answer:
@Test public void testMetricsSystemIntegration() throws Exception { RocksDBStore metadataStore = getTestRocksDBStoreWithData(); Thread.sleep(2000); MetricsSystem ms = DefaultMetricsSystem.instance(); MetricsSource rdbSource = ms.getSource("Rocksdb_TestRocksDBStoreMBean-withstat"); BufferedMetricsCollector metricsCollector = new BufferedMetricsCollector(); rdbSource.getMetrics(metricsCollector, true); Map<String, Double> metrics = metricsCollector.getMetricsRecordBuilder() .getMetrics(); assertTrue(10.0 == metrics.get("NUMBER_KEYS_WRITTEN")); assertTrue(metrics.get("DB_WRITE_AVERAGE") > 0); metadataStore.close(); }