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() { // Bootstrap the servers bootstrapServers(); // Create or retrieve the region try { createOrRetrieveRegion(); } catch (Exception ex) { sessionManager.getLogger().fatal("Unable to create or retrieve region", ex); throw new IllegalStateException(ex); } // Set the session region directly as the operating region since there is no difference // between the local cache region and the session region. this.operatingRegion = this.sessionRegion; // Create or retrieve the statistics createStatistics(); }
protected void createOrRetrieveRegion() { // Retrieve the local session region this.sessionRegion = this.cache.getRegion(getSessionManager().getRegionName()); // If necessary, create the regions on the server and client if (this.sessionRegion == null) { // Create the PR on the servers createSessionRegionOnServers(); // Create the region on the client this.sessionRegion = createLocalSessionRegion(); if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger().debug("Created session region: " + this.sessionRegion); } } else { if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger().debug("Retrieved session region: " + this.sessionRegion); } // Check that we have our expiration listener attached if (!regionHasExpirationListenerAttached(sessionRegion)) { sessionRegion.getAttributesMutator().addCacheListener(new SessionExpirationCacheListener()); } // This is true for PROXY regions if (sessionRegion.getAttributes().getDataPolicy() == DataPolicy.EMPTY) { sessionRegion.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS); } } }
@Override public boolean isBackingCacheAvailable() { if (getSessionManager().isCommitValveFailfastEnabled()) { PoolImpl pool = (PoolImpl) PoolManager.find(getOperatingRegionName()); return pool.isPrimaryUpdaterAlive(); } return true; }
private void createSessionRegionOnServers() { // Create the RegionConfiguration RegionConfiguration configuration = createRegionConfiguration(); // Send it to the server tier Execution execution = FunctionService.onServer(this.cache).setArguments(configuration); ResultCollector collector = execution.execute(CreateRegionFunction.ID); // Verify the region was successfully created on the servers List<RegionStatus> results = (List<RegionStatus>) collector.getResult(); for (RegionStatus status : results) { if (status == RegionStatus.INVALID) { StringBuilder builder = new StringBuilder(); builder .append( "An exception occurred on the server while attempting to create or validate region named ") .append(getSessionManager().getRegionName()) .append(". See the server log for additional details."); throw new IllegalStateException(builder.toString()); } } }
String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase(); Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds); try { ResultCollector collector = execution.execute(TouchPartitionedRegionEntriesFunction.ID); } catch (Exception e) { getSessionManager().getLogger().warn("Caught unexpected exception:", e); Execution execution = FunctionService.onServers(getCache()) .setArguments(new Object[] {this.sessionRegion.getFullPath(), sessionIds}); try { } catch (Exception e) { getSessionManager().getLogger().warn("Caught unexpected exception:", e);
protected void createOrRetrieveRegion() { // Retrieve the local session region this.sessionRegion = this.cache.getRegion(getSessionManager().getRegionName()); // If necessary, create the regions on the server and client if (this.sessionRegion == null) { // Create the PR on the servers createSessionRegionOnServers(); // Create the region on the client this.sessionRegion = createLocalSessionRegion(); if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger().debug("Created session region: " + this.sessionRegion); } } else { if (getSessionManager().getLogger().isDebugEnabled()) { getSessionManager().getLogger().debug("Retrieved session region: " + this.sessionRegion); } } }
private Region<String, HttpSession> createLocalSessionRegion() { ClientRegionFactory<String, HttpSession> factory = null; if (getSessionManager().getEnableLocalCache()) { int maxInactiveInterval = getSessionManager().getMaxInactiveInterval(); if (maxInactiveInterval != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) { factory.setStatisticsEnabled(true); Region region = factory.create(getSessionManager().getRegionName()); if (!getSessionManager().getEnableLocalCache()) { region.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS);
String regionAttributesID = getSessionManager().getRegionAttributesId().toLowerCase(); Execution execution = FunctionService.onRegion(getSessionRegion()).withFilter(sessionIds); try { ResultCollector collector = } catch (Exception e) { getSessionManager().getLogger().warn("Caught unexpected exception:", e); Execution execution = FunctionService.onServers(getCache()) .setArguments(new Object[] {this.sessionRegion.getFullPath(), sessionIds}); try { } catch (Exception e) { getSessionManager().getLogger().warn("Caught unexpected exception:", e);
@Override public boolean isBackingCacheAvailable() { if (getSessionManager().isCommitValveFailfastEnabled()) { PoolImpl pool = (PoolImpl) PoolManager.find(getOperatingRegionName()); return pool.isPrimaryUpdaterAlive(); } return true; }
private void createSessionRegionOnServers() { // Create the RegionConfiguration RegionConfiguration configuration = createRegionConfiguration(); // Send it to the server tier Execution execution = FunctionService.onServer(this.cache).setArguments(configuration); ResultCollector collector = execution.execute(CreateRegionFunction.ID); // Verify the region was successfully created on the servers List<RegionStatus> results = (List<RegionStatus>) collector.getResult(); for (RegionStatus status : results) { if (status == RegionStatus.INVALID) { StringBuilder builder = new StringBuilder(); builder .append( "An exception occurred on the server while attempting to create or validate region named ") .append(getSessionManager().getRegionName()) .append(". See the server log for additional details."); throw new IllegalStateException(builder.toString()); } } }
private void bootstrapServers() { Execution execution = FunctionService.onServers(this.cache); ResultCollector collector = execution.execute(new BootstrappingFunction()); // Get the result. Nothing is being done with it. try { collector.getResult(); } catch (Exception e) { // If an exception occurs in the function, log it. getSessionManager().getLogger().warn("Caught unexpected exception:", e); } }
@Override public void initialize() { // Bootstrap the servers bootstrapServers(); // Create or retrieve the region try { createOrRetrieveRegion(); } catch (Exception ex) { sessionManager.getLogger().fatal("Unable to create or retrieve region", ex); throw new IllegalStateException(ex); } // Set the session region directly as the operating region since there is no difference // between the local cache region and the session region. this.operatingRegion = this.sessionRegion; // Create or retrieve the statistics createStatistics(); }
private Region<String, HttpSession> createLocalSessionRegion() { ClientRegionFactory<String, HttpSession> factory = null; if (getSessionManager().getEnableLocalCache()) { int maxInactiveInterval = getSessionManager().getMaxInactiveInterval(); if (maxInactiveInterval != RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) { factory.setStatisticsEnabled(true); Region region = factory.create(getSessionManager().getRegionName()); if (!getSessionManager().getEnableLocalCache()) { region.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS);
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(); }
private void bootstrapServers() { Execution execution = FunctionService.onServers(this.cache); ResultCollector collector = execution.execute(new BootstrappingFunction()); // Get the result. Nothing is being done with it. try { collector.getResult(); } catch (Exception e) { // If an exception occurs in the function, log it. getSessionManager().getLogger().warn("Caught unexpected exception:", e); } }