public RemoteEntrySnapshot(Region.Entry entry, boolean statsEnabled) throws CacheException { Object entryName = entry.getKey(); if (entryName instanceof String || entryName instanceof Number) { name = entryName; } else { name = new RemoteObjectName(entryName); } Object val = entry.getValue(); if (val != null) { this.value = val.getClass().getName() + "\"" + val.toString() + "\""; } else { this.value = null; } Object attr = entry.getUserAttribute(); if (attr != null) { this.userAttribute = attr.getClass().getName() + "\"" + attr.toString() + "\""; } else { this.userAttribute = null; } if (statsEnabled) { this.stats = new RemoteCacheStatistics(entry.getStatistics()); } else { this.stats = new RemoteCacheStatistics(); } } /**
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); CacheStatistics stats = region.getEntry(key).getStatistics(); assertEquals(lastAccessed, stats.getLastAccessedTime()); assertEquals(lastModified, stats.getLastModifiedTime()); assertEquals(0, stats.getHitCount()); assertEquals(0, stats.getMissCount()); } });
public RemoteEntrySnapshot(Region.Entry entry, boolean statsEnabled) throws CacheException { Object entryName = entry.getKey(); if (entryName instanceof String || entryName instanceof Number) { name = entryName; } else { name = new RemoteObjectName(entryName); } Object val = entry.getValue(); if (val != null) { this.value = val.getClass().getName() + "\"" + val.toString() + "\""; } else { this.value = null; } Object attr = entry.getUserAttribute(); if (attr != null) { this.userAttribute = attr.getClass().getName() + "\"" + attr.toString() + "\""; } else { this.userAttribute = null; } if (statsEnabled) { this.stats = new RemoteCacheStatistics(entry.getStatistics()); } else { this.stats = new RemoteCacheStatistics(); } } /**
assertNotNull(entry); if (attributes.getStatisticsEnabled()) { assertNotNull(entry.getStatistics());
assertEquals(0, rStats.getMissCount()); CacheStatistics eStats = region.getEntry(key).getStatistics(); assertEquals(0, eStats.getHitCount()); assertEquals(0, eStats.getMissCount()); CacheStatistics e3Stats = region.getEntry(key3).getStatistics(); assertEquals(0, e3Stats.getHitCount()); assertEquals(0, e3Stats.getMissCount());
before = ((GemFireCacheImpl)getCache()).cacheTimeMillis(); region.put(key, value); CacheStatistics eStats = region.getEntry(key).getStatistics(); after = ((GemFireCacheImpl)getCache()).cacheTimeMillis(); assertInRange(before, after, rStats.getLastAccessedTime()); before = ((GemFireCacheImpl)getCache()).cacheTimeMillis(); region.create(key2, null); CacheStatistics eStats2 = region.getEntry(key2).getStatistics(); after = ((GemFireCacheImpl)getCache()).cacheTimeMillis(); assertInRange(before, after, rStats.getLastAccessedTime());
entry.getStatistics(); fail("Should have thrown an EntryDestroyedException");
entry.getStatistics(); fail("Should have thrown an EntryDestroyedException");
/** * Returns whether the entry at the key is valid. If it should have expired * but hasn't, log a warning. * @param region * @param key * @return */ private static boolean isValid(Region region, Serializable key) { boolean valid = true; Region.Entry entry = region.getEntry(key); if (entry != null) { CacheStatistics statistics = entry.getStatistics(); GemFireCacheImpl cache = (GemFireCacheImpl) region.getCache(); long msSinceLastAccessed = cache.cacheTimeMillis() - statistics.getLastAccessedTime(); long timeout = region.getAttributes().getEntryIdleTimeout().getTimeout() * 1000; if (msSinceLastAccessed > timeout) { StringBuilder builder = new StringBuilder(); builder .append("It has been ") .append(msSinceLastAccessed) .append(" ms since entry at key=") .append(key) .append(" was accessed. It should be expired but isn't."); region.getCache().getLogger().warning(builder.toString()); valid = false; } } return valid; } }
/** * Tests that an attempt to get statistics when they are disabled * results in a {@link StatisticsDisabledException}. */ public void testDisabledStatistics() throws CacheException { String name = this.getUniqueName(); Object key = "KEY"; Object value = "VALUE"; AttributesFactory factory = new AttributesFactory(); factory.setStatisticsEnabled(false); Region region = createRegion(name, factory.create()); try { region.getStatistics(); fail("Should have thrown a StatisticsDisabledException"); } catch (StatisticsDisabledException ex) { // pass... } region.put(key, value); Region.Entry entry = region.getEntry(key); try { entry.getStatistics(); } catch (StatisticsDisabledException ex) { // pass... } }
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); CacheStatistics stats = region.getEntry(key).getStatistics(); long ta = stats.getLastAccessedTime(); long tm = stats.getLastModifiedTime(); long hc = stats.getHitCount(); long mc = stats.getMissCount(); getCache().getLogger().fine("VERIFY: lastAccessed: " + ta + ", lastModified: " + tm); assertTrue("lastAccessedTime was " + ta + " but was expected to be > " + lastAccessed, lastAccessed < (ta + errorMargin)); assertTrue("lastAccessed=" + lastAccessed + " should be < stats.getLastModifiedTime=" + tm, lastAccessed < (tm + errorMargin)); assertEquals(0, hc); assertEquals(0, mc); lastAccessed = stats.getLastAccessedTime(); } });
void buildDetails(Region r, Object objName, int inspectionType) { try { objName = getObjectName(r, objName); if (cancelled) return; if (r.containsKey(objName)) { if (cancelled) return; // @todo darrel: race condition; could be unloaded between isPresent and get call. Region.Entry e = r.getEntry(objName); Object v = e.getValue(); if (cancelled) return; objectValue = CacheDisplay.getCachedObjectDisplay(v, inspectionType); if (cancelled) return; userAttribute = CacheDisplay.getCachedObjectDisplay(e.getUserAttribute(), inspectionType); if (cancelled) return; try { stats = new RemoteCacheStatistics(e.getStatistics()); } catch (StatisticsDisabledException ignore) {} } } catch (CacheException ex) { throw new GemFireCacheException(ex); } }
void buildDetails(Region r, Object objName, int inspectionType) { try { objName = getObjectName(r, objName); if (cancelled) return; if (r.containsKey(objName)) { if (cancelled) return; // @todo darrel: race condition; could be unloaded between isPresent and get call. Region.Entry e = r.getEntry(objName); Object v = e.getValue(); if (cancelled) return; objectValue = CacheDisplay.getCachedObjectDisplay(v, inspectionType); if (cancelled) return; userAttribute = CacheDisplay.getCachedObjectDisplay(e.getUserAttribute(), inspectionType); if (cancelled) return; try { stats = new RemoteCacheStatistics(e.getStatistics()); } catch (StatisticsDisabledException ignore) {} } } catch (CacheException ex) { throw new GemFireCacheException(ex); } }
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); // region.create(key, null); region.put(key,value); CacheStatistics stats = region.getEntry(key).getStatistics(); lastAccessed = stats.getLastAccessedTime(); lastModified = stats.getLastModifiedTime(); getCache().getLogger().fine("DEFINE: lastAccessed: " + lastAccessed + ", lastModified: " + lastModified); assertEquals(0, stats.getHitCount()); assertEquals(0, stats.getMissCount()); assertTrue(lastModified > 0); lastModifiedLocal = lastModified; } });
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); CacheStatistics stats = region.getEntry(key).getStatistics(); assertEquals(lastAccessed, stats.getLastAccessedTime()); assertEquals(lastAccessed, stats.getLastModifiedTime()); assertEquals(0, stats.getHitCount()); assertEquals(0, stats.getMissCount()); } });
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); Object result = region.get(key); assertEquals(value,result); CacheStatistics stats = region.getEntry(key).getStatistics(); lastModifiedRemote = stats.getLastModifiedTime(); getCache().getLogger().fine("NETSEARCH: lastAccessed: " + stats.getLastAccessedTime() + ", lastModified: " + stats.getLastModifiedTime()); } });
public void run2() throws CacheException { Region region = getRootRegion().getSubregion(name); //assertNull(region.getEntry(key)); region.put(key, value); assertEquals(value, region.getEntry(key).getValue()); CacheStatistics stats = region.getEntry(key).getStatistics(); getCache().getLogger().fine("UPDATE: lastAccessed: " + stats.getLastAccessedTime() + ", lastModified: " + stats.getLastModifiedTime()); } });