From b82a43d625679b32422ae03fdc27868e7c13358c Mon Sep 17 00:00:00 2001 From: John Blum Date: Wed, 20 Nov 2019 13:50:38 -0800 Subject: [PATCH] Convert all Spring Session HASH Indexes to FUNCTION/RANGE Indexes. Resolves gh-45. --- .../http/GemFireHttpSessionConfiguration.java | 28 +++++++++---------- .../SessionAttributesIndexFactoryBean.java | 19 ++++--------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/spring-session-data-geode/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.java b/spring-session-data-geode/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.java index a1af470..011b9b4 100644 --- a/spring-session-data-geode/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.java +++ b/spring-session-data-geode/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.java @@ -40,6 +40,7 @@ import org.apache.geode.cache.RegionShortcut; import org.apache.geode.cache.client.ClientCache; import org.apache.geode.cache.client.ClientRegionShortcut; import org.apache.geode.cache.client.Pool; +import org.apache.geode.cache.query.Index; import org.apache.geode.pdx.PdxSerializer; import org.springframework.beans.BeansException; @@ -65,7 +66,6 @@ import org.springframework.data.gemfire.GemfireOperations; import org.springframework.data.gemfire.GemfireTemplate; import org.springframework.data.gemfire.GemfireUtils; import org.springframework.data.gemfire.IndexFactoryBean; -import org.springframework.data.gemfire.IndexType; import org.springframework.data.gemfire.RegionAttributesFactoryBean; import org.springframework.data.gemfire.config.xml.GemfireConstants; import org.springframework.data.gemfire.util.ArrayUtils; @@ -1070,7 +1070,7 @@ public class GemFireHttpSessionConfiguration extends AbstractGemFireHttpSessionC * @see #isExpirationAllowed(GemFireCache) */ @Bean - @SuppressWarnings({ "unchecked", "deprecation" }) + @SuppressWarnings({ "unchecked" }) public RegionAttributesFactoryBean sessionRegionAttributes(GemFireCache gemfireCache) { RegionAttributesFactoryBean regionAttributes = new RegionAttributesFactoryBean(); @@ -1160,12 +1160,13 @@ public class GemFireHttpSessionConfiguration extends AbstractGemFireHttpSessionC } /** - * 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'. + * Defines an OQL {@link Index} bean on the {@link GemFireCache} {@link Region} storing and managing + * {@link Session Sessions}, specifically on the {@literal principalName} property for quick lookup + * of {@link Session Sessions} by {@literal 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}. + * @param gemfireCache reference to the {@link GemFireCache}. + * @return a {@link IndexFactoryBean} to create an OQL {@link Index} on the {@literal principalName} property + * for {@link Session Sessions} stored in the {@link GemFireCache} {@link Region}. * @see org.springframework.data.gemfire.IndexFactoryBean * @see org.apache.geode.cache.GemFireCache */ @@ -1180,19 +1181,18 @@ public class GemFireHttpSessionConfiguration extends AbstractGemFireHttpSessionC principalNameIndex.setExpression("principalName"); principalNameIndex.setFrom(RegionUtils.toRegionPath(getSessionRegionName())); principalNameIndex.setOverride(true); - principalNameIndex.setType(IndexType.HASH); return principalNameIndex; } /** - * Defines a Pivotal GemFire Index bean on the Pivotal GemFire cache {@link Region} storing and managing Sessions, - * specifically on all Session attributes for quick lookup and queries on Session attribute names - * with a given value. + * Defines an OQL {@link Index} bean on the {@link GemFireCache} {@link Region} storing and managing + * {@link Session Sessions}, specifically on all {@link Session} attributes for quick lookup and queries + * on {@link Session} attribute {@link String names} with a given {@link Object value}. * - * @param gemfireCache a reference to the Pivotal GemFire cache. - * @return a {@link IndexFactoryBean} to create an Pivotal GemFire Index on attributes of Sessions - * stored in the Pivotal GemFire cache {@link Region}. + * @param gemfireCache reference to the {@link GemFireCache}. + * @return a {@link IndexFactoryBean} to create an OQL {@link Index} on attributes of {@link Session Sessions} + * stored in the {@link GemFireCache} {@link Region}. * @see org.springframework.data.gemfire.IndexFactoryBean * @see org.apache.geode.cache.GemFireCache */ diff --git a/spring-session-data-geode/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/support/SessionAttributesIndexFactoryBean.java b/spring-session-data-geode/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/support/SessionAttributesIndexFactoryBean.java index 462a78f..f13a436 100644 --- a/spring-session-data-geode/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/support/SessionAttributesIndexFactoryBean.java +++ b/spring-session-data-geode/src/main/java/org/springframework/session/data/gemfire/config/annotation/web/http/support/SessionAttributesIndexFactoryBean.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.session.data.gemfire.config.annotation.web.http.support; import java.util.Optional; @@ -61,7 +60,9 @@ public class SessionAttributesIndexFactoryBean private String[] indexableSessionAttributes; - /* (non-Javadoc) */ + /** + * @inheritDoc + */ public void afterPropertiesSet() throws Exception { if (isIndexableSessionAttributesConfigured()) { @@ -124,56 +125,46 @@ public class SessionAttributesIndexFactoryBean String indexExpression = builder.toString(); - return (indexExpression.isEmpty() ? "*" : indexExpression); + return indexExpression.isEmpty() ? "*" : indexExpression; } - /* (non-Javadoc) */ - public Index getObject() throws Exception { + public Index getObject() { return this.sessionAttributesIndex; } - /* (non-Javadoc) */ @SuppressWarnings("unchecked") public Class getObjectType() { return Optional.ofNullable(this.sessionAttributesIndex).map(Object::getClass).orElse((Class) Index.class); } - /* (non-Javadoc) */ public boolean isSingleton() { return true; } - /* (non-Javadoc) */ public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; } - /* (non-Javadoc) */ public void setBeanName(String beanName) { this.beanName = beanName; } - /* (non-Javadoc) */ public void setGemFireCache(GemFireCache gemfireCache) { this.gemfireCache = gemfireCache; } - /* (non-Javadoc) */ public void setIndexableSessionAttributes(String[] indexableSessionAttributes) { this.indexableSessionAttributes = indexableSessionAttributes; } - /* (non-Javadoc) */ protected String[] getIndexableSessionAttributes() { return Optional.ofNullable(this.indexableSessionAttributes).orElse(DEFAULT_INDEXABLE_SESSION_ATTRIBUTES); } - /* (non-Javadoc) */ public void setRegionName(String regionName) { this.regionName = regionName; } - /* (non-Javadoc) */ protected String getRegionName() { return this.regionName; }