@Override public long get() { return getInstance().get(); } }
s.create(segmentName, TIMEOUT).join(); long expectedMetricsSize = FileSystemMetrics.WRITE_BYTES.get(); long expectedMetricsSuccesses = FileSystemMetrics.WRITE_LATENCY.toOpStatsData().getNumSuccessfulEvents(); expectedMetricsSize, FileSystemMetrics.WRITE_BYTES.get()); Assert.assertEquals("WRITE_LATENCY should not increase the count of successful events in case of unsuccessful writes", expectedMetricsSuccesses, FileSystemMetrics.WRITE_LATENCY.toOpStatsData().getNumSuccessfulEvents()); expectedMetricsSuccesses, FileSystemMetrics.WRITE_LATENCY.toOpStatsData().getNumSuccessfulEvents()); Assert.assertEquals("WRITE_BYTES should increase by the size of successful writes", expectedMetricsSize, FileSystemMetrics.WRITE_BYTES.get()); ex -> ex instanceof BadOffsetException); Assert.assertEquals("WRITE_BYTES should not change in case of unsuccessful writes", expectedMetricsSize, FileSystemMetrics.WRITE_BYTES.get()); Assert.assertEquals("WRITE_LATENCY should not increase the count of successful events in case of unsuccessful writes", expectedMetricsSuccesses, FileSystemMetrics.WRITE_LATENCY.toOpStatsData().getNumSuccessfulEvents()); ex -> ex instanceof StreamSegmentNotExistsException); Assert.assertEquals("WRITE_BYTES should not change in case of unsuccessful writes", expectedMetricsSize, FileSystemMetrics.WRITE_BYTES.get()); Assert.assertEquals("WRITE_LATENCY should not increase the count of successful events in case of unsuccessful writes", expectedMetricsSuccesses, FileSystemMetrics.WRITE_LATENCY.toOpStatsData().getNumSuccessfulEvents());
/** * Test counter registered and worked well with StatsLogger. */ @Test public void testCounter() { Counter testCounter = statsLogger.createCounter("testCounter"); testCounter.add(17); assertEquals(17, testCounter.get()); // test dynamic counter int sum = 0; for (int i = 1; i < 10; i++) { sum += i; dynamicLogger.incCounterValue("dynamicCounter", i); assertEquals(sum, MetricRegistryUtils.getCounter("pravega.dynamicCounter.Counter").getCount()); } dynamicLogger.freezeCounter("dynamicCounter"); assertEquals(null, MetricRegistryUtils.getCounter("pravega.dynamicCounter.Counter")); }
/** * Test transition back to null provider. */ @Test public void testTransitionBackToNullProvider() { MetricsConfig config = MetricsConfig.builder() .with(MetricsConfig.ENABLE_STATISTICS, false) .build(); MetricsProvider.initialize(config); Counter counter = statsLogger.createCounter("continuity-counter"); counter.add(1L); assertEquals(0L, counter.get()); config = MetricsConfig.builder() .with(MetricsConfig.ENABLE_STATISTICS, true) .build(); MetricsProvider.initialize(config); counter.add(1L); assertEquals(1L, counter.get()); } }