RegionPerfStats extends CachePerfStats implements RegionStats { @Override protected void close() { meterRegistry.remove(entriesGauge); entriesGauge.close(); meterRegistry.remove(cacheGetsHitTimer); cacheGetsHitTimer.close(); meterRegistry.remove(cacheGetsMissTimer); cacheGetsMissTimer.close(); super.close(); } RegionPerfStats(StatisticsFactory statisticsFactory, String textId, CachePerfStats cachePerfStats,
      InternalRegion region, MeterRegistry meterRegistry, StatisticsClock clock); @VisibleForTesting  RegionPerfStats(StatisticsFactory statisticsFactory, String textId, StatisticsClock clock,
      CachePerfStats cachePerfStats, InternalRegion region, MeterRegistry meterRegistry); @VisibleForTesting  RegionPerfStats(StatisticsFactory statisticsFactory, String textId, StatisticsClock clock,
      CachePerfStats cachePerfStats, InternalRegion region, MeterRegistry meterRegistry,
      Gauge entriesGauge, Timer cacheGetsHitTimer, Timer cacheGetsMissTimer); @Override void incReliableQueuedOps(int inc); @Override void incReliableQueueSize(int inc); @Override void incReliableQueueMax(int inc); @Override void incReliableRegions(int inc); @Override void incReliableRegionsMissing(int inc); @Override void incReliableRegionsQueuing(int inc); @Override void incReliableRegionsMissingFullAccess(int inc); @Override void incReliableRegionsMissingLimitedAccess(int inc); @Override void incReliableRegionsMissingNoAccess(int inc); @Override void incQueuedEvents(int inc); @Override long startLoad(); @Override void endLoad(long start); @Override long startNetload(); @Override void endNetload(long start); @Override long startNetsearch(); @Override void endNetsearch(long start); @Override long startCacheWriterCall(); @Override void endCacheWriterCall(long start); @Override long startCacheListenerCall(); @Override void endCacheListenerCall(long start); @Override long startGetInitialImage(); @Override void endGetInitialImage(long start); @Override void endNoGIIDone(long start); @Override void incGetInitialImageKeysReceived(); @Override long startIndexUpdate(); @Override void endIndexUpdate(long start); @Override void incRegions(int inc); @Override void incPartitionedRegions(int inc); @Override void incDestroys(); @Override void incCreates(); @Override void incInvalidates(); @Override void incTombstoneCount(int amount); @Override void incTombstoneGCCount(); @Override void incClearTimeouts(); @Override void incConflatedEventsCount(); @Override void endGet(long start, boolean miss); @Override void endGetForClient(long start, boolean miss); @Override long endPut(long start, boolean isUpdate); @Override void endPutAll(long start); @Override void endQueryExecution(long executionTime); @Override void endQueryResultsHashCollisionProbe(long start); @Override void incQueryResultsHashCollisions(); @Override void incTxConflictCheckTime(long delta); @Override void txSuccess(long opTime, long txLifeTime, int txChanges); @Override void txFailure(long opTime, long txLifeTime, int txChanges); @Override void txRollback(long opTime, long txLifeTime, int txChanges); @Override void incEventQueueSize(int items); @Override void incEventQueueThrottleCount(int items); @Override void incEventQueueThrottleTime(long nanos); @Override void incEventThreads(int items); @Override void incEntryCount(int delta); @Override void incRetries(); @Override void incDiskTasksWaiting(); @Override void decDiskTasksWaiting(); @Override void decDiskTasksWaiting(int count); @Override void incEvictorJobsStarted(); @Override void incEvictorJobsCompleted(); @Override void incEvictorQueueSize(int delta); @Override void incEvictWorkTime(long delta); @Override void incClearCount(); @Override void incPRQueryRetries(); @Override void incMetaDataRefreshCount(); @Override void endImport(long entryCount, long start); @Override void endExport(long entryCount, long start); @Override long startCompression(); @Override void endCompression(long startTime, long startSize, long endSize); @Override long startDecompression(); @Override void endDecompression(long startTime);  }
@Test public void close_removesEntriesGaugeFromTheRegistry() { assertThat(metersNamed("geode.cache.entries")) .as("entries gauge before closing the stats") .hasSize(1); regionPerfStats.close(); assertThat(metersNamed("geode.cache.entries")) .as("entries gauge after closing the stats") .hasSize(0); regionPerfStats = null; }
@Test public void close_removesCacheGetsTimersFromTheRegistry() { assertThat(metersNamed("geode.cache.gets")) .as("cache gets timer before closing the stats") .hasSize(2); regionPerfStats.close(); assertThat(metersNamed("geode.cache.gets")) .as("cache gets timer after closing the stats") .hasSize(0); regionPerfStats = null; }
@Test public void close_doesNotRemoveMetersItDoesNotOwn() { String foreignMeterName = "some.meter.not.created.by.the.gateway.receiver.stats"; Timer.builder(foreignMeterName) .register(meterRegistry); regionPerfStats.close(); assertThat(metersNamed(foreignMeterName)) .as("foreign meter after closing the stats") .hasSize(1); regionPerfStats = null; }
@Test public void close_closesMeters() { Gauge entriesGauge = mock(Gauge.class); Timer cacheGetsHitTimer = mock(Timer.class); Timer cacheGetsMissTimer = mock(Timer.class); regionPerfStats = new RegionPerfStats(statisticsFactory, TEXT_ID, statisticsClock, cachePerfStats, region, mock(MeterRegistry.class), entriesGauge, cacheGetsHitTimer, cacheGetsMissTimer); regionPerfStats.close(); verify(entriesGauge).close(); verify(cacheGetsHitTimer).close(); verify(cacheGetsMissTimer).close(); regionPerfStats = null; }