protected void initializeSessionCache() { // Retrieve the cache GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance(); if (cache == null) { throw new IllegalStateException( "No cache exists. Please configure either a PeerToPeerCacheLifecycleListener or ClientServerCacheLifecycleListener in the server.xml file."); } // Create the appropriate session cache this.sessionCache = cache.isClient() ? new ClientServerSessionCache(this, cache) : new PeerToPeerSessionCache(this, cache); // Initialize the session cache this.sessionCache.initialize(); }
@Override public void initialize() { // Register Functions registerFunctions(); // Create or retrieve the region createOrRetrieveRegion(); // If local cache is enabled, create the local region fronting the session region // and set it as the operating region; otherwise, use the session region directly // as the operating region. this.operatingRegion = getSessionManager().getEnableLocalCache() ? createOrRetrieveLocalRegion() : this.sessionRegion; // Create or retrieve the statistics createStatistics(); }
@SuppressWarnings("unchecked") protected void createOrRetrieveRegion() { // Create the RegionConfiguration RegionConfiguration configuration = createRegionConfiguration(); configuration.setSessionExpirationCacheListener(true); // Attempt to retrieve the region // If it already exists, validate it // If it doesn't already exist, create it Region region = this.cache.getRegion(getSessionManager().getRegionName()); if (region == null) { // Create the region region = RegionHelper.createRegion((Cache) getCache(), configuration); if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger().debug("Created new session region: " + region); } } else { // Validate the existing region if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger().debug("Retrieved existing session region: " + region); } RegionHelper.validateRegion((Cache) getCache(), configuration, region); } // Set the session region this.sessionRegion = region; }
@Override public void touchSessions(Set<String> sessionIds) { // Get the region attributes id to determine the region type. This is // problematic since the region attributes id doesn't really define the // region type. This should look at the actual session region. String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase(); // Invoke the appropriate function depending on the type of region ResultCollector collector = null; if (regionAttributesID.startsWith("partition")) { // Execute the partitioned touch function on the primary server(s) Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds); collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID); } else { // Execute the member touch function on all the server(s) Execution execution = FunctionService.onMembers() .setArguments(new Object[] {this.sessionRegion.getFullPath(), sessionIds}); collector = execution.execute(TouchReplicatedRegionEntriesFunction.ID); } // Get the result try { collector.getResult(); } catch (Exception e) { // If an exception occurs in the function, log it. getSessionManager().getLogger().warn("Caught unexpected exception:", e); } }
@Override public Set<String> keySet() { return getSessionRegion().keySet(); }
int maxInactiveInterval = getSessionManager().getMaxInactiveInterval(); if (maxInactiveInterval != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) { factory.setStatisticsEnabled(true); if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger() .debug("Created new local session region: " + frontingRegion); if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger() .debug("Retrieved existing local session region: " + frontingRegion);
@Override public void touchSessions(Set<String> sessionIds) { // Get the region attributes id to determine the region type. This is // problematic since the region attributes id doesn't really define the // region type. This should look at the actual session region. String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase(); // Invoke the appropriate function depending on the type of region ResultCollector collector = null; if (regionAttributesID.startsWith("partition")) { // Execute the partitioned touch function on the primary server(s) Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds); collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID, true, false, true); } else { // Execute the member touch function on all the server(s) Execution execution = FunctionService.onMembers() .setArguments(new Object[] {this.sessionRegion.getFullPath(), sessionIds}); collector = execution.execute(TouchReplicatedRegionEntriesFunction.ID, true, false, false); } // Get the result try { collector.getResult(); } catch (Exception e) { // If an exception occurs in the function, log it. getSessionManager().getLogger().warn("Caught unexpected exception:", e); } }
@Override public int size() { return getSessionRegion().size(); }
int maxInactiveInterval = getSessionManager().getMaxInactiveInterval(); if (maxInactiveInterval != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) { factory.setStatisticsEnabled(true); if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger() .debug("Created new local session region: " + frontingRegion); if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger() .debug("Retrieved existing local session region: " + frontingRegion);
@Override public void initialize() { // Register Functions registerFunctions(); // Create or retrieve the region createOrRetrieveRegion(); // If local cache is enabled, create the local region fronting the session region // and set it as the operating region; otherwise, use the session region directly // as the operating region. this.operatingRegion = getSessionManager().getEnableLocalCache() ? createOrRetrieveLocalRegion() : this.sessionRegion; // Create or retrieve the statistics createStatistics(); }
@SuppressWarnings("unchecked") protected void createOrRetrieveRegion() { // Create the RegionConfiguration RegionConfiguration configuration = createRegionConfiguration(); configuration.setSessionExpirationCacheListener(true); // Attempt to retrieve the region // If it already exists, validate it // If it doesn't already exist, create it Region region = this.cache.getRegion(getSessionManager().getRegionName()); if (region == null) { // Create the region region = RegionHelper.createRegion((Cache) getCache(), configuration); if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger().debug("Created new session region: " + region); } } else { // Validate the existing region if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger().debug("Retrieved existing session region: " + region); } RegionHelper.validateRegion((Cache) getCache(), configuration, region); } // Set the session region this.sessionRegion = region; }
@Override public Set<String> keySet() { return getSessionRegion().keySet(); }
protected void initializeSessionCache() { // Retrieve the cache GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance(); if (cache == null) { throw new IllegalStateException( "No cache exists. Please configure either a PeerToPeerCacheLifecycleListener or ClientServerCacheLifecycleListener in the server.xml file."); } // Create the appropriate session cache this.sessionCache = cache.isClient() ? new ClientServerSessionCache(this, cache) : new PeerToPeerSessionCache(this, cache); // Initialize the session cache this.sessionCache.initialize(); }
@Override public int size() { return getSessionRegion().size(); }