public ClientRegionFactory<K,V> setEntryTimeToLive(ExpirationAttributes timeToLive) { this.attrsFactory.setEntryTimeToLive(timeToLive); return this; }
public ClientRegionFactory<K,V> setEntryTimeToLive(ExpirationAttributes timeToLive) { this.attrsFactory.setEntryTimeToLive(timeToLive); return this; }
/** * Sets the timeToLive expiration attributes for region entries for the next * <code>RegionAttributes</code> created. * * @param timeToLive * the timeToLive ExpirationAttributes for entries in this region * @return a reference to this RegionFactory object * @throws IllegalArgumentException * if timeToLive is null * @see AttributesFactory#setEntryTimeToLive */ public RegionFactory<K,V> setEntryTimeToLive(ExpirationAttributes timeToLive) { this.attrsFactory.setEntryTimeToLive(timeToLive); return this; }
/** * Sets the timeToLive expiration attributes for region entries for the next * <code>RegionAttributes</code> created. * * @param timeToLive * the timeToLive ExpirationAttributes for entries in this region * @return a reference to this RegionFactory object * @throws IllegalArgumentException * if timeToLive is null * @see AttributesFactory#setEntryTimeToLive */ public RegionFactory<K,V> setEntryTimeToLive(ExpirationAttributes timeToLive) { this.attrsFactory.setEntryTimeToLive(timeToLive); return this; }
public static String createClientMessagesRegionForTesting(GemFireCacheImpl cache, String ePolicy, int capacity, int port, int expiryTime, String overFlowDir, boolean isDiskStore) { AttributesFactory factory = getAttribFactoryForClientMessagesRegion(cache, ePolicy, capacity, overFlowDir, isDiskStore); ExpirationAttributes ea = new ExpirationAttributes(expiryTime, ExpirationAction.LOCAL_INVALIDATE); factory.setEntryTimeToLive(ea); RegionAttributes attr = factory.create(); return createClientMessagesRegion(attr, cache, capacity, port); }
public static String createClientMessagesRegionForTesting(GemFireCacheImpl cache, String ePolicy, int capacity, int port, int expiryTime, String overFlowDir, boolean isDiskStore) { AttributesFactory factory = getAttribFactoryForClientMessagesRegion(cache, ePolicy, capacity, overFlowDir, isDiskStore); ExpirationAttributes ea = new ExpirationAttributes(expiryTime, ExpirationAction.LOCAL_INVALIDATE); factory.setEntryTimeToLive(ea); RegionAttributes attr = factory.create(); return createClientMessagesRegion(attr, cache, capacity, port); }
public void run2() throws CacheException { AttributesFactory factory = new AttributesFactory(getRegionAttributes()); factory.setStatisticsEnabled(true); ExpirationAttributes expire = new ExpirationAttributes(longTimeout, ExpirationAction.DESTROY); factory.setEntryTimeToLive(expire); Region region = null; System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true"); try { region = createRegion(name, factory.create()); region.create(key, value); } finally { System.getProperties().remove(LocalRegion.EXPIRY_MS_PROPERTY); } } };
/** * Create a region and install the given listener * * ACCESSED VIA REFLECTION */ protected static void createSubregionWhenDestroy(String name, SubscriptionAttributes subAttrs, GenericListener l, Integer ttl, ExpirationAction action) throws CacheException { Region region = getRegion(); AttributesFactory factory = new AttributesFactory(); factory.setStatisticsEnabled(true); factory.setSubscriptionAttributes(subAttrs); factory.setEntryTimeToLive(new ExpirationAttributes(ttl.intValue(), action)); factory.addCacheListener(l); factory.setPartitionAttributes((new PartitionAttributesFactory()).create()); region.createSubregion(name, factory.create()); } /**
public void run2() throws CacheException { RegionAttributes ra = getRegionAttributes(); AttributesFactory factory = new AttributesFactory(ra); final boolean partitioned = ra.getPartitionAttributes() != null || ra.getDataPolicy().withPartitioning() ; // MUST be nonmirrored, so turn off persistBackup if this is a disk region test if (!partitioned) { if (ra.getEvictionAttributes() == null || !ra.getEvictionAttributes().getAction().isOverflowToDisk()) { factory.setDiskStoreName(null); } factory.setDataPolicy(DataPolicy.NORMAL); } factory.setStatisticsEnabled(true); ExpirationAttributes expire = new ExpirationAttributes(shortTimeout, ExpirationAction.DESTROY); factory.setEntryTimeToLive(expire); System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true"); try { createRegion(name, factory.create()); } finally { System.getProperties().remove(LocalRegion.EXPIRY_MS_PROPERTY); } } });
public void run2() throws CacheException { AttributesFactory factory = new AttributesFactory(getRegionAttributes()); final boolean partitioned = getRegionAttributes().getPartitionAttributes() != null || getRegionAttributes().getDataPolicy().withPartitioning(); factory.setStatisticsEnabled(true); ExpirationAttributes expire = new ExpirationAttributes(timeout, ExpirationAction.DESTROY); factory.setEntryTimeToLive(expire); if (!getRegionAttributes().getDataPolicy().withReplication()&& ! partitioned) { factory.setDataPolicy(DataPolicy.NORMAL); factory.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL)); } System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true"); try { createRegion(name, factory.create()); } finally { System.getProperties().remove(LocalRegion.EXPIRY_MS_PROPERTY); } } });
/** * Create a region with one entry in this test's region with the * given name and attributes. */ private static void createEntry(String name, int ttl, ExpirationAction action, GenericListener l) throws CacheException { Region region = getRegion(); AttributesFactory factory = new AttributesFactory(region.getAttributes()); factory.setStatisticsEnabled(true); factory.setEntryTimeToLive(new ExpirationAttributes(ttl, action)); factory.setScope(SCOPE); factory.setCacheListener(l); Region sub = region.createSubregion(name, factory.create()); sub.create(name, new Integer(0), sub.getCache().getDistributedSystem().getDistributedMember()); }
/** * Create a region with one entry in this test's region with the * given name and attributes. */ private static void createEntry(String name, int ttl, ExpirationAction action, GenericListener l) throws CacheException { Region region = getRegion(); AttributesFactory factory = new AttributesFactory(region.getAttributes()); factory.setStatisticsEnabled(true); factory.setEntryTimeToLive(new ExpirationAttributes(ttl, action)); factory.setScope(SCOPE); factory.setCacheListener(l); Region sub = region.createSubregion(name, factory.create()); sub.create(name, new Integer(0), sub.getCache().getDistributedSystem().getDistributedMember()); }
private static Region _createRegion(String name, int ttl, ExpirationAction action, SubscriptionAttributes subAttrs, GenericListener l) throws CacheException { Region region = getRegion(); AttributesFactory factory = new AttributesFactory(); factory.setStatisticsEnabled(true); factory.setEntryTimeToLive(new ExpirationAttributes(ttl, action)); factory.setSubscriptionAttributes(subAttrs); factory.addCacheListener(l); factory.setPartitionAttributes((new PartitionAttributesFactory()).create()); Region sub = region.createSubregion(name, factory.create()); return sub; }
/** * Expiration needs some more work in the new TX model. */ public void DISABLED_TILL_NEW_TX_IMPL_COMPLETE_testEntryTTLExpiration() throws CacheException { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setStatisticsEnabled(true); af.setEntryTimeToLive(new ExpirationAttributes(2, ExpirationAction.DESTROY)); Region exprReg = this.cache.createRegion("TXEntryTTL", af.create()); generalEntryExpirationTest(exprReg, 2); AttributesMutator mutator = exprReg.getAttributesMutator(); mutator.setEntryTimeToLive(new ExpirationAttributes(1, ExpirationAction.DESTROY)); generalEntryExpirationTest(exprReg, 1); }
public static final Region createRegion(String name, String rootName, RegionAttributes attrs) throws CacheException { Region root = cache.getRegion(rootName); if (root == null) { // don't put listeners on root region RegionAttributes rootAttrs = attrs; AttributesFactory fac = new AttributesFactory(attrs); ExpirationAttributes expiration = ExpirationAttributes.DEFAULT; // fac.setCacheListener(null); fac.setCacheLoader(null); fac.setCacheWriter(null); fac.setPartitionAttributes(null); fac.setRegionTimeToLive(expiration); fac.setEntryTimeToLive(expiration); fac.setRegionIdleTimeout(expiration); fac.setEntryIdleTimeout(expiration); rootAttrs = fac.create(); root = cache.createRegion(rootName, rootAttrs); } return LocalRegionHelper.createSubregion(root, name, attrs, null); }
/** * createCacheTask: general task to hook a vm to the distributed cache. */ public static synchronized void createCacheTask() { if ( CacheUtil.getCache() == null ) { log().info( "Initializing the cache" ); CacheUtil.createCache(); AttributesFactory factory = new AttributesFactory(); factory.setScope( Scope.DISTRIBUTED_ACK ); // switch to GLOBAL when available factory.setRegionTimeToLive( ExpirationAttributes.DEFAULT ); // infinite factory.setEntryTimeToLive( ExpirationAttributes.DEFAULT ); // infinite //factory.setExpirationAction( irrelevant ); //CapacityController capcon = ...; //factory.setCapacityController( capcon ); //RegionEventListener revel = ...; //factory.setRegionEventListener( revel ); RegionAttributes ratts = factory.createRegionAttributes(); CacheUtil.createRegion( REGION_NAME, ratts ); log().info( "Initialized the cache" ); } } /**
public void testLocalDestroyTimeToLive() { Cache cache = getCache(); AttributesFactory attr = new AttributesFactory(); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setRedundantCopies(1); paf.setRecoveryDelay(-1); paf.setStartupRecoveryDelay(-1); PartitionAttributes prAttr = paf.create(); attr.setStatisticsEnabled(true); attr.setEntryTimeToLive(new ExpirationAttributes(1000, ExpirationAction.LOCAL_DESTROY)); attr.setPartitionAttributes(prAttr); try { cache.createRegion("region1", attr.create()); fail("We should not have been able to create the region"); } catch(IllegalStateException expected) { } }
public void testLocalInvalidateTimeToLive() { Cache cache = getCache(); AttributesFactory attr = new AttributesFactory(); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setRedundantCopies(1); paf.setRecoveryDelay(-1); paf.setStartupRecoveryDelay(-1); PartitionAttributes prAttr = paf.create(); attr.setStatisticsEnabled(true); attr.setEntryTimeToLive(new ExpirationAttributes(1000, ExpirationAction.LOCAL_INVALIDATE)); attr.setPartitionAttributes(prAttr); try { cache.createRegion("region1", attr.create()); fail("We should not have been able to create the region"); } catch(IllegalStateException expected) { } } }
final public Region createRegion(String name, String rootName, RegionAttributes attrs) throws CacheException { Region root = getRootRegion(rootName); if (root == null) { // don't put listeners on root region RegionAttributes rootAttrs = attrs; AttributesFactory fac = new AttributesFactory(attrs); ExpirationAttributes expiration = ExpirationAttributes.DEFAULT; // fac.setCacheListener(null); fac.setCacheLoader(null); fac.setCacheWriter(null); fac.setPoolName(null); fac.setPartitionAttributes(null); fac.setRegionTimeToLive(expiration); fac.setEntryTimeToLive(expiration); fac.setRegionIdleTimeout(expiration); fac.setEntryIdleTimeout(expiration); rootAttrs = fac.create(); root = createRootRegion(rootName, rootAttrs); } return LocalRegionHelper.createSubregion(root, name, attrs, getInternalRegionArguments()); }
/** * This method creates the client health monitoring region. * * @param cache * The current GemFire Cache * @guarded.By ClientHealthMonitoringRegion.class */ private static void initialize(GemFireCacheImpl cache) { try { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); factory.setEntryTimeToLive(new ExpirationAttributes( ADMIN_REGION_EXPIRY_INTERVAL, ExpirationAction.DESTROY)); cache.getLogger().fine("ClientHealthMonitoringRegion, setting TTL for entry...."); factory.addCacheListener(prepareCacheListener()); factory.setStatisticsEnabled(true); RegionAttributes regionAttrs = factory.create(); InternalRegionArguments internalArgs = new InternalRegionArguments(); internalArgs.setIsUsedForMetaRegion(true); internalArgs.setIsUsedForPartitionedRegionAdmin(false); currentInstance = cache.createVMRegion(ADMIN_REGION_NAME, regionAttrs, internalArgs); } catch (Exception ex) { cache.getLoggerI18n().error(LocalizedStrings. ClientHealthMonitoringRegion_ERROR_WHILE_CREATING_AN_ADMIN_REGION, ex); } }