Search in sources :

Example 1 with CacheState

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));
}
Also used : CacheState(io.pravega.segmentstore.storage.cache.CacheState) Cleanup(lombok.Cleanup) Test(org.junit.Test)

Aggregations

CacheState (io.pravega.segmentstore.storage.cache.CacheState)1 Cleanup (lombok.Cleanup)1 Test (org.junit.Test)1