public ClientRegionFactory<K,V> setEntryIdleTimeout(ExpirationAttributes idleTimeout) { this.attrsFactory.setEntryIdleTimeout(idleTimeout); return this; }
public ClientRegionFactory<K,V> setEntryIdleTimeout(ExpirationAttributes idleTimeout) { this.attrsFactory.setEntryIdleTimeout(idleTimeout); return this; }
/** * Sets the idleTimeout expiration attributes for region entries for the next * <code>RegionAttributes</code> created. * Note that the XML element that corresponds to this method "entry-idle-time", does not include "out" in its name. * * @param idleTimeout * the idleTimeout ExpirationAttributes for entries in this region * @return a reference to this RegionFactory object * @throws IllegalArgumentException * if idleTimeout is null * @see AttributesFactory#setEntryIdleTimeout */ public RegionFactory<K,V> setEntryIdleTimeout(ExpirationAttributes idleTimeout) { this.attrsFactory.setEntryIdleTimeout(idleTimeout); return this; }
/** * Sets the idleTimeout expiration attributes for region entries for the next * <code>RegionAttributes</code> created. * Note that the XML element that corresponds to this method "entry-idle-time", does not include "out" in its name. * * @param idleTimeout * the idleTimeout ExpirationAttributes for entries in this region * @return a reference to this RegionFactory object * @throws IllegalArgumentException * if idleTimeout is null * @see AttributesFactory#setEntryIdleTimeout */ public RegionFactory<K,V> setEntryIdleTimeout(ExpirationAttributes idleTimeout) { this.attrsFactory.setEntryIdleTimeout(idleTimeout); return this; }
public void run2() throws CacheException { AttributesFactory factory = new AttributesFactory(getRegionAttributes()); factory.setStatisticsEnabled(true); ExpirationAttributes expire = new ExpirationAttributes(longTimeout, ExpirationAction.DESTROY); factory.setEntryIdleTimeout(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); } } };
public void testResumeCommitWithExpiry_bug45558() throws Exception { final CacheTransactionManager mgr = cache.getCacheTransactionManager(); final CountDownLatch l = new CountDownLatch(1); region.close(); AttributesFactory<String, String> af = new AttributesFactory<String, String>(); af.setStatisticsEnabled(true); af.setEntryIdleTimeout(new ExpirationAttributes(5)); //region.getAttributesMutator().setEntryTimeToLive(new ExpirationAttributes(5)); region = cache.createRegion(getName(), af.create()); region.put("key", "value"); mgr.begin(); region.put("key", "value"); final TransactionId txId = mgr.suspend(); Thread t = new Thread(new Runnable() { @Override public void run() { mgr.resume(txId); mgr.commit(); l.countDown(); } }); t.start(); l.await(); }
public void run2() throws CacheException { AttributesFactory factory = new AttributesFactory(getRegionAttributes()); factory.setStatisticsEnabled(true); ExpirationAttributes expire = new ExpirationAttributes(timeout, ExpirationAction.DESTROY); factory.setEntryIdleTimeout(expire); Region region = createRegion(name, factory.create()); region.create(key, null); } });
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.setEntryIdleTimeout(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()); factory.setStatisticsEnabled(true); ExpirationAttributes expire = new ExpirationAttributes(timeout, ExpirationAction.DESTROY); factory.setEntryIdleTimeout(expire); if(getRegionAttributes().getPartitionAttributes() != null){ createRegion(name, factory.create()); } else { createRegion(name); } } });
public static void createPR(String partitionedRegionName, Integer redundancy, Integer localMaxMemory, Integer totalNumBuckets, Boolean setExpiry, Compressor compressor) { PartitionAttributesFactory paf = new PartitionAttributesFactory(); PartitionAttributes prAttr = paf.setRedundantCopies(redundancy.intValue()) .setLocalMaxMemory(localMaxMemory.intValue()).setTotalNumBuckets( totalNumBuckets.intValue()).create(); AttributesFactory attr = new AttributesFactory(); attr.setPartitionAttributes(prAttr); attr.setDataPolicy(DataPolicy.PARTITION); attr.setConcurrencyChecksEnabled(true); if (setExpiry) { attr.setStatisticsEnabled(true); attr.setEntryIdleTimeout(new ExpirationAttributes(1, ExpirationAction.INVALIDATE)); } if (compressor != null) { attr.setCompressor(compressor); } //attr.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(5)); assertNotNull(cache); deltaPR = cache.createRegion(partitionedRegionName, attr.create()); assertNotNull(deltaPR); getLogWriter().info( "Partitioned Region " + partitionedRegionName + " created Successfully :" + deltaPR); }
/** * Expiration needs some more work in the new TX model. */ public void DISABLED_TILL_NEW_TX_IMPL_COMPLETE_testEntryIdleExpiration() throws CacheException { AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setStatisticsEnabled(true); af.setEntryIdleTimeout(new ExpirationAttributes(2, ExpirationAction.DESTROY)); Region exprReg = this.cache.createRegion("TXEntryIdle", af.create()); // exprReg.getCache().getLogger().info("invoking expiration test with 2"); generalEntryExpirationTest(exprReg, 2); AttributesMutator mutator = exprReg.getAttributesMutator(); mutator.setEntryIdleTimeout(new ExpirationAttributes(1, ExpirationAction.DESTROY)); // exprReg.getCache().getLogger().info("invoking expiration test with 1 after setting idle timeout of 1 second"); generalEntryExpirationTest(exprReg, 1); }
afact.setEntryIdleTimeout(exprAttrs[0]); expirationFlag = 4; break;
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); }
private Region getResultRegion() { Region resultRegion = super.getCommandRegion().getSubregion(REGION_NAME_RESULTS); if (resultRegion == null) { AttributesFactory factory = new AttributesFactory(); factory.setStatisticsEnabled(true); factory.setScope(Scope.LOCAL); factory.setDataPolicy(DataPolicy.NORMAL); factory.setEntryIdleTimeout(new ExpirationAttributes(UUID_TIMEOUT, ExpirationAction.LOCAL_DESTROY)); try { resultRegion = super.getCommandRegion().createSubregion(REGION_NAME_RESULTS, factory.create()); } catch (Exception ex) { // in case another thread created it resultRegion = super.getCommandRegion().getSubregion(REGION_NAME_RESULTS); } } return resultRegion; }
public void testLocalDestroyIdleTimeout() { 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.setEntryIdleTimeout(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 testLocalInvalidateIdleTimeout() { 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.setEntryIdleTimeout(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()); }
factory.setScope(Scope.LOCAL); factory.setDataPolicy(DataPolicy.NORMAL); factory.setEntryIdleTimeout(new ExpirationAttributes(ASYNC_REGION_TIMEOUT, ExpirationAction.LOCAL_DESTROY)); factory.addCacheListener(new CacheListenerAdapter() { public void afterDestroy(EntryEvent event)
public void run() { Cache cache = getCache(); DiskStore ds = cache.findDiskStore("disk"); if(ds == null) { ds = cache.createDiskStoreFactory() .setDiskDirs(getDiskDirs()).create("disk"); } AttributesFactory af = new AttributesFactory(); PartitionAttributesFactory paf = new PartitionAttributesFactory(); af.setPartitionAttributes(paf.create()); af.setCustomEntryIdleTimeout(new TestCustomExpiration()); af.setEntryIdleTimeout(new ExpirationAttributes(60, ExpirationAction.INVALIDATE)); af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION); af.setDiskStoreName("disk"); RegionAttributes attr = af.create(); cache.createRegion(PR_REGION_NAME, attr); } };
public void run2() throws CacheException { Cache cache = getCache(); AttributesFactory factory = new AttributesFactory(); factory.setCacheListener(new CacheListener2()); factory.setCacheLoader(new CacheLoader2()); factory.setCacheWriter(new CacheWriter2()); factory.setConcurrencyLevel(concurrencyLevel); factory.setDiskDirs(new File[] { diskDir }); factory.setDiskWriteAttributes(dwa); factory.setStatisticsEnabled(statisticsEnabled); factory.setEntryIdleTimeout(entryIdle); factory.setEntryTimeToLive(entryTtl); factory.setInitialCapacity(initialCapacity); factory.setKeyConstraint(String.class); factory.setLoadFactor(loadFactor); factory.setDataPolicy(dataPolicy); factory.setRegionIdleTimeout(regionIdle); factory.setRegionTimeToLive(regionTtl); factory.setScope(scope); factory.setEarlyAck(false); MembershipAttributes membershipAttributes = new MembershipAttributes(new String[] {"A"}, LossAction.LIMITED_ACCESS, ResumptionAction.NONE); factory.setMembershipAttributes(membershipAttributes); RegionAttributes attrs = factory.create(); Region region = cache.createRegion(name, attrs); region.setUserAttribute(userAttribute); } });