Search in sources :

Example 1 with RegionConfiguration

use of org.apache.geode.modules.util.RegionConfiguration in project geode by apache.

the class AbstractSessionCache method createRegionConfiguration.

/**
   * Build up a {@code RegionConfiguraton} object from parameters originally passed in as filter
   * initialization parameters.
   *
   * @return a {@code RegionConfiguration} object
   */
protected RegionConfiguration createRegionConfiguration() {
    RegionConfiguration configuration = new RegionConfiguration();
    configuration.setRegionName((String) properties.get(CacheProperty.REGION_NAME));
    configuration.setRegionAttributesId((String) properties.get(CacheProperty.REGION_ATTRIBUTES_ID));
    configuration.setEnableGatewayDeltaReplication((Boolean) properties.get(CacheProperty.ENABLE_GATEWAY_DELTA_REPLICATION));
    configuration.setEnableGatewayReplication((Boolean) properties.get(CacheProperty.ENABLE_GATEWAY_REPLICATION));
    configuration.setEnableDebugListener((Boolean) properties.get(CacheProperty.ENABLE_DEBUG_LISTENER));
    return configuration;
}
Also used : RegionConfiguration(org.apache.geode.modules.util.RegionConfiguration)

Example 2 with RegionConfiguration

use of org.apache.geode.modules.util.RegionConfiguration in project geode by apache.

the class PeerToPeerSessionCache method createOrRetrieveRegion.

@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;
}
Also used : RegionConfiguration(org.apache.geode.modules.util.RegionConfiguration) Region(org.apache.geode.cache.Region) Cache(org.apache.geode.cache.Cache) GemFireCache(org.apache.geode.cache.GemFireCache)

Example 3 with RegionConfiguration

use of org.apache.geode.modules.util.RegionConfiguration 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;
}
Also used : RegionConfiguration(org.apache.geode.modules.util.RegionConfiguration) SessionCustomExpiry(org.apache.geode.modules.util.SessionCustomExpiry)

Example 4 with RegionConfiguration

use of org.apache.geode.modules.util.RegionConfiguration in project geode by apache.

the class ClientServerSessionCache method createSessionRegionOnServers.

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());
        }
    }
}
Also used : RegionConfiguration(org.apache.geode.modules.util.RegionConfiguration) Execution(org.apache.geode.cache.execute.Execution) RegionStatus(org.apache.geode.modules.util.RegionStatus) List(java.util.List) ResultCollector(org.apache.geode.cache.execute.ResultCollector)

Example 5 with RegionConfiguration

use of org.apache.geode.modules.util.RegionConfiguration in project geode by apache.

the class PeerToPeerSessionCache method createOrRetrieveRegion.

private void createOrRetrieveRegion() {
    // Create the RegionConfiguration
    RegionConfiguration configuration = createRegionConfiguration();
    // Attempt to retrieve the region
    // If it already exists, validate it
    // If it doesn't already exist, create it
    Region region = this.cache.getRegion((String) properties.get(CacheProperty.REGION_NAME));
    if (region == null) {
        // Create the region
        region = RegionHelper.createRegion(cache, configuration);
        LOG.info("Created new session region: {}", region);
    } else {
        // Validate the existing region
        LOG.info("Retrieved existing session region: {}", region);
        RegionHelper.validateRegion(cache, configuration, region);
    }
    // Set the session region
    this.sessionRegion = region;
}
Also used : RegionConfiguration(org.apache.geode.modules.util.RegionConfiguration) Region(org.apache.geode.cache.Region)

Aggregations

RegionConfiguration (org.apache.geode.modules.util.RegionConfiguration)6 List (java.util.List)2 Region (org.apache.geode.cache.Region)2 Execution (org.apache.geode.cache.execute.Execution)2 ResultCollector (org.apache.geode.cache.execute.ResultCollector)2 RegionStatus (org.apache.geode.modules.util.RegionStatus)2 Cache (org.apache.geode.cache.Cache)1 GemFireCache (org.apache.geode.cache.GemFireCache)1 SessionCustomExpiry (org.apache.geode.modules.util.SessionCustomExpiry)1