@Test public void includesAGaugeForDirectCapacity() throws Exception { final Gauge gauge = (Gauge) buffers.getMetrics().get(DIRECT_CAPACITY); when(mBeanServer.getAttribute(direct, "TotalCapacity")).thenReturn(100); assertThat(gauge.getValue()) .isEqualTo(100); }
@Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); for (String pool : POOLS) { for (int i = 0; i < ATTRIBUTES.length; i++) { final String attribute = ATTRIBUTES[i]; final String name = NAMES[i]; try { final ObjectName on = new ObjectName("java.nio:type=BufferPool,name=" + pool); mBeanServerConnection.getMBeanInfo(on); gauges.put(MetricRegistry.name(pool, name), new JmxAttributeGauge(mBeanServerConnection, on, attribute)); } catch (JMException ignored) { LOGGER.debug("Unable to load buffer pool MBeans, possibly running on Java 6"); } catch (IOException ioException) { LOGGER.debug("Unable to load buffer pool MBeans, an exception occur, cause of", ioException); } } } return Collections.unmodifiableMap(gauges); }
BufferPoolMetricSet implements MetricSet { @Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); for (String pool : POOLS) { for (int i = 0; i < ATTRIBUTES.length; i++) { final String attribute = ATTRIBUTES[i]; final String name = NAMES[i]; try { final ObjectName on = new ObjectName("java.nio:type=BufferPool,name=" + pool); mBeanServerConnection.getMBeanInfo(on); gauges.put(MetricRegistry.name(pool, name), new JmxAttributeGauge(mBeanServerConnection, on, attribute)); } catch (JMException ignored) { LOGGER.debug("Unable to load buffer pool MBeans, possibly running on Java 6"); } catch (IOException ioException) { LOGGER.debug("Unable to load buffer pool MBeans, an exception occur, cause of", ioException); } } } return Collections.unmodifiableMap(gauges); } }
BufferPoolMetricSet implements MetricSet { @Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); for (String pool : POOLS) { for (int i = 0; i < ATTRIBUTES.length; i++) { final String attribute = ATTRIBUTES[i]; final String name = NAMES[i]; try { final ObjectName on = new ObjectName("java.nio:type=BufferPool,name=" + pool); mBeanServerConnection.getMBeanInfo(on); gauges.put(MetricRegistry.name(pool, name), new JmxAttributeGauge(mBeanServerConnection, on, attribute)); } catch (JMException ignored) { LOGGER.debug("Unable to load buffer pool MBeans, possibly running on Java 6"); } catch (IOException ioException) { LOGGER.debug("Unable to load buffer pool MBeans, an exception occur, cause of", ioException); } } } return Collections.unmodifiableMap(gauges); } BufferPoolMetricSet(MBeanServerConnection mBeanServerConnection); }
BufferPoolMetricSet implements MetricSet { @Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); for (String pool : POOLS) { for (int i = 0; i < ATTRIBUTES.length; i++) { final String attribute = ATTRIBUTES[i]; final String name = NAMES[i]; try { final ObjectName on = new ObjectName("java.nio:type=BufferPool,name=" + pool); mBeanServerConnection.getMBeanInfo(on); gauges.put(MetricRegistry.name(pool, name), new JmxAttributeGauge(mBeanServerConnection, on, attribute)); } catch (JMException ignored) { LOGGER.debug("Unable to load buffer pool MBeans, possibly running on Java 6"); } catch (IOException ioException) { LOGGER.debug("Unable to load buffer pool MBeans, an exception occur, cause of", ioException); } } } return Collections.unmodifiableMap(gauges); } BufferPoolMetricSet(MBeanServerConnection mBeanServerConnection); @Override Map<MetricName, Metric> getMetrics(); @Override long lastUpdateTime(); }
BufferPoolMetricSet implements MetricSet { @Override public Map<MetricName, Metric> getMetrics() { final Map<MetricName, Metric> gauges = new HashMap<MetricName, Metric>(); for (String pool : POOLS) { for (int i = 0; i < ATTRIBUTES.length; i++) { final String attribute = ATTRIBUTES[i]; final String name = NAMES[i]; try { final ObjectName on = new ObjectName("java.nio:type=BufferPool,name=" + pool); mBeanServerConnection.getMBeanInfo(on); gauges.put(MetricRegistry.name(pool, name), new JmxAttributeGauge(mBeanServerConnection, on, attribute)); } catch (JMException ignored) { LOGGER.debug("Unable to load buffer pool MBeans, possibly running on Java 6"); } catch (IOException ioException) { LOGGER.debug("Unable to load buffer pool MBeans, an exception occur, cause of", ioException); } } } return Collections.unmodifiableMap(gauges); } BufferPoolMetricSet(MBeanServerConnection mBeanServerConnection); @Override Map<MetricName, Metric> getMetrics(); @Override long lastUpdateTime();  }