@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 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); } }
@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; }
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); } } }
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); } 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 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); } } }
@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; }
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); } }
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); } }