private boolean isIncludedJsonRegion(Region region) { boolean result = false; if (isIncludedJsonRegion(toRegionName(region), toRegionPath(region))) { if (log.isDebugEnabled()) { log.debug(String.format("Region [%s] is included for JSON conversion", region.getName())); } result = true; } return result; }
RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(dataPolicy, this.persistent); RegionUtils.assertClientRegionShortcutAndPersistentAttributeAreCompatible(resolvedShortcut, this.persistent);
protected PartitionRegionCacheStatistics(Region<?, ?> region) { Assert.isInstanceOf(PartitionedRegion.class, region, () -> String.format("Region [%1$s] must be of type [%2$s]", RegionUtils.toRegionPath(region), PartitionedRegion.class.getName())); this.partitionRegion = computeStatistics((PartitionedRegion) region); }
@Override protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) { if (dataPolicy == null) { dataPolicy = (isPersistent() ? DataPolicy.PERSISTENT_PARTITION : DataPolicy.PARTITION); } else { // Validate that the user-defined Data Policy matches the appropriate Spring GemFire XML namespace // configuration meta-data element for Region (i.e. <gfe:partitioned-region .../>)! Assert.isTrue(dataPolicy.withPartitioning(), String.format( "Data Policy '%1$s' is not supported in Partitioned Regions.", dataPolicy)); } // Validate the data-policy and persistent attributes are compatible when specified! RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(dataPolicy, persistent); regionFactory.setDataPolicy(dataPolicy); setDataPolicy(dataPolicy); }
/** * Sets regions to be included for JSON conversion. By default, all regions will be included * * @param regions a List of region names to include */ public void setIncludedRegions(List<Region<?, ?>> regions) { nullSafeList(regions).forEach(region -> this.includedRegions.add(toRegionName(region))); }
/** * Constructs a Pivotal GemFire {@link Index} over the attributes of the {@link HttpSession}. * * @return a Pivotal GemFire {@link Index} over the {@link HttpSession} attributes. * @throws Exception if an error occurs while initializing the Pivotal GemFire {@link Index}. * @see org.springframework.data.gemfire.IndexFactoryBean */ protected Index newIndex() throws Exception { IndexFactoryBean indexFactory = new IndexFactoryBean(); indexFactory.setBeanFactory(this.beanFactory); indexFactory.setBeanName(this.beanName); indexFactory.setCache(this.gemfireCache); indexFactory.setName("sessionAttributesIndex"); indexFactory.setExpression(String.format("s.attributes[%1$s]", getIndexableSessionAttributesAsGemFireIndexExpression())); indexFactory.setFrom(String.format("%1$s s", RegionUtils.toRegionPath(this.regionName))); indexFactory.setOverride(true); indexFactory.afterPropertiesSet(); return indexFactory.getObject(); }
@Override protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) { if (dataPolicy == null) { dataPolicy = (isPersistent() ? DataPolicy.PERSISTENT_REPLICATE : DataPolicy.REPLICATE); } else if (DataPolicy.EMPTY.equals(dataPolicy)) { dataPolicy = DataPolicy.EMPTY; } else { // Validate that the user-defined Data Policy matches the appropriate Spring GemFire XML namespace // configuration meta-data element for the Region (i.e. <gfe:replicated-region .../>)! Assert.isTrue(dataPolicy.withReplication(), String.format( "Data Policy '%1$s' is not supported in Replicated Regions.", dataPolicy)); } // Validate that the data-policy and persistent attributes are compatible when both are specified! RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(dataPolicy, persistent); regionFactory.setDataPolicy(dataPolicy); setDataPolicy(dataPolicy); }
/** * Sets regions to be included for JSON conversion. By default, all regions will be included * * @param regions a List of region names to include */ public void setIncludedRegions(List<Region<?, ?>> regions) { nullSafeList(regions).forEach(region -> this.includedRegions.add(toRegionName(region))); }
private boolean isIncludedJsonRegion(Region region) { boolean result = false; if (isIncludedJsonRegion(toRegionName(region), toRegionPath(region))) { if (log.isDebugEnabled()) { log.debug(String.format("Region [%s] is included for JSON conversion", region.getName())); } result = true; } return result; }
/** * Defines a Pivotal GemFire Index bean on the Pivotal GemFire cache {@link Region} storing and managing Sessions, * specifically on the 'principalName' property for quick lookup of Sessions by 'principalName'. * * @param gemfireCache a reference to the Pivotal GemFire cache. * @return a {@link IndexFactoryBean} to create an Pivotal GemFire Index on the 'principalName' property * for Sessions stored in the Pivotal GemFire cache {@link Region}. * @see org.springframework.data.gemfire.IndexFactoryBean * @see org.apache.geode.cache.GemFireCache */ @Bean @DependsOn(DEFAULT_SESSION_REGION_NAME) public IndexFactoryBean principalNameIndex(GemFireCache gemfireCache) { IndexFactoryBean principalNameIndex = new IndexFactoryBean(); principalNameIndex.setCache(gemfireCache); principalNameIndex.setName("principalNameIndex"); principalNameIndex.setExpression("principalName"); principalNameIndex.setFrom(RegionUtils.toRegionPath(getSessionRegionName())); principalNameIndex.setOverride(true); principalNameIndex.setType(IndexType.HASH); return principalNameIndex; }
@Override protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) { if (dataPolicy == null) { dataPolicy = (isPersistent() ? DataPolicy.PERSISTENT_REPLICATE : DataPolicy.REPLICATE); } else if (DataPolicy.EMPTY.equals(dataPolicy)) { dataPolicy = DataPolicy.EMPTY; } else { // Validate that the user-defined Data Policy matches the appropriate Spring Pivotal GemFire XML namespace // configuration meta-data element for the Region (i.e. <gfe:replicated-region .../>)! Assert.isTrue(dataPolicy.withReplication(), String.format( "Data Policy '%1$s' is not supported in Replicated Regions.", dataPolicy)); } // Validate that the data-policy and persistent attributes are compatible when both are specified! RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(dataPolicy, persistent); regionFactory.setDataPolicy(dataPolicy); setDataPolicy(dataPolicy); }
RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(dataPolicy, this.persistent); RegionUtils.assertClientRegionShortcutAndPersistentAttributeAreCompatible(resolvedShortcut, this.persistent);
@Override protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) { if (dataPolicy == null) { dataPolicy = (isPersistent() ? DataPolicy.PERSISTENT_PARTITION : DataPolicy.PARTITION); } else { // Validate that the user-defined Data Policy matches the appropriate Spring Pivotal GemFire XML namespace // configuration meta-data element for Region (i.e. <gfe:partitioned-region .../>)! Assert.isTrue(dataPolicy.withPartitioning(), String.format( "Data Policy '%1$s' is not supported in Partitioned Regions.", dataPolicy)); } // Validate the data-policy and persistent attributes are compatible when specified! RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(dataPolicy, persistent); regionFactory.setDataPolicy(dataPolicy); setDataPolicy(dataPolicy); }
/** * Validates and sets the {@link DataPolicy} on the {@link RegionFactory} used to create and configure * the {@link Region} from this {@link FactoryBean}. * * @param regionFactory the RegionFactory used by this FactoryBean to create and configure the Region. * @param persistent a boolean value indicating whether the Region should be persistent and persist it's * data to disk. * @param dataPolicy the configured Data Policy for the Region. * @see #resolveDataPolicy(org.apache.geode.cache.RegionFactory, Boolean, String) * @see org.apache.geode.cache.DataPolicy * @see org.apache.geode.cache.RegionFactory */ protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) { if (dataPolicy != null) { RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(dataPolicy, this.persistent); regionFactory.setDataPolicy(dataPolicy); setDataPolicy(dataPolicy); } else { resolveDataPolicy(regionFactory, persistent, (String) null); } }
/** * Validates and sets the Data Policy on the RegionFactory used to create and configure the Region from this * FactoryBean. * * @param regionFactory the RegionFactory used by this FactoryBean to create and configure the Region. * @param persistent a boolean value indicating whether the Region should be persistent and persist it's * data to disk. * @param dataPolicy the configured Data Policy for the Region. * @see #resolveDataPolicy(org.apache.geode.cache.RegionFactory, Boolean, String) * @see org.apache.geode.cache.DataPolicy * @see org.apache.geode.cache.RegionFactory */ protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, DataPolicy dataPolicy) { if (dataPolicy != null) { RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(dataPolicy, this.persistent); regionFactory.setDataPolicy(dataPolicy); setDataPolicy(dataPolicy); } else { resolveDataPolicy(regionFactory, persistent, (String) null); } }
/** * Validates the configured Data Policy and may override it, taking into account the 'persistent' attribute * and constraints for the Region type. * * @param regionFactory the GemFire RegionFactory used to create the desired Region. * @param persistent a boolean value indicating whether the Region should persist it's data to disk. * @param dataPolicy requested Data Policy as set by the user in the Spring GemFire configuration meta-data. * @see org.apache.geode.cache.DataPolicy * @see org.apache.geode.cache.RegionFactory */ protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, String dataPolicy) { if (dataPolicy != null) { DataPolicy resolvedDataPolicy = new DataPolicyConverter().convert(dataPolicy); Assert.notNull(resolvedDataPolicy, String.format("Data Policy [%s] is invalid", dataPolicy)); RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(resolvedDataPolicy, this.persistent); regionFactory.setDataPolicy(resolvedDataPolicy); setDataPolicy(resolvedDataPolicy); } else { DataPolicy regionAttributesDataPolicy = getDataPolicy(getAttributes(), DataPolicy.DEFAULT); DataPolicy resolvedDataPolicy = isPersistent() && DataPolicy.DEFAULT.equals(regionAttributesDataPolicy) ? DataPolicy.PERSISTENT_REPLICATE : regionAttributesDataPolicy; RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(resolvedDataPolicy, this.persistent); regionFactory.setDataPolicy(resolvedDataPolicy); setDataPolicy(resolvedDataPolicy); } }
/** * Validates the configured Data Policy and may override it, taking into account the 'persistent' attribute * and constraints for the Region type. * * @param regionFactory the Pivotal GemFire RegionFactory used to create the desired Region. * @param persistent a boolean value indicating whether the Region should persist it's data to disk. * @param dataPolicy requested Data Policy as set by the user in the Spring Pivotal GemFire configuration meta-data. * @see org.apache.geode.cache.DataPolicy * @see org.apache.geode.cache.RegionFactory */ protected void resolveDataPolicy(RegionFactory<K, V> regionFactory, Boolean persistent, String dataPolicy) { if (dataPolicy != null) { DataPolicy resolvedDataPolicy = new DataPolicyConverter().convert(dataPolicy); Assert.notNull(resolvedDataPolicy, String.format("Data Policy [%s] is invalid", dataPolicy)); RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(resolvedDataPolicy, this.persistent); regionFactory.setDataPolicy(resolvedDataPolicy); setDataPolicy(resolvedDataPolicy); } else { DataPolicy regionAttributesDataPolicy = getDataPolicy(getAttributes(), DataPolicy.DEFAULT); DataPolicy resolvedDataPolicy = isPersistent() && DataPolicy.DEFAULT.equals(regionAttributesDataPolicy) ? DataPolicy.PERSISTENT_REPLICATE : regionAttributesDataPolicy; RegionUtils.assertDataPolicyAndPersistentAttributeAreCompatible(resolvedDataPolicy, this.persistent); regionFactory.setDataPolicy(resolvedDataPolicy); setDataPolicy(resolvedDataPolicy); } }