public <K, V> Region<K, V> createRegion(Cache c, String diskStore, RegionType type, String name) { Region<Integer, MyObject> r = c.getRegion(name); switch (type) { case REPLICATE: return c.<K, V>createRegionFactory(RegionShortcut.REPLICATE).create(name); case REPLICATE_PERSISTENT: return c.<K, V>createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT) .setDiskStoreName(diskStore).create(name); case REPLICATE_PERSISTENT_OVERFLOW: return c.<K, V>createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT_OVERFLOW) .setEvictionAttributes( EvictionAttributes.createLIFOEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)) .setDiskStoreName(diskStore).create(name); case PARTITION: return c.<K, V>createRegionFactory(RegionShortcut.PARTITION).create(name); case PARTITION_PERSISTENT: return c.<K, V>createRegionFactory(RegionShortcut.PARTITION_PERSISTENT) .setDiskStoreName(diskStore).create(name); case PARTITION_PERSISTENT_OVERFLOW: return c.<K, V>createRegionFactory(RegionShortcut.PARTITION_PERSISTENT_OVERFLOW) .setEvictionAttributes( EvictionAttributes.createLIFOEntryAttributes(5, EvictionAction.OVERFLOW_TO_DISK)) .setDiskStoreName(diskStore).create(name); } throw new IllegalArgumentException(); }
private static void setupReplicatedRegionWithEviction(String regionName) { InternalCache cache = ClusterStartupRule.getCache(); EvictionAttributesImpl evictionAttributes = new EvictionAttributesImpl(); evictionAttributes.setMaximum(1).setAction(EvictionAction.OVERFLOW_TO_DISK) .setAlgorithm(EvictionAlgorithm.LRU_ENTRY); RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE) .setEvictionAttributes(evictionAttributes); Region dataRegion = regionFactory.create(regionName); assertThat(dataRegion).isNotNull(); assertThat(dataRegion.getFullPath()).contains(regionName); }
factory.setEvictionAttributes( EvictionAttributesImpl.fromConfig(regionAttributes.getEvictionAttributes())); } catch (Exception e) {
.thenAnswer(newSetter(entryTimeToLive, mockRegionFactory)); when(mockRegionFactory.setEvictionAttributes(any(EvictionAttributes.class))) .thenAnswer(newSetter(evictionAttributes, mockRegionFactory));
regionFactory.setEvictionAttributes(regionAttributes.getEvictionAttributes());
regionFactory.setEvictionAttributes(regionAttributes.getEvictionAttributes());