public long getEntrySize() { if (lruMemoryStats != null) { return lruMemoryStats.getCounter(); } return ManagementConstants.NOT_AVAILABLE_LONG; }
public long getEntrySize() { if (lruMemoryStats != null) { return lruMemoryStats.getCounter(); } return ManagementConstants.NOT_AVAILABLE_LONG; }
protected void waitIfQueueFull() { if (maximumSize <= 0) { return; } // Make the put block if the queue has reached the maximum size // If the queue is over the maximum size, the put will wait for // the given throttle time until there is space in the queue if (stats.getCounter() > maximumSize) { try { synchronized (this.stats) { this.stats.wait(throttleTime); } } catch (InterruptedException e) { // If the thread is interrupted, just continue on Thread.currentThread().interrupt(); } } }
protected void waitIfQueueFull() { if (maximumSize <= 0) { return; } // Make the put block if the queue has reached the maximum size // If the queue is over the maximum size, the put will wait for // the given throttle time until there is space in the queue if (stats.getCounter() > maximumSize) { try { synchronized (this.stats) { this.stats.wait(throttleTime); } } catch (InterruptedException e) { // If the thread is interrupted, just continue on Thread.currentThread().interrupt(); } } }
public boolean mustEvict(LRUStatistics stats, Region region, int delta) { return stats.getCounter() + delta > stats.getLimit(); } };
public boolean mustEvict(LRUStatistics stats, Region region, int delta) { return stats.getCounter() + delta > stats.getLimit(); } };
public boolean mustEvict(LRUStatistics stats, Region region, int delta) { return stats.getCounter() + delta > stats.getLimit(); } };
public boolean mustEvict(LRUStatistics stats, Region region, int delta) { return stats.getCounter() + delta > stats.getLimit(); } };
public static long getPartionRegionCounter(String prRegionName) { final PartitionedRegion pr = (PartitionedRegion)cache .getRegion(prRegionName); return ((AbstractLRURegionMap)pr.entries)._getLruList().stats() .getCounter(); }
private long getSizeFromEvictionStats(LocalRegion region) { long result = region.getEvictionController().getLRUHelper().getStats().getCounter(); // region.getCache().getLogger().info("DEBUG evictionSize=" + result); return result; }
/** * return the current size of all the entries. * * @return The current size of all the entries. */ protected final long getTotalEntrySize() { if (_getOwnerObject() instanceof BucketRegion) { BucketRegion bucketRegion = (BucketRegion)_getOwner(); return bucketRegion.getCounter(); } return _getLruList().stats().getCounter(); }
/** * return the current size of all the entries. * * @return The current size of all the entries. */ protected final long getTotalEntrySize() { if (_getOwnerObject() instanceof BucketRegion) { BucketRegion bucketRegion = (BucketRegion)_getOwner(); return bucketRegion.getCounter(); } return _getLruList().stats().getCounter(); }
public void run2() throws CacheException { getCache(); Region reg1 = getRootRegion().getSubregion(r1); Region reg2 = getRootRegion().getSubregion(r2); Region reg3 = getRootRegion().getSubregion(r3); final Region[] r = {reg1, reg2, reg3}; for(int i =0; i<r.length; i++) { assertNotNull(r[i]); assertEquals(numEntries, r[i].size()); { LocalRegion lr = (LocalRegion) r[i]; assertEquals(maxEntries, lr.getEvictionController().getLRUHelper().getStats().getLimit()); assertEquals(maxEntries, lr.getEvictionController().getLRUHelper().getStats().getCounter()); } } } });
public void run2() throws CacheException { getCache(); Region reg1 = getRootRegion().getSubregion(r1); Region reg2 = getRootRegion().getSubregion(r2); Region reg3 = getRootRegion().getSubregion(r3); final Region[] r = {reg1, reg2, reg3}; for(int i =0; i<r.length; i++) { assertNotNull(r[i]); assertEquals(numEntries, r[i].size()); { LocalRegion lr = (LocalRegion) r[i]; assertEquals(maxEntries, lr.getEvictionController().getLRUHelper().getStats().getLimit()); assertEquals(maxEntries, lr.getEvictionController().getLRUHelper().getStats().getCounter()); } } } });
private void initialize(Region region) { setNumberOfEntries(region.size()); EvictionAttributes ea = region.getAttributes().getEvictionAttributes(); if (ea != null && ea.getAlgorithm().isLRUMemory()) { LocalRegion lr = (LocalRegion) region; LRUStatistics stats = ((AbstractLRURegionMap) lr.getRegionMap())._getLruList().stats(); setHeapSize(stats.getCounter()); } else { setHeapSize(-1); } }
private void initialize(Region region) { setNumberOfEntries(region.size()); EvictionAttributes ea = region.getAttributes().getEvictionAttributes(); if (ea != null && ea.getAlgorithm().isLRUMemory()) { LocalRegion lr = (LocalRegion) region; LRUStatistics stats = ((AbstractLRURegionMap) lr.getRegionMap())._getLruList().stats(); setHeapSize(stats.getCounter()); } else { setHeapSize(-1); } }
/** * Validate that a custom {@link ObjectSizer} is called, configured propertly, * and actually limits the size of the <code>Region</code>. * * @throws Exception */ public void testCustomObjectSizer() throws Exception { final String name = this.getUniqueName(); final int entrySize = 1024 * 1024; final int numEntries = 3; AttributesFactory factory = new AttributesFactory(); CustomObjectSizer cs = new CustomObjectSizer(entrySize); factory.setScope(Scope.LOCAL); factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(1, cs)); Region r = createRegion(name, factory.create()); for (int size = 0; size < numEntries; size++) { r.put(new Integer(size), new byte[entrySize]); } assertTrue("ObjectSizer was not triggered", cs.wasCalled()); long actualSize = getLRUStats(r).getCounter(); int bytesPut = (entrySize * numEntries); assertTrue("Expected bytes put: " + bytesPut + " is not < " + actualSize, actualSize < bytesPut); }
/** * Without object sizer */ public void testWithoutObjectSizerForHeapLRU() { prepareScenario(EvictionAlgorithm.LRU_HEAP, null); // Size of overhead= // 49(HeapLRUCapacityController)((PartitionedRegion)region).getEvictionController()).getPerEntryOverhead() // Size of Integer key= 16 (8 byte object with a 4 byte field, rounded up to the nearest 8 byte word) // Size of Byte Array(1 MB)= 1024 * 1024 + 8 (byte object) + 4 ( size of object) + 4 (rounded up to nearest word) // = 1048592 // Total Size of each entry should be= 1048608 putData("PR1", 2, 1); int keySize = SharedLibrary.getObjectHeaderSize() + 4; keySize = (int) ReflectionSingleObjectSizer.roundUpSize(keySize); int valueSize = SharedLibrary.getObjectHeaderSize() + 4 /* array length */ + (1024*1024) /* bytes */; valueSize = (int) ReflectionSingleObjectSizer.roundUpSize(valueSize); int entrySize = keySize + valueSize + ((HeapLRUCapacityController)((PartitionedRegion)region).getEvictionController()).getPerEntryOverhead(); verifySize("PR1", 2, entrySize); assertEquals(2*entrySize, ((PartitionedRegion)region).getEvictionController().getLRUHelper().getStats().getCounter()); }
/** * With object sizer for customized value object implementing ObjectSizer .Key * -Integer Value TestObjectSizerImpl */ public void testObjectSizerForHeapLRU_CustomizedSizerObject() { prepareScenario(EvictionAlgorithm.LRU_HEAP, new TestObjectSizerImpl()); // Size of overhead= 49 // Size of Integer key= 5(customized) // Size of TestObjectSizerImpl= 160 (serialized size) // Total Size of entry should be= 76 putCustomizedData(1, new TestObjectSizerImpl()); int expected = (5+160+(Sizeable.PER_OBJECT_OVERHEAD*2)+((HeapLRUCapacityController)((PartitionedRegion)region).getEvictionController()).getPerEntryOverhead()); // for direct object storage the overhead is less with no java serialization if (CachedDeserializableFactory.preferObject()) { expected -= 200; } getLogWriter().info("testObjectSizerForHeapLRU_CustomizedSizerObject expected= " + expected); assertEquals(expected, getSizeOfCustomizedData(1)); assertEquals(expected, ((PartitionedRegion)region).getEvictionController() .getLRUHelper().getStats().getCounter()); }
/** * With object sizer for customized key and value objects. */ public void testObjectSizerForHeapLRU_CustomizedSizerObjects() { prepareScenario(EvictionAlgorithm.LRU_HEAP, new TestObjectSizerImpl()); // Size of overhead= 49 // Size of TestNonSizerObject key= 1(customized) // Size of TestObjectSizerImpl= 160 (serialized size) // Total Size of entry should be= 72 putCustomizedObjects(new TestNonSizerObject("1"), new TestObjectSizerImpl()); int expected = (1+160+(Sizeable.PER_OBJECT_OVERHEAD*2)+((HeapLRUCapacityController)((PartitionedRegion)region).getEvictionController()).getPerEntryOverhead()); // for direct object storage the overhead is less with no java serialization if (CachedDeserializableFactory.preferObject()) { expected -= 200; } getLogWriter().info("testObjectSizerForHeapLRU_CustomizedSizerObjects expected= " + expected); assertEquals(expected, getSizeOfCustomizedObject(new TestNonSizerObject("1"))); assertEquals(expected, ((PartitionedRegion)region).getEvictionController() .getLRUHelper().getStats().getCounter()); }