use of org.apache.geode.modules.util.SessionCustomExpiry in project geode by apache.
the class PeerToPeerSessionCache method createOrRetrieveLocalRegion.
private Region<String, HttpSession> createOrRetrieveLocalRegion() {
// Attempt to retrieve the fronting region
String frontingRegionName = this.sessionRegion.getName() + "_local";
Region<String, HttpSession> frontingRegion = this.cache.getRegion(frontingRegionName);
if (frontingRegion == null) {
// Create the region factory
RegionFactory<String, HttpSession> factory = this.cache.createRegionFactory(RegionShortcut.LOCAL_HEAP_LRU);
// Add the cache loader and writer
factory.setCacheLoader(new LocalSessionCacheLoader(this.sessionRegion));
factory.setCacheWriter(new LocalSessionCacheWriter(this.sessionRegion));
// Set the expiration time, action and listener if necessary
int maxInactiveInterval = getSessionManager().getMaxInactiveInterval();
if (maxInactiveInterval != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) {
factory.setStatisticsEnabled(true);
factory.setCustomEntryIdleTimeout(new SessionCustomExpiry());
factory.addCacheListener(new SessionExpirationCacheListener());
}
// Create the region
frontingRegion = factory.create(frontingRegionName);
if (getSessionManager().getLogger().isDebugEnabled()) {
getSessionManager().getLogger().debug("Created new local session region: " + frontingRegion);
}
} else {
if (getSessionManager().getLogger().isDebugEnabled()) {
getSessionManager().getLogger().debug("Retrieved existing local session region: " + frontingRegion);
}
}
return frontingRegion;
}
use of org.apache.geode.modules.util.SessionCustomExpiry in project geode by apache.
the class AbstractSessionCache method createRegionConfiguration.
protected RegionConfiguration createRegionConfiguration() {
RegionConfiguration configuration = new RegionConfiguration();
configuration.setRegionName(getSessionManager().getRegionName());
configuration.setRegionAttributesId(getSessionManager().getRegionAttributesId());
if (getSessionManager().getMaxInactiveInterval() != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) {
configuration.setMaxInactiveInterval(getSessionManager().getMaxInactiveInterval());
configuration.setCustomExpiry(new SessionCustomExpiry());
}
configuration.setEnableGatewayDeltaReplication(getSessionManager().getEnableGatewayDeltaReplication());
configuration.setEnableGatewayReplication(getSessionManager().getEnableGatewayReplication());
configuration.setEnableDebugListener(getSessionManager().getEnableDebugListener());
return configuration;
}
use of org.apache.geode.modules.util.SessionCustomExpiry in project geode by apache.
the class ClientServerSessionCache method createLocalSessionRegion.
private Region<String, HttpSession> createLocalSessionRegion() {
ClientRegionFactory<String, HttpSession> factory = null;
if (getSessionManager().getEnableLocalCache()) {
// Create the region factory with caching and heap LRU enabled
factory = this.cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU);
// Set the expiration time, action and listener if necessary
int maxInactiveInterval = getSessionManager().getMaxInactiveInterval();
if (maxInactiveInterval != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) {
factory.setStatisticsEnabled(true);
factory.setCustomEntryIdleTimeout(new SessionCustomExpiry());
factory.addCacheListener(new SessionExpirationCacheListener());
}
} else {
// Create the region factory without caching enabled
factory = this.cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
factory.addCacheListener(new SessionExpirationCacheListener());
}
// Create the region
Region region = factory.create(getSessionManager().getRegionName());
/*
* If we're using an empty client region, we register interest so that expired sessions are
* destroyed correctly.
*/
if (!getSessionManager().getEnableLocalCache()) {
region.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS);
}
return region;
}
Aggregations