Search in sources :

Example 1 with LocalSessionCacheWriter

use of org.apache.geode.modules.session.catalina.callback.LocalSessionCacheWriter in project geode by apache.

the class PeerToPeerSessionCache method createOrRetrieveLocalRegion.

/**
   * Create a local region fronting the main region.
   *
   * @return
   */
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));
        // Create the region
        frontingRegion = factory.create(frontingRegionName);
        LOG.info("Created new local session region: {}", frontingRegion);
    } else {
        LOG.info("Retrieved existing local session region: {}", frontingRegion);
    }
    return frontingRegion;
}
Also used : HttpSession(javax.servlet.http.HttpSession) LocalSessionCacheLoader(org.apache.geode.modules.session.catalina.callback.LocalSessionCacheLoader) LocalSessionCacheWriter(org.apache.geode.modules.session.catalina.callback.LocalSessionCacheWriter)

Example 2 with LocalSessionCacheWriter

use of org.apache.geode.modules.session.catalina.callback.LocalSessionCacheWriter 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;
}
Also used : HttpSession(javax.servlet.http.HttpSession) SessionExpirationCacheListener(org.apache.geode.modules.session.catalina.callback.SessionExpirationCacheListener) SessionCustomExpiry(org.apache.geode.modules.util.SessionCustomExpiry) LocalSessionCacheLoader(org.apache.geode.modules.session.catalina.callback.LocalSessionCacheLoader) LocalSessionCacheWriter(org.apache.geode.modules.session.catalina.callback.LocalSessionCacheWriter)

Aggregations

HttpSession (javax.servlet.http.HttpSession)2 LocalSessionCacheLoader (org.apache.geode.modules.session.catalina.callback.LocalSessionCacheLoader)2 LocalSessionCacheWriter (org.apache.geode.modules.session.catalina.callback.LocalSessionCacheWriter)2 SessionExpirationCacheListener (org.apache.geode.modules.session.catalina.callback.SessionExpirationCacheListener)1 SessionCustomExpiry (org.apache.geode.modules.util.SessionCustomExpiry)1