use of io.pravega.segmentstore.storage.cache.CacheState in project pravega by pravega.
the class SegmentStoreMetricsTests method testCacheManagerMetrics.
@Test
public void testCacheManagerMetrics() {
long storedBytes = 10000;
long usedBytes = 1000;
long allocatedBytes = 100;
int generationSpread = 10;
long managerIterationDuration = 1;
@Cleanup SegmentStoreMetrics.CacheManager cache = new SegmentStoreMetrics.CacheManager();
cache.report(new CacheState(storedBytes, usedBytes, 0, allocatedBytes, storedBytes), generationSpread, managerIterationDuration);
assertEquals(storedBytes, (long) MetricRegistryUtils.getGauge(MetricsNames.CACHE_STORED_SIZE_BYTES).value());
assertEquals(usedBytes, (long) MetricRegistryUtils.getGauge(MetricsNames.CACHE_USED_SIZE_BYTES).value());
assertEquals(allocatedBytes, (long) MetricRegistryUtils.getGauge(MetricsNames.CACHE_ALLOC_SIZE_BYTES).value());
assertEquals(generationSpread, (int) MetricRegistryUtils.getGauge(MetricsNames.CACHE_GENERATION_SPREAD).value());
assertEquals(managerIterationDuration, (long) MetricRegistryUtils.getTimer(MetricsNames.CACHE_MANAGER_ITERATION_DURATION).mean(TimeUnit.MILLISECONDS));
cache.close();
assertNull(MetricRegistryUtils.getGauge(MetricsNames.CACHE_STORED_SIZE_BYTES));
assertNull(MetricRegistryUtils.getGauge(MetricsNames.CACHE_USED_SIZE_BYTES));
assertNull(MetricRegistryUtils.getGauge(MetricsNames.CACHE_ALLOC_SIZE_BYTES));
assertNull(MetricRegistryUtils.getGauge(MetricsNames.CACHE_GENERATION_SPREAD));
assertNull(MetricRegistryUtils.getTimer(MetricsNames.CACHE_MANAGER_ITERATION_DURATION));
}
Aggregations