mutator.setCloningEnabled(regionAlterArgs.isCloningEnabled()); if (logger.isDebugEnabled()) { logger.debug("Region successfully altered - cloning"); mutator.getEvictionAttributesMutator().setMaximum(regionAlterArgs.getEvictionMax()); if (logger.isDebugEnabled()) { logger.debug("Region successfully altered - eviction attributes max"); mutator.setEntryIdleTimeout(parseExpirationAttributes(newEntryExpirationIdleTime, region.getEntryIdleTimeout())); if (logger.isDebugEnabled()) { logger.debug("Region successfully altered - entry idle timeout"); mutator.setEntryTimeToLive(parseExpirationAttributes(newEntryExpirationTTL, region.getEntryTimeToLive())); if (logger.isDebugEnabled()) { logger.debug("Region successfully altered - entry TTL"); mutator.setRegionIdleTimeout(parseExpirationAttributes(newRegionExpirationIdleTime, region.getRegionIdleTimeout())); if (logger.isDebugEnabled()) { logger.debug("Region successfully altered - region idle timeout"); mutator.setRegionTimeToLive(parseExpirationAttributes(newRegionExpirationTTL, region.getRegionTimeToLive())); if (logger.isDebugEnabled()) { logger.debug("Region successfully altered - region TTL"); for (String gatewaySenderId : oldGatewaySenderIds) { if (!newGatewaySenderIds.contains(gatewaySenderId)) { mutator.removeGatewaySenderId(gatewaySenderId); mutator.addGatewaySenderId(gatewaySenderId);
mutator.initCacheListeners(attrs.getCacheListeners()); mutator.setCacheLoader(attrs.getCacheLoader()); mutator.setCacheWriter(attrs.getCacheWriter()); mutator.setEntryIdleTimeout(attrs.getEntryIdleTimeout()); mutator.setCustomEntryIdleTimeout(attrs.getCustomEntryIdleTimeout()); mutator.setEntryTimeToLive(attrs.getEntryTimeToLive()); mutator.setCustomEntryTimeToLive(attrs.getCustomEntryTimeToLive()); mutator.setRegionIdleTimeout(attrs.getEntryIdleTimeout()); mutator.setRegionTimeToLive(attrs.getRegionTimeToLive()); mutator.setCloningEnabled(attrs.getCloningEnabled());
private void initializeResponder() { for (Region aRegion: allRegions) { aRegion.getAttributesMutator().addCacheListener(new ImportListener()); aRegion.getAttributesMutator().setCacheWriter(new ImportWriter()); Log.getLogWriter().info("After adding ImportListener and ImportWriter via AttributesMutator, Region = " + TestHelper.regionToString(aRegion, true)); } }
mutator.setEntryIdleTimeout(null); fail("Should have thrown an IllegalArgumentException"); mutator.setEntryTimeToLive(null); fail("Should have thrown an IllegalArgumentException"); mutator.setRegionIdleTimeout(null); fail("Should have thrown an IllegalArgumentException"); mutator.setRegionTimeToLive(null); fail("Should have thrown an IllegalArgumentException"); mutator.setEntryIdleTimeout(new ExpirationAttributes(1, ExpirationAction.DESTROY)); fail("Should have thrown an IllegalStateException"); } catch (IllegalStateException ex) { mutator.setEntryTimeToLive(new ExpirationAttributes(1, ExpirationAction.DESTROY)); fail("Should have thrown an IllegalStateException"); } catch (IllegalStateException ex) { mutator.setRegionIdleTimeout(new ExpirationAttributes(1, ExpirationAction.DESTROY)); fail("Should have thrown an IllegalStateException"); } catch (IllegalStateException ex) { mutator.setRegionTimeToLive(new ExpirationAttributes(1, ExpirationAction.DESTROY)); fail("Should have thrown an IllegalStateException");
assertEquals(region, mutator.getRegion()); assertSame(region, mutator); mutator.setCacheListener(listener); mutator.setCacheLoader(loader); mutator.setCacheWriter(writer); mutator.setEntryIdleTimeout(entryIdle); mutator.setCustomEntryIdleTimeout(customEntryIdle); mutator.setEntryTimeToLive(entryTTL); mutator.setCustomEntryTimeToLive(customTtl); mutator.setRegionIdleTimeout(regionIdle); mutator.setRegionTimeToLive(regionTTL); new ExpirationAttributes(8, ExpirationAction.INVALIDATE); assertEquals(listener, mutator.setCacheListener(listener2)); assertEquals(loader, mutator.setCacheLoader(loader2)); assertEquals(writer, mutator.setCacheWriter(writer2)); assertEquals(entryIdle, mutator.setEntryIdleTimeout(entryIdle2)); assertEquals(customEntryIdle, mutator.setCustomEntryIdleTimeout(customEntryIdle2)); assertEquals(entryTTL, mutator.setEntryTimeToLive(entryTTL2)); assertEquals(customTtl, mutator.setCustomEntryTimeToLive(customTtl2)); assertEquals(regionIdle, mutator.setRegionIdleTimeout(regionIdle2)); assertEquals(regionTTL, mutator.setRegionTimeToLive(regionTTL2));
switch (expirationKind) { case GfxdAttributesMutator.EXPIRE_REGION_TIMETOLIVE: attrsMutator.setRegionTimeToLive(expirationAttrs); break; case GfxdAttributesMutator.EXPIRE_REGION_IDLETIME: attrsMutator.setRegionIdleTimeout(expirationAttrs); break; case GfxdAttributesMutator.EXPIRE_ENTRY_TIMETOLIVE: attrsMutator.setEntryTimeToLive(expirationAttrs); break; case GfxdAttributesMutator.EXPIRE_ENTRY_IDLETIME: attrsMutator.setEntryIdleTimeout(expirationAttrs); break; .getEvictionAttributesMutator(); region.getAttributesMutator().setCustomEvictionAttributes( this.mutator.getCustomEvictionStart(), this.mutator.getCustomEvictionInterval());
assertEquals(Collections.EMPTY_LIST, Arrays.asList(ra.getCacheListeners())); try { am.addCacheListener(null); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { am.removeCacheListener(null); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { am.initCacheListeners(new CacheListener[]{cl1, null}); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { am.addCacheListener(cl1); assertEquals(cl1, ra.getCacheListener()); assertEquals(Arrays.asList(new CacheListener[]{cl1}), Arrays.asList(ra.getCacheListeners())); am.addCacheListener(cl2); assertEquals(Arrays.asList(new CacheListener[]{cl1,cl2}), Arrays.asList(ra.getCacheListeners())); try { am.setCacheListener(cl1); fail("expected IllegalStateException"); } catch (IllegalStateException expected) { am.removeCacheListener(cl1); assertEquals(Arrays.asList(new CacheListener[]{cl2}), Arrays.asList(ra.getCacheListeners())); am.removeCacheListener(cl1);
@Override public void visit(Integer bucketId, Region r) { AttributesMutator mut = r.getAttributesMutator(); if (logger.isDebugEnabled()) { logger.debug("setting new cache loader in bucket region: {}", newLoader); } mut.setCacheLoader(newLoader); } });
@Override public void addCacheListener(CacheListener listener) { for(PartitionedRegion prQ: this.userRegionNameToshadowPRMap.values()) { AttributesMutator mutator = prQ.getAttributesMutator(); mutator.addCacheListener(listener); } }
assertEquals(Arrays.asList(new CacheListener[]{l1, l2}), Arrays.asList(r.getAttributes().getCacheListeners())); AttributesMutator am = r.getAttributesMutator(); am.removeCacheListener(l2); assertEquals(Arrays.asList(new CacheListener[]{l1}), Arrays.asList(r.getAttributes().getCacheListeners())); am.removeCacheListener(l1); assertEquals(Arrays.asList(new CacheListener[]{}), Arrays.asList(r.getAttributes().getCacheListeners())); am.addCacheListener(l1); assertEquals(Arrays.asList(new CacheListener[]{l1}), Arrays.asList(r.getAttributes().getCacheListeners())); am.addCacheListener(l1); assertEquals(Arrays.asList(new CacheListener[]{l1}), Arrays.asList(r.getAttributes().getCacheListeners())); am.addCacheListener(l2); assertEquals(Arrays.asList(new CacheListener[]{l1,l2}), Arrays.asList(r.getAttributes().getCacheListeners())); am.removeCacheListener(l1); assertEquals(Arrays.asList(new CacheListener[]{l2}), Arrays.asList(r.getAttributes().getCacheListeners())); am.removeCacheListener(l1); assertEquals(Arrays.asList(new CacheListener[]{l2}), Arrays.asList(r.getAttributes().getCacheListeners())); am.initCacheListeners(new CacheListener[]{l1,l2}); assertEquals(Arrays.asList(new CacheListener[]{l1,l2}), Arrays.asList(r.getAttributes().getCacheListeners()));
public void run2() throws CacheException { Region r = getRootRegion("ProxyDUnitTest"); AttributesMutator am = r.getAttributesMutator(); CacheWriter cw = new CacheWriterAdapter() { public void beforeCreate(EntryEvent event) throws CacheWriterException { throw new CacheWriterException("expected"); } }; am.setCacheWriter(cw); } });
TestOnlyHARegionQueue(String regionName, GemFireCacheImpl cache, HARegionQueueAttributes hrqa, Map haContainer, final byte clientConflation, boolean isPrimary) throws IOException, ClassNotFoundException, CacheException, InterruptedException { super(regionName, cache, hrqa, haContainer, null, clientConflation, isPrimary); ExpirationAttributes ea = new ExpirationAttributes(hrqa.getExpiryTime(), ExpirationAction.LOCAL_INVALIDATE); this.region.setOwner(this); this.region.getAttributesMutator().setEntryTimeToLive(ea); this.initialized.set(true); }
@Override public void close() { instance.processors.remove(windowId); region.getAttributesMutator().removeCacheListener(crash); permits.release(MAX_PERMITS); }
final boolean regionExpiry[] = {false}; AttributesMutator mutator = exprReg.getAttributesMutator(); mutator.setCacheListener(new CacheListenerAdapter() { public void close() {} public void afterCreate(EntryEvent e) {} action = exprAtt.getAction(); if (useTTL) { mutator.setRegionTimeToLive(exprAtt); } else { mutator.setRegionIdleTimeout(exprAtt);
/** * Changes the timeToLive expiration attributes for the partitioned region as * a whole * * @param timeToLive * the expiration attributes for the region timeToLive * @return the previous value of region timeToLive * @throws IllegalArgumentException * if timeToLive is null or if the ExpirationAction is * LOCAL_INVALIDATE and the region is * {@link DataPolicy#withReplication replicated} * @throws IllegalStateException * if statistics are disabled for this region. */ @Override public ExpirationAttributes setRegionTimeToLive( ExpirationAttributes timeToLive) { ExpirationAttributes attr = super.setRegionTimeToLive(timeToLive); // Set to Bucket regions as well if (this.getDataStore() != null) { // not for accessors Iterator iter = this.getDataStore().getAllLocalBuckets().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry)iter.next(); Region bucketRegion = (BucketRegion)entry.getValue(); bucketRegion.getAttributesMutator().setRegionTimeToLive(timeToLive); } } return attr; }
protected void initialize() { super.initialize(); Region aRegion = CacheUtil.getRegion(REGION_NAME); int currentPoint = ((Integer)CapConBB.getBB().getSharedMap().get(CapConBB.CURRENT_POINT)).intValue(); int mm = currentPoint * boundsMultiplier; EvictionAttributesMutator mutator = aRegion.getAttributesMutator().getEvictionAttributesMutator(); mutator.setMaximum(mm); Log.getLogWriter().info("Memory evictor is set to " + mm + " megabytes"); memLRUParams = new MemLRUParameters(KEY_LENGTH, 1 * boundsMultiplier, aRegion); CapConBB.getBB().getSharedMap().put(CapConBB.TEST_SETTINGS, memLRUParams); }
Map.Entry entry = (Map.Entry)iter.next(); Region bucketRegion = (BucketRegion)entry.getValue(); bucketRegion.getAttributesMutator().setEntryIdleTimeout(idleTimeout);
aRegion.getAttributesMutator().removeCacheListener(assignedListeners[j]); aRegion.getAttributesMutator().addCacheListener(eeListener);
/** * Changes the idleTimeout expiration attributes for the region as a whole. * Resets the {@link CacheStatistics#getLastAccessedTime} for the region. * * @param idleTimeout * the ExpirationAttributes for this region idleTimeout * @return the previous value of region idleTimeout * @throws IllegalArgumentException * if idleTimeout is null or if the ExpirationAction is * LOCAL_INVALIDATE and the region is * {@link DataPolicy#withReplication replicated} * @throws IllegalStateException * if statistics are disabled for this region. */ @Override public ExpirationAttributes setRegionIdleTimeout( ExpirationAttributes idleTimeout) { ExpirationAttributes attr = super.setRegionIdleTimeout(idleTimeout); // Set to Bucket regions as well if (this.getDataStore() != null) { // not for accessors Iterator iter = this.getDataStore().getAllLocalBuckets().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry)iter.next(); Region bucketRegion = (BucketRegion)entry.getValue(); bucketRegion.getAttributesMutator().setRegionIdleTimeout(idleTimeout); } } return attr; }
/** * Initializes the listener list with a single listener (set vs. init) * * @param aRegion - the targeted region for the listener operation */ protected void setListener(Region aRegion) { AttributesMutator mutator = aRegion.getAttributesMutator(); Log.getLogWriter().info("Clearing existing listenerList of " + getCacheListenerNames(aRegion)); // Clear out existing listeners (to avoid IllegalStateException if > 1) mutator.initCacheListeners( null ); Log.getLogWriter().info("After init (with null array) list = " + getCacheListenerNames(aRegion)); CacheListener newListener = getNewListener(); Log.getLogWriter().info("setListener calling setCacheListener with " + ((MultiListener)newListener).getName()); // Add a random listener from the list of availableListeners mutator.setCacheListener( newListener ); Log.getLogWriter().info("After setCacheListener cacheListenerList = " + getCacheListenerNames(aRegion)); }