@Override public ClientRegionFactory<K, V> setEvictionAttributes(EvictionAttributes evictionAttributes) { this.attrsFactory.setEvictionAttributes(evictionAttributes); return this; }
/** * Sets the eviction attributes that controls growth of the Region to be created. * * @param evictionAttributes for the Region to create * @return a reference to this RegionFactory object */ public RegionFactory<K, V> setEvictionAttributes(EvictionAttributes evictionAttributes) { this.attrsFactory.setEvictionAttributes(evictionAttributes); return this; }
factory.setEvictionAttributes( EvictionAttributes.createLIFOEntryAttributes(capacity, EvictionAction.OVERFLOW_TO_DISK)); } else if (HARegionQueue.HA_EVICTION_POLICY_MEMORY.equals(ePolicy)) { factory.setEvictionAttributes( EvictionAttributes.createLIFOMemoryAttributes(capacity, EvictionAction.OVERFLOW_TO_DISK)); } else {
EvictionAction.OVERFLOW_TO_DISK); factory.setEvictionAttributes(ea); factory.setConcurrencyChecksEnabled(false);
/** * Byte arrays */ public static void main4(String[] args) throws Exception { DistributedSystem system = DistributedSystem.connect(new java.util.Properties()); Cache cache = CacheFactory.create(system); AttributesFactory factory = new AttributesFactory(); factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(2, (ObjectSizer) null, EvictionAction.OVERFLOW_TO_DISK)); LocalRegion region = (LocalRegion) cache.createRegion("TestDiskRegion", factory.create()); // DiskRegion dr = region.getDiskRegion(); // DiskRegionStats diskStats = dr.getStats(); // EvictionStatistics lruStats = getLRUStats(region); // int total; // for (total = 0; lruStats.getEvictions() > 100; total++) { // region.put(new Integer(total), String.valueOf(total).getBytes()); // } // for (int i = 0; i < total; i++) { // byte[] bytes = (byte[]) region.get(new Integer(i)); // Assert.assertTrue((new String(bytes)).equals(String.valueOf(i))); // } for (int i = 0; i < 100000; i++) { System.out.println(i); region.put(String.valueOf(i), String.valueOf(i).getBytes()); } }
factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(DataPolicy.REPLICATE); factory.setEvictionAttributes( EvictionAttributes.createLRUMemoryAttributes(100, null, EvictionAction.OVERFLOW_TO_DISK)); RegionAttributes attributes = factory.create();
/** * This function creates Region attributes with provided scope,redundancy and localmaxMemory */ public static RegionAttributes createRegionAttrsForPR(int red, int localMaxMem, long recoveryDelay, EvictionAttributes evictionAttrs, PartitionResolver resolver) { AttributesFactory attr = new AttributesFactory(); attr.setDataPolicy(DataPolicy.PARTITION); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setRedundantCopies(red).setLocalMaxMemory(localMaxMem).setRecoveryDelay(recoveryDelay); if (resolver != null) { paf.setPartitionResolver(resolver); } PartitionAttributes<?, ?> prAttr = paf.create(); attr.setPartitionAttributes(prAttr); attr.setEvictionAttributes(evictionAttrs); return attr.create(); }
public static void main1(String[] args) throws Exception { DistributedSystem system = DistributedSystem.connect(new java.util.Properties()); Cache cache = CacheFactory.create(system); AttributesFactory factory = new AttributesFactory(); factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(2, (ObjectSizer) null, EvictionAction.OVERFLOW_TO_DISK)); factory.setCacheListener(new CacheListenerAdapter() { @Override public void afterUpdate(EntryEvent event) { System.out.println("UPDATE: " + event.getKey() + " -> (" + event.getOldValue() + " -> " + event.getNewValue() + ")"); } }); LocalRegion region = (LocalRegion) cache.createRegion("TestDiskRegion", factory.create()); DiskRegion dr = region.getDiskRegion(); DiskRegionStats diskStats = dr.getStats(); EvictionCounters lruStats = getLRUStats(region); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Hit enter to perform action"); for (int i = 0; true; i++) { br.readLine(); // Thread.sleep(500); Object key = new Integer(i); Object value = new byte[200000]; region.put(key, value); System.out.println(key + " -> " + value + " evictions = " + lruStats.getEvictions() + ", writes = " + diskStats.getWrites()); } }
AttributesFactory factory = new AttributesFactory(); factory.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); factory.setDiskSynchronous(true);
/** * Filling up the region with keys and values */ public static void main5(String[] args) throws Exception { DistributedSystem system = DistributedSystem.connect(new java.util.Properties()); Cache cache = CacheFactory.create(system); AttributesFactory factory = new AttributesFactory(); factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(2, (ObjectSizer) null, EvictionAction.OVERFLOW_TO_DISK)); LocalRegion region = (LocalRegion) cache.createRegion("TestDiskRegion", factory.create()); // DiskRegion dr = region.getDiskRegion(); // DiskRegionStats diskStats = dr.getStats(); EvictionCounters lruStats = getLRUStats(region); for (int i = 0; i < 10000; i++) { int[] array = new int[1000]; array[0] = i; try { region.put(array, new Integer(i)); } catch (IllegalStateException ex) { System.out.println("Ran out of space: " + ex); return; } } String s = "Limit is " + lruStats.getLimit() + " evictions are " + lruStats.getEvictions(); throw new RuntimeException(s); }
sender.getMaximumQueueMemory(), EvictionAction.OVERFLOW_TO_DISK); fact.setEvictionAttributes(ea); fact.setPartitionAttributes(pfact.create());
.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes( ManagementConstants.NOTIF_REGION_MAX_ENTRIES, EvictionAction.LOCAL_DESTROY));
sender.getMaximumQueueMemory(), EvictionAction.OVERFLOW_TO_DISK); fact.setEvictionAttributes(ea); fact.setPartitionAttributes(pfact.create());
AttributesFactory<?, ?> af = new AttributesFactory(); af.setDataPolicy(DataPolicy.NORMAL); af.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes()); cache.setRegionAttributes(shortcut.toString(), af.create()); break; AttributesFactory<?, ?> af = new AttributesFactory(); af.setDataPolicy(DataPolicy.NORMAL); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); AttributesFactory<?, ?> af = new AttributesFactory(); af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); AttributesFactory<?, ?> af = new AttributesFactory(); af.setDataPolicy(DataPolicy.NORMAL); af.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes()); UserSpecifiedRegionAttributes<?, ?> attributes = (UserSpecifiedRegionAttributes) af.create(); AttributesFactory<?, ?> af = new AttributesFactory(); af.setDataPolicy(DataPolicy.NORMAL); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); UserSpecifiedRegionAttributes<?, ?> attributes =
if (ev != null && ev.getAlgorithm().isLRU()) { EvictionAttributes rev = new EvictionAttributesImpl(ev); af.setEvictionAttributes(rev);
factory.setEvictionAttributes( EvictionAttributes.createLRUEntryAttributes(capacity, EvictionAction.OVERFLOW_TO_DISK)); factory.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes(ObjectSizer.DEFAULT, EvictionAction.OVERFLOW_TO_DISK));
Cache cache = CacheFactory.create(system); AttributesFactory factory = new AttributesFactory(); factory.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(2, (ObjectSizer) null, EvictionAction.OVERFLOW_TO_DISK)); DiskStoreFactory dsf = cache.createDiskStoreFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory(); af.setPartitionAttributes(paf.create()); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); paf.setRedundantCopies(1); af.setPartitionAttributes(paf.create()); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); PartitionAttributesFactory paf = new PartitionAttributesFactory(); af.setPartitionAttributes(paf.create()); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); paf.setRedundantCopies(1); af.setPartitionAttributes(paf.create()); af.setEvictionAttributes( EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK)); cache.setRegionAttributes(shortcut.toString(), af.create()); PartitionAttributesFactory paf = new PartitionAttributesFactory(); af.setPartitionAttributes(paf.create()); af.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes()); cache.setRegionAttributes(shortcut.toString(), af.create()); break;