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 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(); } } /**
entry.getUserAttribute(); fail("Should have thrown an EntryDestroyedException");
assertEquals("uaValue1", cmtre.getUserAttribute()); txre.getUserAttribute(); fail("expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { re.getUserAttribute(); txre.getUserAttribute(); fail("expected UnsupportedOperationException"); } catch (UnsupportedOperationException e) { assertFalse(re.isDestroyed()); re.setUserAttribute("uaValue2"); assertEquals("uaValue2", re.getUserAttribute()); assertEquals(txFailureChanges, stats.getTxFailureChanges()); assertEquals("uaValue2", cmtre.getUserAttribute());
entry.getUserAttribute(); fail("Should have thrown an EntryDestroyedException");
assertEquals(null, cmtre.getUserAttribute()); txMgrImpl.begin(); Region.Entry txre = this.region.getEntry("key1"); txre.setUserAttribute("uaValue1"); txMgrImpl.commit(); assertEquals("uaValue1", cmtre.getUserAttribute()); this.region.localDestroy("key1"); cmtre = this.region.getEntry("key1"); assertEquals("value0", cmtre.getValue()); assertEquals(null, cmtre.getUserAttribute()); this.txMgr.begin(); txre = this.region.getEntry("key1"); assertEquals("valueTX", txre.getValue()); assertEquals("value0", cmtre.getValue()); assertEquals(null, txre.getUserAttribute()); txre.setUserAttribute("uaValue1"); assertEquals("uaValue1", txre.getUserAttribute()); assertEquals(null, cmtre.getUserAttribute()); cmtre.setUserAttribute("uaValue2"); assertEquals("uaValue2", cmtre.getUserAttribute()); assertEquals("uaValue1", txre.getUserAttribute()); try { txMgrImpl.commit(); txre.getUserAttribute(); fail("expected IllegalTransactionStateException"); } catch (IllegalTransactionStateException ok) {
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); } }
/** * Tests a region entry's user attribute */ public void testEntryUserAttribute() throws CacheException { String name = this.getUniqueName(); String key = "KEY"; String attr = "USER_ATTRIBUTE"; Region region = createRegion(name); region.create(key, null); Region.Entry entry = region.getEntry(key); entry.setUserAttribute(attr); assertEquals(attr, entry.getUserAttribute()); entry = region.getEntry(key); assertEquals(attr, entry.getUserAttribute()); }