@SuppressWarnings("unchecked") @Test public void testNginxWithNoData() { String data0 = "Active connections: 1\n" + "server accepts handled requests request_time\n" + " 65355 65355 56195 37545\n" + "ssl new reused(SID+ticket)\n" + " 0 0\n" + "Reading: 0 Writing: 1 Waiting: 0\n" + "SSL_Requests: 0 SSL_Handshake: 0 SSL_Handshake_Time: 0"; String data1 = "Active connections: 1\n" + "server accepts handled requests request_time\n" + " 65357 65357 56197 37549\n" + "ssl new reused(SID+ticket)\n" + " 0 0\n" + "Reading: 0 Writing: 1 Waiting: 0\n" + "SSL_Requests: 0 SSL_Handshake: 0 SSL_Handshake_Time: 0"; String data2 = ""; ManualClock clock = new ManualClock(); TestNginxGaugeSet nginxGaugeSet = new TestNginxGaugeSet(clock); Map<MetricName, Metric> metrics = nginxGaugeSet.getMetrics(); Assert.assertEquals(8, metrics.keySet().size()); clock.addMillis(1000); nginxGaugeSet.setData(data0); Gauge<Double> connAccepted = (Gauge<Double>)metrics.get(MetricName.build("conn.accepted")); Gauge<Double> connHandled = (Gauge<Double>)metrics.get(MetricName.build("conn.handled")); Gauge<Double> reqQps = (Gauge<Double>)metrics.get(MetricName.build("request.qps")); Gauge<Double> reqAvgRt = (Gauge<Double>)metrics.get(MetricName.build("request.avg_rt")); Gauge<Long> connActive = (Gauge<Long>)metrics.get(MetricName.build("conn.active")); Gauge<Long> connReading = (Gauge<Long>)metrics.get(MetricName.build("conn.reading")); Gauge<Long> connWriting = (Gauge<Long>)metrics.get(MetricName.build("conn.writing")); Gauge<Long> connWaiting = (Gauge<Long>)metrics.get(MetricName.build("conn.waiting")); Assert.assertEquals(0.0d, connAccepted.getValue(), 0.0001d); clock.addMillis(1000); nginxGaugeSet.setData(data1); Assert.assertEquals(2.0d, connAccepted.getValue(), 0.0001d); Assert.assertEquals(0L, connWaiting.getValue().longValue()); clock.addMillis(1000); nginxGaugeSet.setData(data2); Assert.assertEquals(0d, connAccepted.getValue(), 0.0001d); Assert.assertEquals(0d, connHandled.getValue(), 0.0001d); Assert.assertEquals(0d, reqQps.getValue(), 0.0001d); Assert.assertEquals(0d, reqAvgRt.getValue(), 0.0001d); Assert.assertEquals(0L, connActive.getValue().longValue()); Assert.assertEquals(0L, connReading.getValue().longValue()); Assert.assertEquals(0L, connWriting.getValue().longValue()); Assert.assertEquals(0L, connWaiting.getValue().longValue()); }
@Override public Map<MetricName, Metric> getMetrics() { return metrics; }
NginxGaugeSet extends CachedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { return metrics; } }
NginxGaugeSet extends CachedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { return metrics; } NginxGaugeSet();  NginxGaugeSet(long dataTTL, TimeUnit unit);  NginxGaugeSet(String nginxHost, int nginxPort, String statusPath, String statusHost,
                         long dataTTL, TimeUnit unit, Clock clock); }
NginxGaugeSet extends CachedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { return metrics; } NginxGaugeSet();  NginxGaugeSet(long dataTTL, TimeUnit unit);  NginxGaugeSet(String nginxHost, int nginxPort, String statusPath, String statusHost,
                         long dataTTL, TimeUnit unit, Clock clock); @Override Map<MetricName, Metric> getMetrics(); }
NginxGaugeSet extends CachedMetricSet { @Override public Map<MetricName, Metric> getMetrics() { return metrics; } NginxGaugeSet();  NginxGaugeSet(long dataTTL, TimeUnit unit);  NginxGaugeSet(String nginxHost, int nginxPort, String statusPath, String statusHost,
                         long dataTTL, TimeUnit unit, Clock clock); @Override Map<MetricName, Metric> getMetrics();  }