DATAGEODE-88 - Add configuration support for critical and eviction off-heap percentages in client, peer and cache server application annotations.

This commit is contained in:
John Blum
2018-03-08 21:18:24 -08:00
parent da9736eb02
commit e67b395e9a
15 changed files with 522 additions and 400 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -23,7 +23,6 @@ import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeList
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@@ -43,6 +42,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportAware; import org.springframework.context.annotation.ImportAware;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.ConversionService;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
@@ -126,7 +126,9 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
private Integer mcastPort = 0; private Integer mcastPort = 0;
private Float criticalHeapPercentage; private Float criticalHeapPercentage;
private Float criticalOffHeapPercentage;
private Float evictionHeapPercentage; private Float evictionHeapPercentage;
private Float evictionOffHeapPercentage;
private GatewayConflictResolver gatewayConflictResolver; private GatewayConflictResolver gatewayConflictResolver;
@@ -165,7 +167,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
* *
* @return a {@link Properties} object containing Pivotal GemFire/Apache Geode properties used to configure * @return a {@link Properties} object containing Pivotal GemFire/Apache Geode properties used to configure
* the Pivotal GemFire/Apache Geode cache instance. * the Pivotal GemFire/Apache Geode cache instance.
* @see <a link="http://gemfire.docs.pivotal.io/docs-gemfire/reference/topics/gemfire_properties.html">GemFire Properties</a> * @see <a href="http://gemfire.docs.pivotal.io/docs-gemfire/reference/topics/gemfire_properties.html">GemFire Properties</a>
* @see java.util.Properties * @see java.util.Properties
* @see #locators() * @see #locators()
* @see #logLevel() * @see #logLevel()
@@ -192,6 +194,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
*/ */
@Override @Override
public void setImportMetadata(AnnotationMetadata importMetadata) { public void setImportMetadata(AnnotationMetadata importMetadata) {
configureInfrastructure(importMetadata); configureInfrastructure(importMetadata);
configureCache(importMetadata); configureCache(importMetadata);
configurePdx(importMetadata); configurePdx(importMetadata);
@@ -207,6 +210,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
* @see org.springframework.core.type.AnnotationMetadata * @see org.springframework.core.type.AnnotationMetadata
*/ */
protected void configureInfrastructure(AnnotationMetadata importMetadata) { protected void configureInfrastructure(AnnotationMetadata importMetadata) {
registerCustomEditorBeanFactoryPostProcessor(importMetadata); registerCustomEditorBeanFactoryPostProcessor(importMetadata);
registerDefinedIndexesApplicationListener(importMetadata); registerDefinedIndexesApplicationListener(importMetadata);
registerDiskStoreDirectoryBeanPostProcessor(importMetadata); registerDiskStoreDirectoryBeanPostProcessor(importMetadata);
@@ -249,8 +253,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
if (isClientPeerOrServerCacheApplication(importMetadata)) { if (isClientPeerOrServerCacheApplication(importMetadata)) {
Map<String, Object> cacheMetadataAttributes = AnnotationAttributes cacheMetadataAttributes = getAnnotationAttributes(importMetadata);
importMetadata.getAnnotationAttributes(getAnnotationTypeName());
setCopyOnRead(resolveProperty(cacheProperty("copy-on-read"), setCopyOnRead(resolveProperty(cacheProperty("copy-on-read"),
Boolean.TRUE.equals(cacheMetadataAttributes.get("copyOnRead")))); Boolean.TRUE.equals(cacheMetadataAttributes.get("copyOnRead"))));
@@ -263,6 +266,14 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
.filter(AbstractAnnotationConfigSupport::hasValue) .filter(AbstractAnnotationConfigSupport::hasValue)
.ifPresent(this::setCriticalHeapPercentage); .ifPresent(this::setCriticalHeapPercentage);
Optional.ofNullable(resolveProperty(cacheProperty("critical-off-heap-percentage"), (Float) null))
.ifPresent(this::setCriticalOffHeapPercentage);
Optional.ofNullable((Float) cacheMetadataAttributes.get("criticalOffHeapPercentage"))
.filter(it -> getCriticalOffHeapPercentage() == null)
.filter(AbstractAnnotationConfigSupport::hasValue)
.ifPresent(this::setCriticalOffHeapPercentage);
Optional.ofNullable(resolveProperty(cacheProperty("eviction-heap-percentage"), (Float) null)) Optional.ofNullable(resolveProperty(cacheProperty("eviction-heap-percentage"), (Float) null))
.ifPresent(this::setEvictionHeapPercentage); .ifPresent(this::setEvictionHeapPercentage);
@@ -271,6 +282,14 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
.filter(AbstractAnnotationConfigSupport::hasValue) .filter(AbstractAnnotationConfigSupport::hasValue)
.ifPresent(this::setEvictionHeapPercentage); .ifPresent(this::setEvictionHeapPercentage);
Optional.ofNullable(resolveProperty(cacheProperty("eviction-off-heap-percentage"), (Float) null))
.ifPresent(this::setEvictionOffHeapPercentage);
Optional.ofNullable((Float) cacheMetadataAttributes.get("evictionOffHeapPercentage"))
.filter(it -> getEvictionOffHeapPercentage() == null)
.filter(AbstractAnnotationConfigSupport::hasValue)
.ifPresent(this::setEvictionOffHeapPercentage);
setLogLevel(resolveProperty(cacheProperty("log-level"), setLogLevel(resolveProperty(cacheProperty("log-level"),
(String) cacheMetadataAttributes.get("logLevel"))); (String) cacheMetadataAttributes.get("logLevel")));
@@ -297,7 +316,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
if (importMetadata.hasAnnotation(enablePdxTypeName)) { if (importMetadata.hasAnnotation(enablePdxTypeName)) {
Map<String, Object> enablePdxAttributes = importMetadata.getAnnotationAttributes(enablePdxTypeName); AnnotationAttributes enablePdxAttributes = getAnnotationAttributes(importMetadata, enablePdxTypeName);
setPdxDiskStoreName(resolveProperty(pdxProperty("disk-store-name"), setPdxDiskStoreName(resolveProperty(pdxProperty("disk-store-name"),
(String) enablePdxAttributes.get("diskStoreName"))); (String) enablePdxAttributes.get("diskStoreName")));
@@ -377,6 +396,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
Optional.ofNullable(getPdxDiskStoreName()) Optional.ofNullable(getPdxDiskStoreName())
.filter(StringUtils::hasText) .filter(StringUtils::hasText)
.ifPresent(pdxDiskStoreName -> { .ifPresent(pdxDiskStoreName -> {
if (PDX_DISK_STORE_AWARE_BEAN_FACTORY_POST_PROCESSOR_REGISTERED.compareAndSet(false, true)) { if (PDX_DISK_STORE_AWARE_BEAN_FACTORY_POST_PROCESSOR_REGISTERED.compareAndSet(false, true)) {
register(BeanDefinitionBuilder.rootBeanDefinition(PdxDiskStoreAwareBeanFactoryPostProcessor.class) register(BeanDefinitionBuilder.rootBeanDefinition(PdxDiskStoreAwareBeanFactoryPostProcessor.class)
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE) .setRole(BeanDefinition.ROLE_INFRASTRUCTURE)
@@ -450,8 +470,10 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
gemfireCache.setClose(isClose()); gemfireCache.setClose(isClose());
gemfireCache.setCopyOnRead(getCopyOnRead()); gemfireCache.setCopyOnRead(getCopyOnRead());
gemfireCache.setCriticalHeapPercentage(getCriticalHeapPercentage()); gemfireCache.setCriticalHeapPercentage(getCriticalHeapPercentage());
gemfireCache.setCriticalOffHeapPercentage(getCriticalOffHeapPercentage());
gemfireCache.setDynamicRegionSupport(getDynamicRegionSupport()); gemfireCache.setDynamicRegionSupport(getDynamicRegionSupport());
gemfireCache.setEvictionHeapPercentage(getEvictionHeapPercentage()); gemfireCache.setEvictionHeapPercentage(getEvictionHeapPercentage());
gemfireCache.setEvictionOffHeapPercentage(getEvictionOffHeapPercentage());
gemfireCache.setGatewayConflictResolver(getGatewayConflictResolver()); gemfireCache.setGatewayConflictResolver(getGatewayConflictResolver());
gemfireCache.setJndiDataSources(getJndiDataSources()); gemfireCache.setJndiDataSources(getJndiDataSources());
gemfireCache.setProperties(gemfireProperties()); gemfireCache.setProperties(gemfireProperties());
@@ -466,42 +488,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return gemfireCache; return gemfireCache;
} }
/**
* Returns the cache application {@link java.lang.annotation.Annotation} type pertaining to this configuration.
*
* @return the cache application {@link java.lang.annotation.Annotation} type used by this application.
* @see org.springframework.data.gemfire.config.annotation.CacheServerApplication
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
* @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication
*/
protected abstract Class<? extends Annotation> getAnnotationType();
/**
* Returns the fully-qualified {@link Class#getName() class name} of the cache application
* {@link java.lang.annotation.Annotation} type.
*
* @return the fully-qualified {@link Class#getName() class name} of the cache application
* {@link java.lang.annotation.Annotation} type.
* @see java.lang.Class#getName()
* @see #getAnnotationType()
*/
protected String getAnnotationTypeName() {
return getAnnotationType().getName();
}
/**
* Returns the simple {@link Class#getName() class name} of the cache application
* {@link java.lang.annotation.Annotation} type.
*
* @return the simple {@link Class#getName() class name} of the cache application
* {@link java.lang.annotation.Annotation} type.
* @see java.lang.Class#getSimpleName()
* @see #getAnnotationType()
*/
protected String getAnnotationTypeSimpleName() {
return getAnnotationType().getSimpleName();
}
// REVIEW JAVADOC FROM HERE // REVIEW JAVADOC FROM HERE
/** /**
@@ -604,7 +590,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|| isPeerCacheApplication(importMetadata)); || isPeerCacheApplication(importMetadata));
} }
/* (non-Javadoc) */
void setCacheXml(Resource cacheXml) { void setCacheXml(Resource cacheXml) {
this.cacheXml = cacheXml; this.cacheXml = cacheXml;
} }
@@ -613,7 +598,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.cacheXml; return this.cacheXml;
} }
/* (non-Javadoc) */
void setClose(boolean close) { void setClose(boolean close) {
this.close = close; this.close = close;
} }
@@ -622,7 +606,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.close; return this.close;
} }
/* (non-Javadoc) */
void setCopyOnRead(boolean copyOnRead) { void setCopyOnRead(boolean copyOnRead) {
this.copyOnRead = copyOnRead; this.copyOnRead = copyOnRead;
} }
@@ -631,7 +614,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.copyOnRead; return this.copyOnRead;
} }
/* (non-Javadoc) */
void setCriticalHeapPercentage(Float criticalHeapPercentage) { void setCriticalHeapPercentage(Float criticalHeapPercentage) {
this.criticalHeapPercentage = criticalHeapPercentage; this.criticalHeapPercentage = criticalHeapPercentage;
} }
@@ -640,7 +622,14 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.criticalHeapPercentage; return this.criticalHeapPercentage;
} }
/* (non-Javadoc) */ void setCriticalOffHeapPercentage(Float criticalOffHeapPercentage) {
this.criticalOffHeapPercentage = criticalOffHeapPercentage;
}
protected Float getCriticalOffHeapPercentage() {
return this.criticalOffHeapPercentage;
}
void setDynamicRegionSupport(DynamicRegionSupport dynamicRegionSupport) { void setDynamicRegionSupport(DynamicRegionSupport dynamicRegionSupport) {
this.dynamicRegionSupport = dynamicRegionSupport; this.dynamicRegionSupport = dynamicRegionSupport;
} }
@@ -649,7 +638,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.dynamicRegionSupport; return this.dynamicRegionSupport;
} }
/* (non-Javadoc) */
void setEvictionHeapPercentage(Float evictionHeapPercentage) { void setEvictionHeapPercentage(Float evictionHeapPercentage) {
this.evictionHeapPercentage = evictionHeapPercentage; this.evictionHeapPercentage = evictionHeapPercentage;
} }
@@ -658,7 +646,14 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.evictionHeapPercentage; return this.evictionHeapPercentage;
} }
/* (non-Javadoc) */ void setEvictionOffHeapPercentage(Float evictionOffHeapPercentage) {
this.evictionOffHeapPercentage = evictionOffHeapPercentage;
}
protected Float getEvictionOffHeapPercentage() {
return this.evictionOffHeapPercentage;
}
void setGatewayConflictResolver(GatewayConflictResolver gatewayConflictResolver) { void setGatewayConflictResolver(GatewayConflictResolver gatewayConflictResolver) {
this.gatewayConflictResolver = gatewayConflictResolver; this.gatewayConflictResolver = gatewayConflictResolver;
} }
@@ -667,7 +662,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.gatewayConflictResolver; return this.gatewayConflictResolver;
} }
/* (non-Javadoc) */
void setJndiDataSources(List<JndiDataSource> jndiDataSources) { void setJndiDataSources(List<JndiDataSource> jndiDataSources) {
this.jndiDataSources = jndiDataSources; this.jndiDataSources = jndiDataSources;
} }
@@ -676,7 +670,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return nullSafeList(this.jndiDataSources); return nullSafeList(this.jndiDataSources);
} }
/* (non-Javadoc) */
void setLocators(String locators) { void setLocators(String locators) {
this.locators = locators; this.locators = locators;
this.mcastPort = DEFAULT_MCAST_PORT; this.mcastPort = DEFAULT_MCAST_PORT;
@@ -686,7 +679,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.locators; return this.locators;
} }
/* (non-Javadoc) */
void setLogLevel(String logLevel) { void setLogLevel(String logLevel) {
this.logLevel = logLevel; this.logLevel = logLevel;
} }
@@ -695,7 +687,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return Optional.ofNullable(this.logLevel).orElse(DEFAULT_LOG_LEVEL); return Optional.ofNullable(this.logLevel).orElse(DEFAULT_LOG_LEVEL);
} }
/* (non-Javadoc) */
void setMappingContext(GemfireMappingContext mappingContext) { void setMappingContext(GemfireMappingContext mappingContext) {
this.mappingContext = mappingContext; this.mappingContext = mappingContext;
} }
@@ -713,7 +704,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return Optional.ofNullable(mcastPort).orElse(DEFAULT_MCAST_PORT); return Optional.ofNullable(mcastPort).orElse(DEFAULT_MCAST_PORT);
} }
/* (non-Javadoc) */
void setName(String name) { void setName(String name) {
this.name = name; this.name = name;
} }
@@ -722,7 +712,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return Optional.ofNullable(this.name).filter(StringUtils::hasText).orElseGet(this::toString); return Optional.ofNullable(this.name).filter(StringUtils::hasText).orElseGet(this::toString);
} }
/* (non-Javadoc) */
void setPdxDiskStoreName(String pdxDiskStoreName) { void setPdxDiskStoreName(String pdxDiskStoreName) {
this.pdxDiskStoreName = pdxDiskStoreName; this.pdxDiskStoreName = pdxDiskStoreName;
} }
@@ -731,7 +720,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.pdxDiskStoreName; return this.pdxDiskStoreName;
} }
/* (non-Javadoc) */
void setPdxIgnoreUnreadFields(Boolean pdxIgnoreUnreadFields) { void setPdxIgnoreUnreadFields(Boolean pdxIgnoreUnreadFields) {
this.pdxIgnoreUnreadFields = pdxIgnoreUnreadFields; this.pdxIgnoreUnreadFields = pdxIgnoreUnreadFields;
} }
@@ -740,7 +728,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.pdxIgnoreUnreadFields; return this.pdxIgnoreUnreadFields;
} }
/* (non-Javadoc) */
void setPdxPersistent(Boolean pdxPersistent) { void setPdxPersistent(Boolean pdxPersistent) {
this.pdxPersistent = pdxPersistent; this.pdxPersistent = pdxPersistent;
} }
@@ -749,7 +736,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.pdxPersistent; return this.pdxPersistent;
} }
/* (non-Javadoc) */
void setPdxReadSerialized(Boolean pdxReadSerialized) { void setPdxReadSerialized(Boolean pdxReadSerialized) {
this.pdxReadSerialized = pdxReadSerialized; this.pdxReadSerialized = pdxReadSerialized;
} }
@@ -758,7 +744,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.pdxReadSerialized; return this.pdxReadSerialized;
} }
/* (non-Javadoc) */
void setPdxSerializer(PdxSerializer pdxSerializer) { void setPdxSerializer(PdxSerializer pdxSerializer) {
this.pdxSerializer = pdxSerializer; this.pdxSerializer = pdxSerializer;
} }
@@ -767,7 +752,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.pdxSerializer; return this.pdxSerializer;
} }
/* (non-Javadoc) */
void setStartLocator(String startLocator) { void setStartLocator(String startLocator) {
this.startLocator = startLocator; this.startLocator = startLocator;
} }
@@ -776,7 +760,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.startLocator; return this.startLocator;
} }
/* (non-Javadoc) */
void setTransactionListeners(List<TransactionListener> transactionListeners) { void setTransactionListeners(List<TransactionListener> transactionListeners) {
this.transactionListeners = transactionListeners; this.transactionListeners = transactionListeners;
} }
@@ -785,7 +768,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return nullSafeList(this.transactionListeners); return nullSafeList(this.transactionListeners);
} }
/* (non-Javadoc) */
void setTransactionWriter(TransactionWriter transactionWriter) { void setTransactionWriter(TransactionWriter transactionWriter) {
this.transactionWriter = transactionWriter; this.transactionWriter = transactionWriter;
} }
@@ -794,7 +776,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
return this.transactionWriter; return this.transactionWriter;
} }
/* (non-Javadoc) */
void setUseBeanFactoryLocator(boolean useBeanFactoryLocator) { void setUseBeanFactoryLocator(boolean useBeanFactoryLocator) {
this.useBeanFactoryLocator = useBeanFactoryLocator; this.useBeanFactoryLocator = useBeanFactoryLocator;
} }

View File

@@ -96,6 +96,16 @@ public @interface CacheServerApplication {
*/ */
float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_PERCENTAGE; float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_PERCENTAGE;
/**
* Configures the percentage of off-heap at or above which the cache is considered in danger of becoming inoperable.
*
* Defaults to {@literal 0.0}.
*
* Use {@literal spring.data.gemfire.cache.critical-off-heap-percentage} property
* in {@literal application.properties}.
*/
float criticalOffHeapPercentage() default 0.0f;
/** /**
* By default, a GemFire member (both locators and servers) will attempt to reconnect and reinitialize the cache * By default, a GemFire member (both locators and servers) will attempt to reconnect and reinitialize the cache
* after it has been forced out of the distributed system by a network partition event or has otherwise been * after it has been forced out of the distributed system by a network partition event or has otherwise been
@@ -118,6 +128,17 @@ public @interface CacheServerApplication {
*/ */
float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_PERCENTAGE; float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_PERCENTAGE;
/**
* Configures the percentage of off-heap at or above which the eviction should begin on Regions configured
* for HeapLRU eviction.
*
* Defaults to {@literal 0.0}.
*
* Use {@literal spring.data.gemfire.cache.eviction-off-heap-percentage} property
* in {@literal application.properties}.
*/
float evictionOffHeapPercentage() default 0.0f;
/** /**
* Configures the ip address or host name that server locators will tell clients that this cache server * Configures the ip address or host name that server locators will tell clients that this cache server
* is listening on. * is listening on.
@@ -141,7 +162,7 @@ public @interface CacheServerApplication {
/** /**
* Configures the list of Locators defining the cluster to which this Spring cache application will connect. * Configures the list of Locators defining the cluster to which this Spring cache application will connect.
* *
* Use {@literal spring.data.gemfire.cache.copy-on-read} property in {@literal application.properties}. * Use {@literal spring.data.gemfire.locators} property in {@literal application.properties}.
*/ */
String locators() default ""; String locators() default "";

View File

@@ -20,6 +20,7 @@ package org.springframework.data.gemfire.config.annotation;
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeMap; import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeMap;
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeSet; import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeSet;
import java.lang.annotation.Annotation;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -39,6 +40,7 @@ import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.data.gemfire.server.CacheServerFactoryBean; import org.springframework.data.gemfire.server.CacheServerFactoryBean;
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy; import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
@@ -145,6 +147,7 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.cacheServerConfigurers) return Optional.ofNullable(this.cacheServerConfigurers)
.filter(cacheServerConfigurers -> !cacheServerConfigurers.isEmpty()) .filter(cacheServerConfigurers -> !cacheServerConfigurers.isEmpty())
.orElseGet(() -> .orElseGet(() ->
Optional.of(this.getBeanFactory()) Optional.of(this.getBeanFactory())
.filter(beanFactory -> beanFactory instanceof ListableBeanFactory) .filter(beanFactory -> beanFactory instanceof ListableBeanFactory)
.map(beanFactory -> { .map(beanFactory -> {
@@ -175,8 +178,7 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
if (isCacheServerApplication(importMetadata)) { if (isCacheServerApplication(importMetadata)) {
Map<String, Object> cacheServerApplicationAttributes = AnnotationAttributes cacheServerApplicationAttributes = getAnnotationAttributes(importMetadata);
importMetadata.getAnnotationAttributes(getAnnotationTypeName());
setAutoStartup(resolveProperty(cacheServerProperty("auto-startup"), setAutoStartup(resolveProperty(cacheServerProperty("auto-startup"),
Boolean.TRUE.equals(cacheServerApplicationAttributes.get("autoStartup")))); Boolean.TRUE.equals(cacheServerApplicationAttributes.get("autoStartup"))));
@@ -229,11 +231,10 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
protected Class getAnnotationType() { protected Class<? extends Annotation> getAnnotationType() {
return CacheServerApplication.class; return CacheServerApplication.class;
} }
/* (non-Javadoc) */
void setAutoStartup(boolean autoStartup) { void setAutoStartup(boolean autoStartup) {
this.autoStartup = autoStartup; this.autoStartup = autoStartup;
} }
@@ -242,7 +243,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return this.autoStartup; return this.autoStartup;
} }
/* (non-Javadoc) */
void setBindAddress(String bindAddress) { void setBindAddress(String bindAddress) {
this.bindAddress = bindAddress; this.bindAddress = bindAddress;
} }
@@ -252,7 +252,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
.orElse(CacheServer.DEFAULT_BIND_ADDRESS); .orElse(CacheServer.DEFAULT_BIND_ADDRESS);
} }
/* (non-Javadoc) */
void setHostnameForClients(String hostnameForClients) { void setHostnameForClients(String hostnameForClients) {
this.hostnameForClients = hostnameForClients; this.hostnameForClients = hostnameForClients;
} }
@@ -262,7 +261,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
.orElse(CacheServer.DEFAULT_HOSTNAME_FOR_CLIENTS); .orElse(CacheServer.DEFAULT_HOSTNAME_FOR_CLIENTS);
} }
/* (non-Javadoc) */
void setInterestRegistrationListeners(Set<InterestRegistrationListener> interestRegistrationListeners) { void setInterestRegistrationListeners(Set<InterestRegistrationListener> interestRegistrationListeners) {
this.interestRegistrationListeners = interestRegistrationListeners; this.interestRegistrationListeners = interestRegistrationListeners;
} }
@@ -271,7 +269,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return nullSafeSet(this.interestRegistrationListeners); return nullSafeSet(this.interestRegistrationListeners);
} }
/* (non-Javadoc) */
void setLoadPollInterval(Long loadPollInterval) { void setLoadPollInterval(Long loadPollInterval) {
this.loadPollInterval = loadPollInterval; this.loadPollInterval = loadPollInterval;
} }
@@ -280,7 +277,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.loadPollInterval).orElse(CacheServer.DEFAULT_LOAD_POLL_INTERVAL); return Optional.ofNullable(this.loadPollInterval).orElse(CacheServer.DEFAULT_LOAD_POLL_INTERVAL);
} }
/* (non-Javadoc) */
void setMaxConnections(Integer maxConnections) { void setMaxConnections(Integer maxConnections) {
this.maxConnections = maxConnections; this.maxConnections = maxConnections;
} }
@@ -289,7 +285,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.maxConnections).orElse(CacheServer.DEFAULT_MAX_CONNECTIONS); return Optional.ofNullable(this.maxConnections).orElse(CacheServer.DEFAULT_MAX_CONNECTIONS);
} }
/* (non-Javadoc) */
void setMaxMessageCount(Integer maxMessageCount) { void setMaxMessageCount(Integer maxMessageCount) {
this.maxMessageCount = maxMessageCount; this.maxMessageCount = maxMessageCount;
} }
@@ -298,7 +293,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.maxMessageCount).orElse(CacheServer.DEFAULT_MAXIMUM_MESSAGE_COUNT); return Optional.ofNullable(this.maxMessageCount).orElse(CacheServer.DEFAULT_MAXIMUM_MESSAGE_COUNT);
} }
/* (non-Javadoc) */
void setMaxThreads(Integer maxThreads) { void setMaxThreads(Integer maxThreads) {
this.maxThreads = maxThreads; this.maxThreads = maxThreads;
} }
@@ -307,7 +301,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.maxThreads).orElse(CacheServer.DEFAULT_MAX_THREADS); return Optional.ofNullable(this.maxThreads).orElse(CacheServer.DEFAULT_MAX_THREADS);
} }
/* (non-Javadoc) */
void setMaxTimeBetweenPings(Integer maxTimeBetweenPings) { void setMaxTimeBetweenPings(Integer maxTimeBetweenPings) {
this.maxTimeBetweenPings = maxTimeBetweenPings; this.maxTimeBetweenPings = maxTimeBetweenPings;
} }
@@ -316,7 +309,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.maxTimeBetweenPings).orElse(CacheServer.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS); return Optional.ofNullable(this.maxTimeBetweenPings).orElse(CacheServer.DEFAULT_MAXIMUM_TIME_BETWEEN_PINGS);
} }
/* (non-Javadoc) */
void setMessageTimeToLive(Integer messageTimeToLive) { void setMessageTimeToLive(Integer messageTimeToLive) {
this.messageTimeToLive = messageTimeToLive; this.messageTimeToLive = messageTimeToLive;
} }
@@ -325,7 +317,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.messageTimeToLive).orElse(CacheServer.DEFAULT_MESSAGE_TIME_TO_LIVE); return Optional.ofNullable(this.messageTimeToLive).orElse(CacheServer.DEFAULT_MESSAGE_TIME_TO_LIVE);
} }
/* (non-Javadoc) */
void setPort(Integer port) { void setPort(Integer port) {
this.port = port; this.port = port;
} }
@@ -334,7 +325,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.port).orElse(CacheServer.DEFAULT_PORT); return Optional.ofNullable(this.port).orElse(CacheServer.DEFAULT_PORT);
} }
/* (non-Javadoc) */
void setServerLoadProbe(ServerLoadProbe serverLoadProbe) { void setServerLoadProbe(ServerLoadProbe serverLoadProbe) {
this.serverLoadProbe = serverLoadProbe; this.serverLoadProbe = serverLoadProbe;
} }
@@ -343,7 +333,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.serverLoadProbe).orElse(CacheServer.DEFAULT_LOAD_PROBE); return Optional.ofNullable(this.serverLoadProbe).orElse(CacheServer.DEFAULT_LOAD_PROBE);
} }
/* (non-Javadoc) */
void setSocketBufferSize(Integer socketBufferSize) { void setSocketBufferSize(Integer socketBufferSize) {
this.socketBufferSize = socketBufferSize; this.socketBufferSize = socketBufferSize;
} }
@@ -352,7 +341,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.socketBufferSize).orElse(CacheServer.DEFAULT_SOCKET_BUFFER_SIZE); return Optional.ofNullable(this.socketBufferSize).orElse(CacheServer.DEFAULT_SOCKET_BUFFER_SIZE);
} }
/* (non-Javadoc) */
void setSubscriptionCapacity(Integer subscriptionCapacity) { void setSubscriptionCapacity(Integer subscriptionCapacity) {
this.subscriptionCapacity = subscriptionCapacity; this.subscriptionCapacity = subscriptionCapacity;
} }
@@ -361,7 +349,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.subscriptionCapacity).orElse(ClientSubscriptionConfig.DEFAULT_CAPACITY); return Optional.ofNullable(this.subscriptionCapacity).orElse(ClientSubscriptionConfig.DEFAULT_CAPACITY);
} }
/* (non-Javadoc) */
void setSubscriptionDiskStoreName(String subscriptionDiskStoreName) { void setSubscriptionDiskStoreName(String subscriptionDiskStoreName) {
this.subscriptionDiskStoreName = subscriptionDiskStoreName; this.subscriptionDiskStoreName = subscriptionDiskStoreName;
} }
@@ -370,7 +357,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return this.subscriptionDiskStoreName; return this.subscriptionDiskStoreName;
} }
/* (non-Javadoc) */
void setSubscriptionEvictionPolicy(SubscriptionEvictionPolicy subscriptionEvictionPolicy) { void setSubscriptionEvictionPolicy(SubscriptionEvictionPolicy subscriptionEvictionPolicy) {
this.subscriptionEvictionPolicy = subscriptionEvictionPolicy; this.subscriptionEvictionPolicy = subscriptionEvictionPolicy;
} }
@@ -379,7 +365,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.subscriptionEvictionPolicy).orElse(SubscriptionEvictionPolicy.DEFAULT); return Optional.ofNullable(this.subscriptionEvictionPolicy).orElse(SubscriptionEvictionPolicy.DEFAULT);
} }
/* (non-Javadoc) */
void setTcpNoDelay(Boolean tcpNoDelay) { void setTcpNoDelay(Boolean tcpNoDelay) {
this.tcpNoDelay = tcpNoDelay; this.tcpNoDelay = tcpNoDelay;
} }
@@ -388,6 +373,14 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
return Optional.ofNullable(this.tcpNoDelay).orElse(CacheServer.DEFAULT_TCP_NO_DELAY); return Optional.ofNullable(this.tcpNoDelay).orElse(CacheServer.DEFAULT_TCP_NO_DELAY);
} }
/**
* Returns a {@link String} containing the name of the Spring-configured Apache Geode {@link CacheServer} application
* and data node in the cluster.
*
* @return a {@link String} containing the name of the Spring-configured Apache Geode {@link CacheServer} application
* and data node in the cluster.
* @see java.lang.Object#toString()
*/
@Override @Override
public String toString() { public String toString() {
return DEFAULT_NAME; return DEFAULT_NAME;

View File

@@ -71,6 +71,16 @@ public @interface ClientCacheApplication {
*/ */
float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_PERCENTAGE; float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_PERCENTAGE;
/**
* Configures the percentage of off-heap at or above which the cache is considered in danger of becoming inoperable.
*
* Defaults to {@literal 0.0}.
*
* Use {@literal spring.data.gemfire.cache.critical-off-heap-percentage} property
* in {@literal application.properties}.
*/
float criticalOffHeapPercentage() default 0.0f;
/** /**
* Used only for clients in a client/server installation. If set, this indicates that the client is durable * Used only for clients in a client/server installation. If set, this indicates that the client is durable
* and identifies the client. The ID is used by servers to reestablish any messaging that was interrupted * and identifies the client. The ID is used by servers to reestablish any messaging that was interrupted
@@ -101,6 +111,17 @@ public @interface ClientCacheApplication {
*/ */
float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_PERCENTAGE; float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_PERCENTAGE;
/**
* Configures the percentage of off-heap at or above which the eviction should begin on Regions configured
* for HeapLRU eviction.
*
* Defaults to {@literal 0.0}.
*
* Use {@literal spring.data.gemfire.cache.eviction-off-heap-percentage} property
* in {@literal application.properties}.
*/
float evictionOffHeapPercentage() default 0.0f;
/** /**
* Configures the free connection timeout for this pool. * Configures the free connection timeout for this pool.
* *

View File

@@ -19,6 +19,7 @@ package org.springframework.data.gemfire.config.annotation;
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeMap; import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeMap;
import java.lang.annotation.Annotation;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -160,6 +161,7 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return Optional.ofNullable(this.clientCacheConfigurers) return Optional.ofNullable(this.clientCacheConfigurers)
.filter(clientCacheConfigurers -> !clientCacheConfigurers.isEmpty()) .filter(clientCacheConfigurers -> !clientCacheConfigurers.isEmpty())
.orElseGet(() -> .orElseGet(() ->
Optional.of(this.getBeanFactory()) Optional.of(this.getBeanFactory())
.filter(beanFactory -> beanFactory instanceof ListableBeanFactory) .filter(beanFactory -> beanFactory instanceof ListableBeanFactory)
.map(beanFactory -> { .map(beanFactory -> {
@@ -230,8 +232,7 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
if (isClientCacheApplication(importMetadata)) { if (isClientCacheApplication(importMetadata)) {
Map<String, Object> clientCacheApplicationAttributes = AnnotationAttributes clientCacheApplicationAttributes = getAnnotationAttributes(importMetadata);
importMetadata.getAnnotationAttributes(getAnnotationTypeName());
setDurableClientId(resolveProperty(cacheClientProperty("durable-client-id"), setDurableClientId(resolveProperty(cacheClientProperty("durable-client-id"),
(String) clientCacheApplicationAttributes.get("durableClientId"))); (String) clientCacheApplicationAttributes.get("durableClientId")));
@@ -358,10 +359,13 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
resolveProperty(poolProperty("locators"), (String) null)); resolveProperty(poolProperty("locators"), (String) null));
if (StringUtils.hasText(locatorsFromProperty)) { if (StringUtils.hasText(locatorsFromProperty)) {
String[] locatorHostsPorts = locatorsFromProperty.split(","); String[] locatorHostsPorts = locatorsFromProperty.split(",");
poolLocators = ConnectionEndpointList.parse(GemfireUtils.DEFAULT_LOCATOR_PORT, locatorHostsPorts); poolLocators = ConnectionEndpointList.parse(GemfireUtils.DEFAULT_LOCATOR_PORT, locatorHostsPorts);
} }
else { else {
poolLocators = new ConnectionEndpointList(); poolLocators = new ConnectionEndpointList();
AnnotationAttributes[] locators = (AnnotationAttributes[]) clientCacheApplicationAttributes.get("locators"); AnnotationAttributes[] locators = (AnnotationAttributes[]) clientCacheApplicationAttributes.get("locators");
@@ -395,7 +399,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
setPoolServers(poolServers); setPoolServers(poolServers);
} }
/* (non-Javadoc) */
protected ConnectionEndpoint newConnectionEndpoint(String host, Integer port) { protected ConnectionEndpoint newConnectionEndpoint(String host, Integer port) {
return new ConnectionEndpoint(host, port); return new ConnectionEndpoint(host, port);
} }
@@ -404,11 +407,10 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
protected Class getAnnotationType() { protected Class<? extends Annotation> getAnnotationType() {
return ClientCacheApplication.class; return ClientCacheApplication.class;
} }
/* (non-Javadoc) */
void setDurableClientId(String durableClientId) { void setDurableClientId(String durableClientId) {
this.durableClientId = durableClientId; this.durableClientId = durableClientId;
} }
@@ -417,7 +419,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.durableClientId; return this.durableClientId;
} }
/* (non-Javadoc) */
void setDurableClientTimeout(Integer durableClientTimeout) { void setDurableClientTimeout(Integer durableClientTimeout) {
this.durableClientTimeout = durableClientTimeout; this.durableClientTimeout = durableClientTimeout;
} }
@@ -426,7 +427,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.durableClientTimeout; return this.durableClientTimeout;
} }
/* (non-Javadoc) */
void setFreeConnectionTimeout(Integer freeConnectionTimeout) { void setFreeConnectionTimeout(Integer freeConnectionTimeout) {
this.freeConnectionTimeout = freeConnectionTimeout; this.freeConnectionTimeout = freeConnectionTimeout;
} }
@@ -435,7 +435,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.freeConnectionTimeout; return this.freeConnectionTimeout;
} }
/* (non-Javadoc) */
void setIdleTimeout(Long idleTimeout) { void setIdleTimeout(Long idleTimeout) {
this.idleTimeout = idleTimeout; this.idleTimeout = idleTimeout;
} }
@@ -444,7 +443,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.idleTimeout; return this.idleTimeout;
} }
/* (non-Javadoc) */
void setKeepAlive(Boolean keepAlive) { void setKeepAlive(Boolean keepAlive) {
this.keepAlive = keepAlive; this.keepAlive = keepAlive;
} }
@@ -453,7 +451,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.keepAlive; return this.keepAlive;
} }
/* (non-Javadoc) */
void setLoadConditioningInterval(Integer loadConditioningInterval) { void setLoadConditioningInterval(Integer loadConditioningInterval) {
this.loadConditioningInterval = loadConditioningInterval; this.loadConditioningInterval = loadConditioningInterval;
} }
@@ -462,7 +459,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.loadConditioningInterval; return this.loadConditioningInterval;
} }
/* (non-Javadoc) */
void setMaxConnections(Integer maxConnections) { void setMaxConnections(Integer maxConnections) {
this.maxConnections = maxConnections; this.maxConnections = maxConnections;
} }
@@ -471,7 +467,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.maxConnections; return this.maxConnections;
} }
/* (non-Javadoc) */
void setMinConnections(Integer minConnections) { void setMinConnections(Integer minConnections) {
this.minConnections = minConnections; this.minConnections = minConnections;
} }
@@ -480,7 +475,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.minConnections; return this.minConnections;
} }
/* (non-Javadoc) */
void setMultiUserAuthentication(Boolean multiUserAuthentication) { void setMultiUserAuthentication(Boolean multiUserAuthentication) {
this.multiUserAuthentication = multiUserAuthentication; this.multiUserAuthentication = multiUserAuthentication;
} }
@@ -489,7 +483,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.multiUserAuthentication; return this.multiUserAuthentication;
} }
/* (non-Javadoc) */
void setPingInterval(Long pingInterval) { void setPingInterval(Long pingInterval) {
this.pingInterval = pingInterval; this.pingInterval = pingInterval;
} }
@@ -498,7 +491,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.pingInterval; return this.pingInterval;
} }
/* (non-Javadoc) */
void setPoolLocators(Iterable<ConnectionEndpoint> locators) { void setPoolLocators(Iterable<ConnectionEndpoint> locators) {
this.locators = locators; this.locators = locators;
} }
@@ -507,7 +499,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.locators; return this.locators;
} }
/* (non-Javadoc) */
void setPoolServers(Iterable<ConnectionEndpoint> servers) { void setPoolServers(Iterable<ConnectionEndpoint> servers) {
this.servers = servers; this.servers = servers;
} }
@@ -516,7 +507,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.servers; return this.servers;
} }
/* (non-Javadoc) */
void setPrSingleHopEnabled(Boolean prSingleHopEnabled) { void setPrSingleHopEnabled(Boolean prSingleHopEnabled) {
this.prSingleHopEnabled = prSingleHopEnabled; this.prSingleHopEnabled = prSingleHopEnabled;
} }
@@ -525,7 +515,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.prSingleHopEnabled; return this.prSingleHopEnabled;
} }
/* (non-Javadoc) */
void setReadTimeout(Integer readTimeout) { void setReadTimeout(Integer readTimeout) {
this.readTimeout = readTimeout; this.readTimeout = readTimeout;
} }
@@ -534,7 +523,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.readTimeout; return this.readTimeout;
} }
/* (non-Javadoc) */
void setReadyForEvents(boolean readyForEvents) { void setReadyForEvents(boolean readyForEvents) {
this.readyForEvents = readyForEvents; this.readyForEvents = readyForEvents;
} }
@@ -543,7 +531,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.readyForEvents; return this.readyForEvents;
} }
/* (non-Javadoc) */
void setRetryAttempts(Integer retryAttempts) { void setRetryAttempts(Integer retryAttempts) {
this.retryAttempts = retryAttempts; this.retryAttempts = retryAttempts;
} }
@@ -552,7 +539,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.retryAttempts; return this.retryAttempts;
} }
/* (non-Javadoc) */
void setServerGroup(String serverGroup) { void setServerGroup(String serverGroup) {
this.serverGroup = serverGroup; this.serverGroup = serverGroup;
} }
@@ -561,7 +547,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.serverGroup; return this.serverGroup;
} }
/* (non-Javadoc) */
void setSocketBufferSize(Integer socketBufferSize) { void setSocketBufferSize(Integer socketBufferSize) {
this.socketBufferSize = socketBufferSize; this.socketBufferSize = socketBufferSize;
} }
@@ -570,7 +555,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.socketBufferSize; return this.socketBufferSize;
} }
/* (non-Javadoc) */
void setStatisticsInterval(Integer statisticsInterval) { void setStatisticsInterval(Integer statisticsInterval) {
this.statisticsInterval = statisticsInterval; this.statisticsInterval = statisticsInterval;
} }
@@ -579,7 +563,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.statisticsInterval; return this.statisticsInterval;
} }
/* (non-Javadoc) */
void setSubscriptionAckInterval(Integer subscriptionAckInterval) { void setSubscriptionAckInterval(Integer subscriptionAckInterval) {
this.subscriptionAckInterval = subscriptionAckInterval; this.subscriptionAckInterval = subscriptionAckInterval;
} }
@@ -588,7 +571,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.subscriptionAckInterval; return this.subscriptionAckInterval;
} }
/* (non-Javadoc) */
void setSubscriptionEnabled(Boolean subscriptionEnabled) { void setSubscriptionEnabled(Boolean subscriptionEnabled) {
this.subscriptionEnabled = subscriptionEnabled; this.subscriptionEnabled = subscriptionEnabled;
} }
@@ -597,7 +579,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.subscriptionEnabled; return this.subscriptionEnabled;
} }
/* (non-Javadoc) */
void setSubscriptionMessageTrackingTimeout(Integer subscriptionMessageTrackingTimeout) { void setSubscriptionMessageTrackingTimeout(Integer subscriptionMessageTrackingTimeout) {
this.subscriptionMessageTrackingTimeout = subscriptionMessageTrackingTimeout; this.subscriptionMessageTrackingTimeout = subscriptionMessageTrackingTimeout;
} }
@@ -606,7 +587,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.subscriptionMessageTrackingTimeout; return this.subscriptionMessageTrackingTimeout;
} }
/* (non-Javadoc) */
void setSubscriptionRedundancy(Integer subscriptionRedundancy) { void setSubscriptionRedundancy(Integer subscriptionRedundancy) {
this.subscriptionRedundancy = subscriptionRedundancy; this.subscriptionRedundancy = subscriptionRedundancy;
} }
@@ -615,7 +595,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.subscriptionRedundancy; return this.subscriptionRedundancy;
} }
/* (non-Javadoc) */
void setThreadLocalConnections(Boolean threadLocalConnections) { void setThreadLocalConnections(Boolean threadLocalConnections) {
this.threadLocalConnections = threadLocalConnections; this.threadLocalConnections = threadLocalConnections;
} }
@@ -624,6 +603,14 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
return this.threadLocalConnections; return this.threadLocalConnections;
} }
/**
* Returns a {@link String} containing the name of the Spring-configured Apache Geode
* {@link ClientCache} application.
*
* @return a {@link String} containing the name of the Spring-configured Apache Geode
* {@link ClientCache} application.
* @see java.lang.Object#toString()
*/
@Override @Override
public String toString() { public String toString() {
return DEFAULT_NAME; return DEFAULT_NAME;

View File

@@ -70,6 +70,16 @@ public @interface PeerCacheApplication {
*/ */
float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_PERCENTAGE; float criticalHeapPercentage() default ResourceManager.DEFAULT_CRITICAL_PERCENTAGE;
/**
* Configures the percentage of off-heap at or above which the cache is considered in danger of becoming inoperable.
*
* Defaults to {@literal 0.0}.
*
* Use {@literal spring.data.gemfire.cache.critical-off-heap-percentage} property
* in {@literal application.properties}.
*/
float criticalOffHeapPercentage() default 0.0f;
/** /**
* By default, a GemFire member (both locators and servers) will attempt to reconnect and reinitialize the cache * By default, a GemFire member (both locators and servers) will attempt to reconnect and reinitialize the cache
* after it has been forced out of the distributed system by a network partition event or has otherwise been * after it has been forced out of the distributed system by a network partition event or has otherwise been
@@ -92,6 +102,17 @@ public @interface PeerCacheApplication {
*/ */
float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_PERCENTAGE; float evictionHeapPercentage() default ResourceManager.DEFAULT_EVICTION_PERCENTAGE;
/**
* Configures the percentage of off-heap at or above which the eviction should begin on Regions configured
* for HeapLRU eviction.
*
* Defaults to {@literal 0.0}.
*
* Use {@literal spring.data.gemfire.cache.eviction-off-heap-percentage} property
* in {@literal application.properties}.
*/
float evictionOffHeapPercentage() default 0.0f;
/** /**
* Configures the list of Locators defining the cluster to which this Spring cache application will connect. * Configures the list of Locators defining the cluster to which this Spring cache application will connect.
* *

View File

@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.data.gemfire.CacheFactoryBean; import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -42,11 +43,15 @@ import org.springframework.util.StringUtils;
* *
* @author John Blum * @author John Blum
* @see org.apache.geode.cache.Cache * @see org.apache.geode.cache.Cache
* @see org.springframework.beans.factory.ListableBeanFactory
* @see org.springframework.context.annotation.Bean * @see org.springframework.context.annotation.Bean
* @see org.springframework.context.annotation.Configuration * @see org.springframework.context.annotation.Configuration
* @see org.springframework.context.annotation.Import * @see org.springframework.context.annotation.Import
* @see org.springframework.data.gemfire.CacheFactoryBean
* @see org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration * @see org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration
* @see org.springframework.data.gemfire.config.annotation.AdministrativeConfiguration * @see org.springframework.data.gemfire.config.annotation.AdministrativeConfiguration
* @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication
* @see org.springframework.data.gemfire.config.annotation.PeerCacheConfigurer
* @since 1.9.0 * @since 1.9.0
*/ */
@Configuration @Configuration
@@ -102,6 +107,7 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
return Optional.ofNullable(this.peerCacheConfigurers) return Optional.ofNullable(this.peerCacheConfigurers)
.filter(peerCacheConfigurers -> !peerCacheConfigurers.isEmpty()) .filter(peerCacheConfigurers -> !peerCacheConfigurers.isEmpty())
.orElseGet(() -> .orElseGet(() ->
Optional.of(this.getBeanFactory()) Optional.of(this.getBeanFactory())
.filter(beanFactory -> beanFactory instanceof ListableBeanFactory) .filter(beanFactory -> beanFactory instanceof ListableBeanFactory)
.map(beanFactory -> { .map(beanFactory -> {
@@ -144,8 +150,7 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
if (isCacheServerOrPeerCacheApplication(importMetadata)) { if (isCacheServerOrPeerCacheApplication(importMetadata)) {
Map<String, Object> peerCacheApplicationAttributes = AnnotationAttributes peerCacheApplicationAttributes = getAnnotationAttributes(importMetadata);
importMetadata.getAnnotationAttributes(getAnnotationTypeName());
if (peerCacheApplicationAttributes != null) { if (peerCacheApplicationAttributes != null) {
@@ -174,6 +179,10 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
Optional.ofNullable(resolveProperty(cachePeerProperty("locators"), (String) null)) Optional.ofNullable(resolveProperty(cachePeerProperty("locators"), (String) null))
.filter(StringUtils::hasText) .filter(StringUtils::hasText)
.ifPresent(this::setLocators); .ifPresent(this::setLocators);
Optional.ofNullable(resolveProperty(propertyName("locators"), (String) null))
.filter(StringUtils::hasText)
.ifPresent(this::setLocators);
} }
} }
} }
@@ -186,7 +195,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
return PeerCacheApplication.class; return PeerCacheApplication.class;
} }
/* (non-Javadoc) */
void setEnableAutoReconnect(boolean enableAutoReconnect) { void setEnableAutoReconnect(boolean enableAutoReconnect) {
this.enableAutoReconnect = enableAutoReconnect; this.enableAutoReconnect = enableAutoReconnect;
} }
@@ -195,7 +203,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
return this.enableAutoReconnect; return this.enableAutoReconnect;
} }
/* (non-Javadoc) */
void setLockLease(Integer lockLease) { void setLockLease(Integer lockLease) {
this.lockLease = lockLease; this.lockLease = lockLease;
} }
@@ -204,7 +211,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
return this.lockLease; return this.lockLease;
} }
/* (non-Javadoc) */
void setLockTimeout(Integer lockTimeout) { void setLockTimeout(Integer lockTimeout) {
this.lockTimeout = lockTimeout; this.lockTimeout = lockTimeout;
} }
@@ -213,7 +219,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
return this.lockTimeout; return this.lockTimeout;
} }
/* (non-Javadoc) */
void setMessageSyncInterval(Integer messageSyncInterval) { void setMessageSyncInterval(Integer messageSyncInterval) {
this.messageSyncInterval = messageSyncInterval; this.messageSyncInterval = messageSyncInterval;
} }
@@ -222,7 +227,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
return this.messageSyncInterval; return this.messageSyncInterval;
} }
/* (non-Javadoc) */
void setSearchTimeout(Integer searchTimeout) { void setSearchTimeout(Integer searchTimeout) {
this.searchTimeout = searchTimeout; this.searchTimeout = searchTimeout;
} }
@@ -231,7 +235,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
return this.searchTimeout; return this.searchTimeout;
} }
/* (non-Javadoc) */
void setUseClusterConfiguration(boolean useClusterConfiguration) { void setUseClusterConfiguration(boolean useClusterConfiguration) {
this.useClusterConfiguration = useClusterConfiguration; this.useClusterConfiguration = useClusterConfiguration;
} }
@@ -240,6 +243,14 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
return this.useClusterConfiguration; return this.useClusterConfiguration;
} }
/**
* Returns a {@link String} containing the name of the Spring-configured Apache Geode peer {@link Cache} application
* and data node in the cluster.
*
* @return a {@link String} containing the name of the Spring-configured Apache Geode peer {@link Cache} application
* and data node in the cluster.
* @see java.lang.Object#toString()
*/
@Override @Override
public String toString() { public String toString() {
return DEFAULT_NAME; return DEFAULT_NAME;

View File

@@ -48,7 +48,7 @@ import org.springframework.data.gemfire.process.ProcessWrapper;
import org.springframework.data.gemfire.test.support.FileSystemUtils; import org.springframework.data.gemfire.test.support.FileSystemUtils;
import org.springframework.data.gemfire.test.support.ThreadUtils; import org.springframework.data.gemfire.test.support.ThreadUtils;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@@ -64,7 +64,7 @@ import org.springframework.util.StringUtils;
* @see org.springframework.data.gemfire.client.GemfireDataSourcePostProcessor * @see org.springframework.data.gemfire.client.GemfireDataSourcePostProcessor
* @since 1.7.0 * @since 1.7.0
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringRunner.class)
@ContextConfiguration @ContextConfiguration
@SuppressWarnings({ "rawtypes", "unused"}) @SuppressWarnings({ "rawtypes", "unused"})
public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTest { public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTest {
@@ -88,7 +88,8 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
@BeforeClass @BeforeClass
public static void setupBeforeClass() throws IOException { public static void setupBeforeClass() throws IOException {
System.setProperty("gemfire.log-level", "warning");
System.setProperty("gemfire.log-level", "error");
String serverName = "GemFireDataSourceGemFireBasedServer"; String serverName = "GemFireDataSourceGemFireBasedServer";
@@ -123,6 +124,7 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
} }
private static String customClasspath() { private static String customClasspath() {
String[] classpathElements = ProcessExecutor.JAVA_CLASSPATH.split(File.pathSeparator); String[] classpathElements = ProcessExecutor.JAVA_CLASSPATH.split(File.pathSeparator);
List<String> customClasspath = new ArrayList<String>(classpathElements.length); List<String> customClasspath = new ArrayList<String>(classpathElements.length);
@@ -137,6 +139,7 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
} }
private static void waitForProcessStart(final long milliseconds, final ProcessWrapper process, final String processControlFilename) { private static void waitForProcessStart(final long milliseconds, final ProcessWrapper process, final String processControlFilename) {
ThreadUtils.timedWait(milliseconds, TimeUnit.MILLISECONDS.toMillis(500), new ThreadUtils.WaitCondition() { ThreadUtils.timedWait(milliseconds, TimeUnit.MILLISECONDS.toMillis(500), new ThreadUtils.WaitCondition() {
private File processControlFile = new File(process.getWorkingDirectory(), processControlFilename); private File processControlFile = new File(process.getWorkingDirectory(), processControlFilename);
@@ -148,6 +151,7 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
@AfterClass @AfterClass
public static void tearDown() { public static void tearDown() {
serverProcess.shutdown(); serverProcess.shutdown();
if (Boolean.valueOf(System.getProperty("spring.gemfire.fork.clean", Boolean.TRUE.toString()))) { if (Boolean.valueOf(System.getProperty("spring.gemfire.fork.clean", Boolean.TRUE.toString()))) {
@@ -156,6 +160,7 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
} }
protected void assertRegion(Region actualRegion, String expectedRegionName) { protected void assertRegion(Region actualRegion, String expectedRegionName) {
assertThat(actualRegion, is(not(nullValue()))); assertThat(actualRegion, is(not(nullValue())));
assertThat(actualRegion.getName(), is(equalTo(expectedRegionName))); assertThat(actualRegion.getName(), is(equalTo(expectedRegionName)));
assertThat(actualRegion.getFullPath(), is(equalTo(String.format("%1$s%2$s", assertThat(actualRegion.getFullPath(), is(equalTo(String.format("%1$s%2$s",
@@ -168,9 +173,9 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void clientProxyRegionBeansExist() { public void clientProxyRegionBeansExist() {
assertRegion(localRegion, "LocalRegion"); assertRegion(localRegion, "LocalRegion");
assertRegion(serverRegion, "ServerRegion"); assertRegion(serverRegion, "ServerRegion");
assertRegion(anotherServerRegion, "AnotherServerRegion"); assertRegion(anotherServerRegion, "AnotherServerRegion");
} }
} }

View File

@@ -31,6 +31,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import java.lang.annotation.Annotation;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -235,7 +236,7 @@ public class AbstractCacheConfigurationUnitTests {
protected static class TestCacheConfiguration extends AbstractCacheConfiguration { protected static class TestCacheConfiguration extends AbstractCacheConfiguration {
@Override @Override
protected Class getAnnotationType() { protected Class<? extends Annotation> getAnnotationType() {
throw new UnsupportedOperationException("Not Implemented"); throw new UnsupportedOperationException("Not Implemented");
} }

View File

@@ -76,7 +76,9 @@ public class ClientCachePropertiesIntegrationTests {
MockPropertySource testPropertySource = new MockPropertySource() MockPropertySource testPropertySource = new MockPropertySource()
.withProperty("spring.data.gemfire.cache.critical-heap-percentage", 90.0f) .withProperty("spring.data.gemfire.cache.critical-heap-percentage", 90.0f)
.withProperty("spring.data.gemfire.cache.critical-off-heap-percentage", 95.0f)
.withProperty("spring.data.gemfire.cache.eviction-heap-percentage", 85.0f) .withProperty("spring.data.gemfire.cache.eviction-heap-percentage", 85.0f)
.withProperty("spring.data.gemfire.cache.eviction-off-heap-percentage", 80.0f)
.withProperty("spring.data.gemfire.pdx.ignore-unread-fields", false) .withProperty("spring.data.gemfire.pdx.ignore-unread-fields", false)
.withProperty("spring.data.gemfire.pdx.persistent", true) .withProperty("spring.data.gemfire.pdx.persistent", true)
.withProperty("spring.data.gemfire.pool.free-connection-timeout", 20000L) .withProperty("spring.data.gemfire.pool.free-connection-timeout", 20000L)
@@ -134,7 +136,9 @@ public class ClientCachePropertiesIntegrationTests {
assertThat(resourceManager).isNotNull(); assertThat(resourceManager).isNotNull();
assertThat(resourceManager.getCriticalHeapPercentage()).isEqualTo(90.0f); assertThat(resourceManager.getCriticalHeapPercentage()).isEqualTo(90.0f);
assertThat(resourceManager.getCriticalOffHeapPercentage()).isEqualTo(95.0f);
assertThat(resourceManager.getEvictionHeapPercentage()).isEqualTo(90.0f); assertThat(resourceManager.getEvictionHeapPercentage()).isEqualTo(90.0f);
assertThat(resourceManager.getEvictionOffHeapPercentage()).isEqualTo(80.0f);
} }
@Test @Test
@@ -240,16 +244,17 @@ public class ClientCachePropertiesIntegrationTests {
// TODO add more tests! // TODO add more tests!
@EnableGemFireMockObjects @EnableGemFireMockObjects
@EnablePdx(ignoreUnreadFields = true, readSerialized = true, serializerBeanName = "mockPdxSerializer")
@ClientCacheApplication(name = "TestClientCache", copyOnRead = true, @ClientCacheApplication(name = "TestClientCache", copyOnRead = true,
criticalHeapPercentage = 95.0f, evictionHeapPercentage = 80.0f, idleTimeout = 15000L, criticalHeapPercentage = 95.0f, evictionHeapPercentage = 80.0f, idleTimeout = 15000L,
maxConnections = 100, minConnections = 10, pingInterval = 15000L, readTimeout = 15000, retryAttempts = 1, maxConnections = 100, minConnections = 10, pingInterval = 15000L, readTimeout = 15000, retryAttempts = 1,
subscriptionEnabled = true, subscriptionRedundancy = 1) subscriptionEnabled = true, subscriptionRedundancy = 1)
@EnablePdx(ignoreUnreadFields = true, readSerialized = true, serializerBeanName = "mockPdxSerializer")
@SuppressWarnings("unused") @SuppressWarnings("unused")
static class TestClientCacheConfiguration { static class TestClientCacheConfiguration {
@Bean @Bean
ClientCacheConfigurer testClientCacheConfigurer() { ClientCacheConfigurer testClientCacheConfigurer() {
return (beanName, factoryBean) -> { return (beanName, factoryBean) -> {
factoryBean.setEvictionHeapPercentage(90.0f); factoryBean.setEvictionHeapPercentage(90.0f);
factoryBean.setPdxReadSerialized(false); factoryBean.setPdxReadSerialized(false);

View File

@@ -23,6 +23,7 @@ import java.util.Optional;
import org.apache.geode.cache.GemFireCache; import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region; import org.apache.geode.cache.Region;
import org.apache.geode.cache.control.ResourceManager;
import org.junit.After; import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
@@ -68,6 +69,30 @@ public class EnableOffHeapConfigurationUnitTests {
assertThat(region.getAttributes().getOffHeap()).isEqualTo(offHeapEnabled); assertThat(region.getAttributes().getOffHeap()).isEqualTo(offHeapEnabled);
} }
@Test
public void offHeapCriticalAndEvictionMemoryPercentagesConfiguredProperly() {
this.applicationContext = newApplicationContext(OffHeapCriticalAndEvictionMemoryPercentagesConfiguration.class);
assertThat(this.applicationContext).isNotNull();
GemFireCache gemfireCache = this.applicationContext.getBean("gemfireCache", GemFireCache.class);
assertThat(gemfireCache).isNotNull();
assertThat(gemfireCache.getDistributedSystem()).isNotNull();
assertThat(gemfireCache.getDistributedSystem().getProperties()).containsKey("off-heap-memory-size");
assertThat(gemfireCache.getDistributedSystem().getProperties().getProperty("off-heap-memory-size"))
.isEqualTo("1024g");
ResourceManager resourceManager = gemfireCache.getResourceManager();
assertThat(resourceManager).isNotNull();
assertThat(resourceManager.getCriticalHeapPercentage()).isEqualTo(95.55f);
assertThat(resourceManager.getCriticalOffHeapPercentage()).isEqualTo(90.5f);
assertThat(resourceManager.getEvictionHeapPercentage()).isEqualTo(85.75f);
assertThat(resourceManager.getEvictionOffHeapPercentage()).isEqualTo(75.25f);
}
@Test @Test
public void offHeapConfiguredForAllRegions() { public void offHeapConfiguredForAllRegions() {
@@ -160,7 +185,6 @@ public class EnableOffHeapConfigurationUnitTests {
@EnableEntityDefinedRegions(basePackageClasses = Person.class) @EnableEntityDefinedRegions(basePackageClasses = Person.class)
@EnableOffHeap(memorySize = "8192m") @EnableOffHeap(memorySize = "8192m")
@Import(TestRegionConfiguration.class) @Import(TestRegionConfiguration.class)
@SuppressWarnings("unused")
static class EnableOffHeapForAllRegionsConfiguration { static class EnableOffHeapForAllRegionsConfiguration {
} }
@@ -169,7 +193,17 @@ public class EnableOffHeapConfigurationUnitTests {
@EnableEntityDefinedRegions(basePackageClasses = Person.class) @EnableEntityDefinedRegions(basePackageClasses = Person.class)
@EnableOffHeap(memorySize = "1024m", regionNames = { "People", "ExamplePartitionRegion" }) @EnableOffHeap(memorySize = "1024m", regionNames = { "People", "ExamplePartitionRegion" })
@Import(TestRegionConfiguration.class) @Import(TestRegionConfiguration.class)
@SuppressWarnings("unused")
static class EnableOffHeapForSelectRegionsConfiguration { static class EnableOffHeapForSelectRegionsConfiguration {
} }
@EnableGemFireMockObjects
@PeerCacheApplication(
criticalHeapPercentage = 95.55f,
criticalOffHeapPercentage = 90.5f,
evictionHeapPercentage = 85.75f,
evictionOffHeapPercentage = 75.25f
)
@EnableOffHeap(memorySize = "1024g")
static class OffHeapCriticalAndEvictionMemoryPercentagesConfiguration {
}
} }

View File

@@ -58,14 +58,12 @@ public class PeerCacheApplicationIntegrationTests {
assertThat(echo.get("Test")).isEqualTo("Test"); assertThat(echo.get("Test")).isEqualTo("Test");
} }
//@EnableLocator
//@PeerCacheApplication(name = "PeerCacheApplicationIntegrationTests",
// logLevel = "warn", locators="localhost[10334]")
@PeerCacheApplication(name = "PeerCacheApplicationIntegrationTests", logLevel="warn") @PeerCacheApplication(name = "PeerCacheApplicationIntegrationTests", logLevel="warn")
static class PeerCacheApplicationConfiguration { static class PeerCacheApplicationConfiguration {
@Bean("Echo") @Bean("Echo")
PartitionedRegionFactoryBean<String, String> echoRegion(Cache gemfireCache) { PartitionedRegionFactoryBean<String, String> echoRegion(Cache gemfireCache) {
PartitionedRegionFactoryBean<String, String> echoRegion = PartitionedRegionFactoryBean<String, String> echoRegion =
new PartitionedRegionFactoryBean<String, String>(); new PartitionedRegionFactoryBean<String, String>();
@@ -78,7 +76,9 @@ public class PeerCacheApplicationIntegrationTests {
} }
CacheLoader<String, String> echoCacheLoader() { CacheLoader<String, String> echoCacheLoader() {
return new CacheLoader<String, String>() { return new CacheLoader<String, String>() {
@Override @Override
public String load(LoaderHelper<String, String> helper) throws CacheLoaderException { public String load(LoaderHelper<String, String> helper) throws CacheLoaderException {
return helper.getKey(); return helper.getKey();

View File

@@ -75,7 +75,9 @@ public class PeerCachePropertiesIntegrationTests {
MockPropertySource testPropertySource = new MockPropertySource() MockPropertySource testPropertySource = new MockPropertySource()
.withProperty("spring.data.gemfire.cache.copy-on-read", true) .withProperty("spring.data.gemfire.cache.copy-on-read", true)
.withProperty("spring.data.gemfire.cache.critical-heap-percentage", 95.0f) .withProperty("spring.data.gemfire.cache.critical-heap-percentage", 95.0f)
.withProperty("spring.data.gemfire.cache.critical-off-heap-percentage", 90.0f)
.withProperty("spring.data.gemfire.cache.eviction-heap-percentage", 85.0f) .withProperty("spring.data.gemfire.cache.eviction-heap-percentage", 85.0f)
.withProperty("spring.data.gemfire.cache.eviction-off-heap-percentage", 80.0f)
.withProperty("spring.data.gemfire.cache.peer.lock-lease", 180) .withProperty("spring.data.gemfire.cache.peer.lock-lease", 180)
.withProperty("spring.data.gemfire.cache.peer.lock-timeout", 30) .withProperty("spring.data.gemfire.cache.peer.lock-timeout", 30)
.withProperty("spring.data.gemfire.cache.peer.search-timeout", 120) .withProperty("spring.data.gemfire.cache.peer.search-timeout", 120)
@@ -107,7 +109,9 @@ public class PeerCachePropertiesIntegrationTests {
assertThat(resourceManager).isNotNull(); assertThat(resourceManager).isNotNull();
assertThat(resourceManager.getCriticalHeapPercentage()).isEqualTo(95.0f); assertThat(resourceManager.getCriticalHeapPercentage()).isEqualTo(95.0f);
assertThat(resourceManager.getCriticalOffHeapPercentage()).isEqualTo(90.0f);
assertThat(resourceManager.getEvictionHeapPercentage()).isEqualTo(85.0f); assertThat(resourceManager.getEvictionHeapPercentage()).isEqualTo(85.0f);
assertThat(resourceManager.getEvictionOffHeapPercentage()).isEqualTo(80.0f);
} }
@Test @Test

View File

@@ -1656,14 +1656,12 @@ public abstract class MockGemFireObjectsSupport extends MockObjectsSupport {
AtomicReference<Float> criticalHeapPercentage = AtomicReference<Float> criticalHeapPercentage =
new AtomicReference<>(ResourceManager.DEFAULT_CRITICAL_PERCENTAGE); new AtomicReference<>(ResourceManager.DEFAULT_CRITICAL_PERCENTAGE);
AtomicReference<Float> criticalOffHeapPercentage = AtomicReference<Float> criticalOffHeapPercentage = new AtomicReference<>(0.0f);
new AtomicReference<>(ResourceManager.DEFAULT_CRITICAL_PERCENTAGE);
AtomicReference<Float> evictionHeapPercentage = AtomicReference<Float> evictionHeapPercentage =
new AtomicReference<>(ResourceManager.DEFAULT_EVICTION_PERCENTAGE); new AtomicReference<>(ResourceManager.DEFAULT_EVICTION_PERCENTAGE);
AtomicReference<Float> evictionOffHeapPercentage = AtomicReference<Float> evictionOffHeapPercentage = new AtomicReference<>(0.0f);
new AtomicReference<>(ResourceManager.DEFAULT_EVICTION_PERCENTAGE);
doAnswer(newSetter(criticalHeapPercentage, null)) doAnswer(newSetter(criticalHeapPercentage, null))
.when(mockResourceManager).setCriticalHeapPercentage(anyFloat()); .when(mockResourceManager).setCriticalHeapPercentage(anyFloat());