/** * remove a partitioned region from the set of tracked instances. * * @see #addPartitionedRegion(PartitionedRegion) */ @Override public void removePartitionedRegion(PartitionedRegion region) { synchronized (this.partitionedRegions) { if (this.partitionedRegions.remove(region)) { getCachePerfStats().incPartitionedRegions(-1); } } }
/** * add a partitioned region to the set of tracked partitioned regions. This is used to notify the * regions when this cache requires, or does not require notification of all region/entry events. */ @Override public void addPartitionedRegion(PartitionedRegion region) { synchronized (this.partitionedRegions) { if (region.isDestroyed()) { if (logger.isDebugEnabled()) { logger.debug("GemFireCache#addPartitionedRegion did not add destroyed {}", region); } return; } if (this.partitionedRegions.add(region)) { getCachePerfStats().incPartitionedRegions(1); } } }
when(cache.getDistributionManager()).thenReturn(distributionManager); when(cache.getCancelCriterion()).thenReturn(systemCancelCriterion); when(cache.getCachePerfStats()).thenReturn(mock(CachePerfStats.class)); when(cache.getSecurityService()).thenReturn(mock(SecurityService.class)); when(cache.createPdxInstanceFactory(any())).thenReturn(pdxInstanceFactory);
/** * Tests invalidating a region entry */ @Test public void testInvalidateEntry() throws CacheException { String name = this.getUniqueName(); Object key = "KEY"; Object value = "VALUE"; Region region = createRegion(name); region.put(key, value); int beforeInvalidates = ((org.apache.geode.internal.cache.GemFireCacheImpl) getCache()) .getCachePerfStats().getInvalidates(); Region.Entry entry = region.getEntry(key); region.invalidate(key); if (entry.isLocal()) { assertNull(entry.getValue()); } assertNull(region.get(key)); int afterInvalidates = ((org.apache.geode.internal.cache.GemFireCacheImpl) getCache()) .getCachePerfStats().getInvalidates(); assertEquals("Invalidate CachePerfStats incorrect", beforeInvalidates + 1, afterInvalidates); }
int prSize = -this.partitionedRegions.size(); this.partitionedRegions.clear(); getCachePerfStats().incPartitionedRegions(prSize);
int puts = ((GemFireCacheImpl) pr.getCache()).getCachePerfStats().getPuts(); boolean success = pr.replace("otherKeyForNull", null, "no longer invalid"); assertTrue(success); int newputs = ((GemFireCacheImpl) pr.getCache()).getCachePerfStats().getPuts(); assertEquals("stats not updated properly or replace malfunctioned", newputs, puts + 1);