com.googlecode.icegem.expiration
Class ExpirationController

java.lang.Object
  extended by com.googlecode.icegem.expiration.ExpirationController

public class ExpirationController
extends java.lang.Object

The class which can expire region entries using custom policy (strategy).

Example:

 
 Region dataRegion = ...;
 Region errorsRegion = ...;
 
 ExpirationController expirationController = new ExpirationController();
 
 long destroyedEntriesNumberForData = expirationController.process(dataRegion,
        new ExpirationPolicy() {
 
                public boolean isExpired(Entry<Object, Object> entry) {
                        // TODO: Add some logic
                        return false;
                }
        });
 
 long destroyedEntriesNumberForErrors = expirationController.process(errorsRegion,
        new ExpirationPolicy() {
 
                public boolean isExpired(Entry<Object, Object> entry) {
                        // TODO: Add some logic
                        return false;
                }
        });
 
 

You can get access to the other regions inside of isExpired(Entry<Object, Object>) method in the following way:

 new ExpirationPolicy() {
 
   public boolean isExpired(Entry<Object, Object> entry) {
     RegionService regionService = entry.getRegion().getRegionService();
     Region errorsRegion = regionService.getRegion("errors");
 
     // TODO: Add some logic
     return false;
   }
 });
 


Constructor Summary
ExpirationController()
           
 
Method Summary
 long getPacketDelay()
          Gets the delay in processing after the packetSize entries, milliseconds
 long getPacketSize()
          Gets the size of the consistently expired entries packet
 long process(com.gemstone.gemfire.cache.Region<?,?> region, ExpirationPolicy policy)
          Applies the specified policy on the specified region and returns number of destroyed entries.
 void setPacketDelay(long packetDelay)
          Sets the delay in processing after the packetSize entries, milliseconds
 void setPacketSize(long packetSize)
          Gets the size of the consistently expired entries packet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpirationController

public ExpirationController()
Method Detail

getPacketSize

public long getPacketSize()
Gets the size of the consistently expired entries packet

Returns:
- the packet size

setPacketSize

public void setPacketSize(long packetSize)
Gets the size of the consistently expired entries packet

Parameters:
packetSize - - the packet size

getPacketDelay

public long getPacketDelay()
Gets the delay in processing after the packetSize entries, milliseconds

Returns:
- the packet delay

setPacketDelay

public void setPacketDelay(long packetDelay)
Sets the delay in processing after the packetSize entries, milliseconds

Parameters:
packetDelay - - the packet delay

process

public long process(com.gemstone.gemfire.cache.Region<?,?> region,
                    ExpirationPolicy policy)
Applies the specified policy on the specified region and returns number of destroyed entries.

Parameters:
region - - the region
policy - - the expiration policy
Returns:
- the number of destroyed region entries


Copyright © 2011. All Rights Reserved.