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:
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,6 @@ import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeList
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
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.Configuration;
|
||||
import org.springframework.context.annotation.ImportAware;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
@@ -126,7 +126,9 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
private Integer mcastPort = 0;
|
||||
|
||||
private Float criticalHeapPercentage;
|
||||
private Float criticalOffHeapPercentage;
|
||||
private Float evictionHeapPercentage;
|
||||
private Float evictionOffHeapPercentage;
|
||||
|
||||
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
|
||||
* 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 #locators()
|
||||
* @see #logLevel()
|
||||
@@ -192,6 +194,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
*/
|
||||
@Override
|
||||
public void setImportMetadata(AnnotationMetadata importMetadata) {
|
||||
|
||||
configureInfrastructure(importMetadata);
|
||||
configureCache(importMetadata);
|
||||
configurePdx(importMetadata);
|
||||
@@ -207,6 +210,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
* @see org.springframework.core.type.AnnotationMetadata
|
||||
*/
|
||||
protected void configureInfrastructure(AnnotationMetadata importMetadata) {
|
||||
|
||||
registerCustomEditorBeanFactoryPostProcessor(importMetadata);
|
||||
registerDefinedIndexesApplicationListener(importMetadata);
|
||||
registerDiskStoreDirectoryBeanPostProcessor(importMetadata);
|
||||
@@ -249,8 +253,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
|
||||
if (isClientPeerOrServerCacheApplication(importMetadata)) {
|
||||
|
||||
Map<String, Object> cacheMetadataAttributes =
|
||||
importMetadata.getAnnotationAttributes(getAnnotationTypeName());
|
||||
AnnotationAttributes cacheMetadataAttributes = getAnnotationAttributes(importMetadata);
|
||||
|
||||
setCopyOnRead(resolveProperty(cacheProperty("copy-on-read"),
|
||||
Boolean.TRUE.equals(cacheMetadataAttributes.get("copyOnRead"))));
|
||||
@@ -263,6 +266,14 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
.filter(AbstractAnnotationConfigSupport::hasValue)
|
||||
.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))
|
||||
.ifPresent(this::setEvictionHeapPercentage);
|
||||
|
||||
@@ -271,6 +282,14 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
.filter(AbstractAnnotationConfigSupport::hasValue)
|
||||
.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"),
|
||||
(String) cacheMetadataAttributes.get("logLevel")));
|
||||
|
||||
@@ -297,7 +316,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
|
||||
if (importMetadata.hasAnnotation(enablePdxTypeName)) {
|
||||
|
||||
Map<String, Object> enablePdxAttributes = importMetadata.getAnnotationAttributes(enablePdxTypeName);
|
||||
AnnotationAttributes enablePdxAttributes = getAnnotationAttributes(importMetadata, enablePdxTypeName);
|
||||
|
||||
setPdxDiskStoreName(resolveProperty(pdxProperty("disk-store-name"),
|
||||
(String) enablePdxAttributes.get("diskStoreName")));
|
||||
@@ -377,6 +396,7 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
Optional.ofNullable(getPdxDiskStoreName())
|
||||
.filter(StringUtils::hasText)
|
||||
.ifPresent(pdxDiskStoreName -> {
|
||||
|
||||
if (PDX_DISK_STORE_AWARE_BEAN_FACTORY_POST_PROCESSOR_REGISTERED.compareAndSet(false, true)) {
|
||||
register(BeanDefinitionBuilder.rootBeanDefinition(PdxDiskStoreAwareBeanFactoryPostProcessor.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
@@ -450,8 +470,10 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
gemfireCache.setClose(isClose());
|
||||
gemfireCache.setCopyOnRead(getCopyOnRead());
|
||||
gemfireCache.setCriticalHeapPercentage(getCriticalHeapPercentage());
|
||||
gemfireCache.setCriticalOffHeapPercentage(getCriticalOffHeapPercentage());
|
||||
gemfireCache.setDynamicRegionSupport(getDynamicRegionSupport());
|
||||
gemfireCache.setEvictionHeapPercentage(getEvictionHeapPercentage());
|
||||
gemfireCache.setEvictionOffHeapPercentage(getEvictionOffHeapPercentage());
|
||||
gemfireCache.setGatewayConflictResolver(getGatewayConflictResolver());
|
||||
gemfireCache.setJndiDataSources(getJndiDataSources());
|
||||
gemfireCache.setProperties(gemfireProperties());
|
||||
@@ -466,42 +488,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
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
|
||||
|
||||
/**
|
||||
@@ -604,7 +590,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
|| isPeerCacheApplication(importMetadata));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setCacheXml(Resource cacheXml) {
|
||||
this.cacheXml = cacheXml;
|
||||
}
|
||||
@@ -613,7 +598,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.cacheXml;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setClose(boolean close) {
|
||||
this.close = close;
|
||||
}
|
||||
@@ -622,7 +606,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.close;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setCopyOnRead(boolean copyOnRead) {
|
||||
this.copyOnRead = copyOnRead;
|
||||
}
|
||||
@@ -631,7 +614,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.copyOnRead;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setCriticalHeapPercentage(Float criticalHeapPercentage) {
|
||||
this.criticalHeapPercentage = criticalHeapPercentage;
|
||||
}
|
||||
@@ -640,7 +622,14 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.criticalHeapPercentage;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setCriticalOffHeapPercentage(Float criticalOffHeapPercentage) {
|
||||
this.criticalOffHeapPercentage = criticalOffHeapPercentage;
|
||||
}
|
||||
|
||||
protected Float getCriticalOffHeapPercentage() {
|
||||
return this.criticalOffHeapPercentage;
|
||||
}
|
||||
|
||||
void setDynamicRegionSupport(DynamicRegionSupport dynamicRegionSupport) {
|
||||
this.dynamicRegionSupport = dynamicRegionSupport;
|
||||
}
|
||||
@@ -649,7 +638,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.dynamicRegionSupport;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setEvictionHeapPercentage(Float evictionHeapPercentage) {
|
||||
this.evictionHeapPercentage = evictionHeapPercentage;
|
||||
}
|
||||
@@ -658,7 +646,14 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.evictionHeapPercentage;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setEvictionOffHeapPercentage(Float evictionOffHeapPercentage) {
|
||||
this.evictionOffHeapPercentage = evictionOffHeapPercentage;
|
||||
}
|
||||
|
||||
protected Float getEvictionOffHeapPercentage() {
|
||||
return this.evictionOffHeapPercentage;
|
||||
}
|
||||
|
||||
void setGatewayConflictResolver(GatewayConflictResolver gatewayConflictResolver) {
|
||||
this.gatewayConflictResolver = gatewayConflictResolver;
|
||||
}
|
||||
@@ -667,7 +662,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.gatewayConflictResolver;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setJndiDataSources(List<JndiDataSource> jndiDataSources) {
|
||||
this.jndiDataSources = jndiDataSources;
|
||||
}
|
||||
@@ -676,7 +670,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return nullSafeList(this.jndiDataSources);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setLocators(String locators) {
|
||||
this.locators = locators;
|
||||
this.mcastPort = DEFAULT_MCAST_PORT;
|
||||
@@ -686,7 +679,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.locators;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setLogLevel(String logLevel) {
|
||||
this.logLevel = logLevel;
|
||||
}
|
||||
@@ -695,7 +687,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return Optional.ofNullable(this.logLevel).orElse(DEFAULT_LOG_LEVEL);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setMappingContext(GemfireMappingContext mappingContext) {
|
||||
this.mappingContext = mappingContext;
|
||||
}
|
||||
@@ -713,7 +704,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return Optional.ofNullable(mcastPort).orElse(DEFAULT_MCAST_PORT);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setName(String 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);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setPdxDiskStoreName(String pdxDiskStoreName) {
|
||||
this.pdxDiskStoreName = pdxDiskStoreName;
|
||||
}
|
||||
@@ -731,7 +720,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.pdxDiskStoreName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setPdxIgnoreUnreadFields(Boolean pdxIgnoreUnreadFields) {
|
||||
this.pdxIgnoreUnreadFields = pdxIgnoreUnreadFields;
|
||||
}
|
||||
@@ -740,7 +728,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.pdxIgnoreUnreadFields;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setPdxPersistent(Boolean pdxPersistent) {
|
||||
this.pdxPersistent = pdxPersistent;
|
||||
}
|
||||
@@ -749,7 +736,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.pdxPersistent;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setPdxReadSerialized(Boolean pdxReadSerialized) {
|
||||
this.pdxReadSerialized = pdxReadSerialized;
|
||||
}
|
||||
@@ -758,7 +744,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.pdxReadSerialized;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setPdxSerializer(PdxSerializer pdxSerializer) {
|
||||
this.pdxSerializer = pdxSerializer;
|
||||
}
|
||||
@@ -767,7 +752,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.pdxSerializer;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setStartLocator(String startLocator) {
|
||||
this.startLocator = startLocator;
|
||||
}
|
||||
@@ -776,7 +760,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.startLocator;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setTransactionListeners(List<TransactionListener> transactionListeners) {
|
||||
this.transactionListeners = transactionListeners;
|
||||
}
|
||||
@@ -785,7 +768,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return nullSafeList(this.transactionListeners);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setTransactionWriter(TransactionWriter transactionWriter) {
|
||||
this.transactionWriter = transactionWriter;
|
||||
}
|
||||
@@ -794,7 +776,6 @@ public abstract class AbstractCacheConfiguration extends AbstractAnnotationConfi
|
||||
return this.transactionWriter;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setUseBeanFactoryLocator(boolean useBeanFactoryLocator) {
|
||||
this.useBeanFactoryLocator = useBeanFactoryLocator;
|
||||
}
|
||||
|
||||
@@ -96,6 +96,16 @@ public @interface CacheServerApplication {
|
||||
*/
|
||||
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
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
* 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 "";
|
||||
|
||||
|
||||
@@ -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.nullSafeSet;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -39,6 +40,7 @@ import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.data.gemfire.server.CacheServerFactoryBean;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
|
||||
@@ -145,6 +147,7 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return Optional.ofNullable(this.cacheServerConfigurers)
|
||||
.filter(cacheServerConfigurers -> !cacheServerConfigurers.isEmpty())
|
||||
.orElseGet(() ->
|
||||
|
||||
Optional.of(this.getBeanFactory())
|
||||
.filter(beanFactory -> beanFactory instanceof ListableBeanFactory)
|
||||
.map(beanFactory -> {
|
||||
@@ -175,8 +178,7 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
|
||||
if (isCacheServerApplication(importMetadata)) {
|
||||
|
||||
Map<String, Object> cacheServerApplicationAttributes =
|
||||
importMetadata.getAnnotationAttributes(getAnnotationTypeName());
|
||||
AnnotationAttributes cacheServerApplicationAttributes = getAnnotationAttributes(importMetadata);
|
||||
|
||||
setAutoStartup(resolveProperty(cacheServerProperty("auto-startup"),
|
||||
Boolean.TRUE.equals(cacheServerApplicationAttributes.get("autoStartup"))));
|
||||
@@ -229,11 +231,10 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class getAnnotationType() {
|
||||
protected Class<? extends Annotation> getAnnotationType() {
|
||||
return CacheServerApplication.class;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setAutoStartup(boolean autoStartup) {
|
||||
this.autoStartup = autoStartup;
|
||||
}
|
||||
@@ -242,7 +243,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return this.autoStartup;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setBindAddress(String bindAddress) {
|
||||
this.bindAddress = bindAddress;
|
||||
}
|
||||
@@ -252,7 +252,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
.orElse(CacheServer.DEFAULT_BIND_ADDRESS);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setHostnameForClients(String hostnameForClients) {
|
||||
this.hostnameForClients = hostnameForClients;
|
||||
}
|
||||
@@ -262,7 +261,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
.orElse(CacheServer.DEFAULT_HOSTNAME_FOR_CLIENTS);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setInterestRegistrationListeners(Set<InterestRegistrationListener> interestRegistrationListeners) {
|
||||
this.interestRegistrationListeners = interestRegistrationListeners;
|
||||
}
|
||||
@@ -271,7 +269,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return nullSafeSet(this.interestRegistrationListeners);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setLoadPollInterval(Long loadPollInterval) {
|
||||
this.loadPollInterval = loadPollInterval;
|
||||
}
|
||||
@@ -280,7 +277,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return Optional.ofNullable(this.loadPollInterval).orElse(CacheServer.DEFAULT_LOAD_POLL_INTERVAL);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setMaxConnections(Integer maxConnections) {
|
||||
this.maxConnections = maxConnections;
|
||||
}
|
||||
@@ -289,7 +285,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return Optional.ofNullable(this.maxConnections).orElse(CacheServer.DEFAULT_MAX_CONNECTIONS);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setMaxMessageCount(Integer maxMessageCount) {
|
||||
this.maxMessageCount = maxMessageCount;
|
||||
}
|
||||
@@ -298,7 +293,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return Optional.ofNullable(this.maxMessageCount).orElse(CacheServer.DEFAULT_MAXIMUM_MESSAGE_COUNT);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setMaxThreads(Integer maxThreads) {
|
||||
this.maxThreads = maxThreads;
|
||||
}
|
||||
@@ -307,7 +301,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return Optional.ofNullable(this.maxThreads).orElse(CacheServer.DEFAULT_MAX_THREADS);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setMaxTimeBetweenPings(Integer 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);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setMessageTimeToLive(Integer 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);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
@@ -334,7 +325,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return Optional.ofNullable(this.port).orElse(CacheServer.DEFAULT_PORT);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setServerLoadProbe(ServerLoadProbe serverLoadProbe) {
|
||||
this.serverLoadProbe = serverLoadProbe;
|
||||
}
|
||||
@@ -343,7 +333,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return Optional.ofNullable(this.serverLoadProbe).orElse(CacheServer.DEFAULT_LOAD_PROBE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setSocketBufferSize(Integer socketBufferSize) {
|
||||
this.socketBufferSize = socketBufferSize;
|
||||
}
|
||||
@@ -352,7 +341,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return Optional.ofNullable(this.socketBufferSize).orElse(CacheServer.DEFAULT_SOCKET_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setSubscriptionCapacity(Integer subscriptionCapacity) {
|
||||
this.subscriptionCapacity = subscriptionCapacity;
|
||||
}
|
||||
@@ -361,7 +349,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return Optional.ofNullable(this.subscriptionCapacity).orElse(ClientSubscriptionConfig.DEFAULT_CAPACITY);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setSubscriptionDiskStoreName(String subscriptionDiskStoreName) {
|
||||
this.subscriptionDiskStoreName = subscriptionDiskStoreName;
|
||||
}
|
||||
@@ -370,7 +357,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return this.subscriptionDiskStoreName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setSubscriptionEvictionPolicy(SubscriptionEvictionPolicy subscriptionEvictionPolicy) {
|
||||
this.subscriptionEvictionPolicy = subscriptionEvictionPolicy;
|
||||
}
|
||||
@@ -379,7 +365,6 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
return Optional.ofNullable(this.subscriptionEvictionPolicy).orElse(SubscriptionEvictionPolicy.DEFAULT);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setTcpNoDelay(Boolean tcpNoDelay) {
|
||||
this.tcpNoDelay = tcpNoDelay;
|
||||
}
|
||||
@@ -388,6 +373,14 @@ public class CacheServerConfiguration extends PeerCacheConfiguration {
|
||||
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
|
||||
public String toString() {
|
||||
return DEFAULT_NAME;
|
||||
|
||||
@@ -71,6 +71,16 @@ public @interface ClientCacheApplication {
|
||||
*/
|
||||
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
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.data.gemfire.config.annotation;
|
||||
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeMap;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -160,6 +161,7 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return Optional.ofNullable(this.clientCacheConfigurers)
|
||||
.filter(clientCacheConfigurers -> !clientCacheConfigurers.isEmpty())
|
||||
.orElseGet(() ->
|
||||
|
||||
Optional.of(this.getBeanFactory())
|
||||
.filter(beanFactory -> beanFactory instanceof ListableBeanFactory)
|
||||
.map(beanFactory -> {
|
||||
@@ -230,8 +232,7 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
|
||||
if (isClientCacheApplication(importMetadata)) {
|
||||
|
||||
Map<String, Object> clientCacheApplicationAttributes =
|
||||
importMetadata.getAnnotationAttributes(getAnnotationTypeName());
|
||||
AnnotationAttributes clientCacheApplicationAttributes = getAnnotationAttributes(importMetadata);
|
||||
|
||||
setDurableClientId(resolveProperty(cacheClientProperty("durable-client-id"),
|
||||
(String) clientCacheApplicationAttributes.get("durableClientId")));
|
||||
@@ -358,10 +359,13 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
resolveProperty(poolProperty("locators"), (String) null));
|
||||
|
||||
if (StringUtils.hasText(locatorsFromProperty)) {
|
||||
|
||||
String[] locatorHostsPorts = locatorsFromProperty.split(",");
|
||||
|
||||
poolLocators = ConnectionEndpointList.parse(GemfireUtils.DEFAULT_LOCATOR_PORT, locatorHostsPorts);
|
||||
}
|
||||
else {
|
||||
|
||||
poolLocators = new ConnectionEndpointList();
|
||||
|
||||
AnnotationAttributes[] locators = (AnnotationAttributes[]) clientCacheApplicationAttributes.get("locators");
|
||||
@@ -395,7 +399,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
setPoolServers(poolServers);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected ConnectionEndpoint newConnectionEndpoint(String host, Integer port) {
|
||||
return new ConnectionEndpoint(host, port);
|
||||
}
|
||||
@@ -404,11 +407,10 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Class getAnnotationType() {
|
||||
protected Class<? extends Annotation> getAnnotationType() {
|
||||
return ClientCacheApplication.class;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setDurableClientId(String durableClientId) {
|
||||
this.durableClientId = durableClientId;
|
||||
}
|
||||
@@ -417,7 +419,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.durableClientId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setDurableClientTimeout(Integer durableClientTimeout) {
|
||||
this.durableClientTimeout = durableClientTimeout;
|
||||
}
|
||||
@@ -426,7 +427,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.durableClientTimeout;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setFreeConnectionTimeout(Integer freeConnectionTimeout) {
|
||||
this.freeConnectionTimeout = freeConnectionTimeout;
|
||||
}
|
||||
@@ -435,7 +435,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.freeConnectionTimeout;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setIdleTimeout(Long idleTimeout) {
|
||||
this.idleTimeout = idleTimeout;
|
||||
}
|
||||
@@ -444,7 +443,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.idleTimeout;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setKeepAlive(Boolean keepAlive) {
|
||||
this.keepAlive = keepAlive;
|
||||
}
|
||||
@@ -453,7 +451,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.keepAlive;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setLoadConditioningInterval(Integer loadConditioningInterval) {
|
||||
this.loadConditioningInterval = loadConditioningInterval;
|
||||
}
|
||||
@@ -462,7 +459,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.loadConditioningInterval;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setMaxConnections(Integer maxConnections) {
|
||||
this.maxConnections = maxConnections;
|
||||
}
|
||||
@@ -471,7 +467,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.maxConnections;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setMinConnections(Integer minConnections) {
|
||||
this.minConnections = minConnections;
|
||||
}
|
||||
@@ -480,7 +475,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.minConnections;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setMultiUserAuthentication(Boolean multiUserAuthentication) {
|
||||
this.multiUserAuthentication = multiUserAuthentication;
|
||||
}
|
||||
@@ -489,7 +483,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.multiUserAuthentication;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setPingInterval(Long pingInterval) {
|
||||
this.pingInterval = pingInterval;
|
||||
}
|
||||
@@ -498,7 +491,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.pingInterval;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setPoolLocators(Iterable<ConnectionEndpoint> locators) {
|
||||
this.locators = locators;
|
||||
}
|
||||
@@ -507,7 +499,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.locators;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setPoolServers(Iterable<ConnectionEndpoint> servers) {
|
||||
this.servers = servers;
|
||||
}
|
||||
@@ -516,7 +507,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.servers;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setPrSingleHopEnabled(Boolean prSingleHopEnabled) {
|
||||
this.prSingleHopEnabled = prSingleHopEnabled;
|
||||
}
|
||||
@@ -525,7 +515,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.prSingleHopEnabled;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setReadTimeout(Integer readTimeout) {
|
||||
this.readTimeout = readTimeout;
|
||||
}
|
||||
@@ -534,7 +523,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.readTimeout;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setReadyForEvents(boolean readyForEvents) {
|
||||
this.readyForEvents = readyForEvents;
|
||||
}
|
||||
@@ -543,7 +531,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.readyForEvents;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setRetryAttempts(Integer retryAttempts) {
|
||||
this.retryAttempts = retryAttempts;
|
||||
}
|
||||
@@ -552,7 +539,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.retryAttempts;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setServerGroup(String serverGroup) {
|
||||
this.serverGroup = serverGroup;
|
||||
}
|
||||
@@ -561,7 +547,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.serverGroup;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setSocketBufferSize(Integer socketBufferSize) {
|
||||
this.socketBufferSize = socketBufferSize;
|
||||
}
|
||||
@@ -570,7 +555,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.socketBufferSize;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setStatisticsInterval(Integer statisticsInterval) {
|
||||
this.statisticsInterval = statisticsInterval;
|
||||
}
|
||||
@@ -579,7 +563,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.statisticsInterval;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setSubscriptionAckInterval(Integer subscriptionAckInterval) {
|
||||
this.subscriptionAckInterval = subscriptionAckInterval;
|
||||
}
|
||||
@@ -588,7 +571,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.subscriptionAckInterval;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setSubscriptionEnabled(Boolean subscriptionEnabled) {
|
||||
this.subscriptionEnabled = subscriptionEnabled;
|
||||
}
|
||||
@@ -597,7 +579,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.subscriptionEnabled;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setSubscriptionMessageTrackingTimeout(Integer subscriptionMessageTrackingTimeout) {
|
||||
this.subscriptionMessageTrackingTimeout = subscriptionMessageTrackingTimeout;
|
||||
}
|
||||
@@ -606,7 +587,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.subscriptionMessageTrackingTimeout;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setSubscriptionRedundancy(Integer subscriptionRedundancy) {
|
||||
this.subscriptionRedundancy = subscriptionRedundancy;
|
||||
}
|
||||
@@ -615,7 +595,6 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.subscriptionRedundancy;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setThreadLocalConnections(Boolean threadLocalConnections) {
|
||||
this.threadLocalConnections = threadLocalConnections;
|
||||
}
|
||||
@@ -624,6 +603,14 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
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
|
||||
public String toString() {
|
||||
return DEFAULT_NAME;
|
||||
|
||||
@@ -70,6 +70,16 @@ public @interface PeerCacheApplication {
|
||||
*/
|
||||
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
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.data.gemfire.CacheFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -42,11 +43,15 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.springframework.beans.factory.ListableBeanFactory
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see org.springframework.context.annotation.Configuration
|
||||
* @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.AdministrativeConfiguration
|
||||
* @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication
|
||||
* @see org.springframework.data.gemfire.config.annotation.PeerCacheConfigurer
|
||||
* @since 1.9.0
|
||||
*/
|
||||
@Configuration
|
||||
@@ -102,6 +107,7 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return Optional.ofNullable(this.peerCacheConfigurers)
|
||||
.filter(peerCacheConfigurers -> !peerCacheConfigurers.isEmpty())
|
||||
.orElseGet(() ->
|
||||
|
||||
Optional.of(this.getBeanFactory())
|
||||
.filter(beanFactory -> beanFactory instanceof ListableBeanFactory)
|
||||
.map(beanFactory -> {
|
||||
@@ -144,8 +150,7 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
|
||||
if (isCacheServerOrPeerCacheApplication(importMetadata)) {
|
||||
|
||||
Map<String, Object> peerCacheApplicationAttributes =
|
||||
importMetadata.getAnnotationAttributes(getAnnotationTypeName());
|
||||
AnnotationAttributes peerCacheApplicationAttributes = getAnnotationAttributes(importMetadata);
|
||||
|
||||
if (peerCacheApplicationAttributes != null) {
|
||||
|
||||
@@ -174,6 +179,10 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
Optional.ofNullable(resolveProperty(cachePeerProperty("locators"), (String) null))
|
||||
.filter(StringUtils::hasText)
|
||||
.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;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setEnableAutoReconnect(boolean enableAutoReconnect) {
|
||||
this.enableAutoReconnect = enableAutoReconnect;
|
||||
}
|
||||
@@ -195,7 +203,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.enableAutoReconnect;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setLockLease(Integer lockLease) {
|
||||
this.lockLease = lockLease;
|
||||
}
|
||||
@@ -204,7 +211,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.lockLease;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setLockTimeout(Integer lockTimeout) {
|
||||
this.lockTimeout = lockTimeout;
|
||||
}
|
||||
@@ -213,7 +219,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.lockTimeout;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setMessageSyncInterval(Integer messageSyncInterval) {
|
||||
this.messageSyncInterval = messageSyncInterval;
|
||||
}
|
||||
@@ -222,7 +227,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.messageSyncInterval;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setSearchTimeout(Integer searchTimeout) {
|
||||
this.searchTimeout = searchTimeout;
|
||||
}
|
||||
@@ -231,7 +235,6 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.searchTimeout;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
void setUseClusterConfiguration(boolean useClusterConfiguration) {
|
||||
this.useClusterConfiguration = useClusterConfiguration;
|
||||
}
|
||||
@@ -240,6 +243,14 @@ public class PeerCacheConfiguration extends AbstractCacheConfiguration {
|
||||
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
|
||||
public String toString() {
|
||||
return DEFAULT_NAME;
|
||||
|
||||
@@ -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.ThreadUtils;
|
||||
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.FileCopyUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -64,7 +64,7 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.springframework.data.gemfire.client.GemfireDataSourcePostProcessor
|
||||
* @since 1.7.0
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings({ "rawtypes", "unused"})
|
||||
public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTest {
|
||||
@@ -88,7 +88,8 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
|
||||
@BeforeClass
|
||||
public static void setupBeforeClass() throws IOException {
|
||||
System.setProperty("gemfire.log-level", "warning");
|
||||
|
||||
System.setProperty("gemfire.log-level", "error");
|
||||
|
||||
String serverName = "GemFireDataSourceGemFireBasedServer";
|
||||
|
||||
@@ -123,6 +124,7 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
}
|
||||
|
||||
private static String customClasspath() {
|
||||
|
||||
String[] classpathElements = ProcessExecutor.JAVA_CLASSPATH.split(File.pathSeparator);
|
||||
|
||||
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) {
|
||||
|
||||
ThreadUtils.timedWait(milliseconds, TimeUnit.MILLISECONDS.toMillis(500), new ThreadUtils.WaitCondition() {
|
||||
private File processControlFile = new File(process.getWorkingDirectory(), processControlFilename);
|
||||
|
||||
@@ -148,6 +151,7 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
|
||||
serverProcess.shutdown();
|
||||
|
||||
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) {
|
||||
|
||||
assertThat(actualRegion, is(not(nullValue())));
|
||||
assertThat(actualRegion.getName(), is(equalTo(expectedRegionName)));
|
||||
assertThat(actualRegion.getFullPath(), is(equalTo(String.format("%1$s%2$s",
|
||||
@@ -168,9 +173,9 @@ public class GemFireDataSourceUsingNonSpringConfiguredGemFireServerIntegrationTe
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void clientProxyRegionBeansExist() {
|
||||
|
||||
assertRegion(localRegion, "LocalRegion");
|
||||
assertRegion(serverRegion, "ServerRegion");
|
||||
assertRegion(anotherServerRegion, "AnotherServerRegion");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -235,7 +236,7 @@ public class AbstractCacheConfigurationUnitTests {
|
||||
protected static class TestCacheConfiguration extends AbstractCacheConfiguration {
|
||||
|
||||
@Override
|
||||
protected Class getAnnotationType() {
|
||||
protected Class<? extends Annotation> getAnnotationType() {
|
||||
throw new UnsupportedOperationException("Not Implemented");
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,9 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
|
||||
MockPropertySource testPropertySource = new MockPropertySource()
|
||||
.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-off-heap-percentage", 80.0f)
|
||||
.withProperty("spring.data.gemfire.pdx.ignore-unread-fields", false)
|
||||
.withProperty("spring.data.gemfire.pdx.persistent", true)
|
||||
.withProperty("spring.data.gemfire.pool.free-connection-timeout", 20000L)
|
||||
@@ -134,7 +136,9 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
|
||||
assertThat(resourceManager).isNotNull();
|
||||
assertThat(resourceManager.getCriticalHeapPercentage()).isEqualTo(90.0f);
|
||||
assertThat(resourceManager.getCriticalOffHeapPercentage()).isEqualTo(95.0f);
|
||||
assertThat(resourceManager.getEvictionHeapPercentage()).isEqualTo(90.0f);
|
||||
assertThat(resourceManager.getEvictionOffHeapPercentage()).isEqualTo(80.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -240,16 +244,17 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
// TODO add more tests!
|
||||
|
||||
@EnableGemFireMockObjects
|
||||
@EnablePdx(ignoreUnreadFields = true, readSerialized = true, serializerBeanName = "mockPdxSerializer")
|
||||
@ClientCacheApplication(name = "TestClientCache", copyOnRead = true,
|
||||
criticalHeapPercentage = 95.0f, evictionHeapPercentage = 80.0f, idleTimeout = 15000L,
|
||||
maxConnections = 100, minConnections = 10, pingInterval = 15000L, readTimeout = 15000, retryAttempts = 1,
|
||||
subscriptionEnabled = true, subscriptionRedundancy = 1)
|
||||
@EnablePdx(ignoreUnreadFields = true, readSerialized = true, serializerBeanName = "mockPdxSerializer")
|
||||
@SuppressWarnings("unused")
|
||||
static class TestClientCacheConfiguration {
|
||||
|
||||
@Bean
|
||||
ClientCacheConfigurer testClientCacheConfigurer() {
|
||||
|
||||
return (beanName, factoryBean) -> {
|
||||
factoryBean.setEvictionHeapPercentage(90.0f);
|
||||
factoryBean.setPdxReadSerialized(false);
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Optional;
|
||||
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.control.ResourceManager;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -68,6 +69,30 @@ public class EnableOffHeapConfigurationUnitTests {
|
||||
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
|
||||
public void offHeapConfiguredForAllRegions() {
|
||||
|
||||
@@ -160,7 +185,6 @@ public class EnableOffHeapConfigurationUnitTests {
|
||||
@EnableEntityDefinedRegions(basePackageClasses = Person.class)
|
||||
@EnableOffHeap(memorySize = "8192m")
|
||||
@Import(TestRegionConfiguration.class)
|
||||
@SuppressWarnings("unused")
|
||||
static class EnableOffHeapForAllRegionsConfiguration {
|
||||
}
|
||||
|
||||
@@ -169,7 +193,17 @@ public class EnableOffHeapConfigurationUnitTests {
|
||||
@EnableEntityDefinedRegions(basePackageClasses = Person.class)
|
||||
@EnableOffHeap(memorySize = "1024m", regionNames = { "People", "ExamplePartitionRegion" })
|
||||
@Import(TestRegionConfiguration.class)
|
||||
@SuppressWarnings("unused")
|
||||
static class EnableOffHeapForSelectRegionsConfiguration {
|
||||
}
|
||||
|
||||
@EnableGemFireMockObjects
|
||||
@PeerCacheApplication(
|
||||
criticalHeapPercentage = 95.55f,
|
||||
criticalOffHeapPercentage = 90.5f,
|
||||
evictionHeapPercentage = 85.75f,
|
||||
evictionOffHeapPercentage = 75.25f
|
||||
)
|
||||
@EnableOffHeap(memorySize = "1024g")
|
||||
static class OffHeapCriticalAndEvictionMemoryPercentagesConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,14 +58,12 @@ public class PeerCacheApplicationIntegrationTests {
|
||||
assertThat(echo.get("Test")).isEqualTo("Test");
|
||||
}
|
||||
|
||||
//@EnableLocator
|
||||
//@PeerCacheApplication(name = "PeerCacheApplicationIntegrationTests",
|
||||
// logLevel = "warn", locators="localhost[10334]")
|
||||
@PeerCacheApplication(name = "PeerCacheApplicationIntegrationTests", logLevel="warn")
|
||||
static class PeerCacheApplicationConfiguration {
|
||||
|
||||
@Bean("Echo")
|
||||
PartitionedRegionFactoryBean<String, String> echoRegion(Cache gemfireCache) {
|
||||
|
||||
PartitionedRegionFactoryBean<String, String> echoRegion =
|
||||
new PartitionedRegionFactoryBean<String, String>();
|
||||
|
||||
@@ -78,7 +76,9 @@ public class PeerCacheApplicationIntegrationTests {
|
||||
}
|
||||
|
||||
CacheLoader<String, String> echoCacheLoader() {
|
||||
|
||||
return new CacheLoader<String, String>() {
|
||||
|
||||
@Override
|
||||
public String load(LoaderHelper<String, String> helper) throws CacheLoaderException {
|
||||
return helper.getKey();
|
||||
|
||||
@@ -75,7 +75,9 @@ public class PeerCachePropertiesIntegrationTests {
|
||||
MockPropertySource testPropertySource = new MockPropertySource()
|
||||
.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-off-heap-percentage", 90.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-timeout", 30)
|
||||
.withProperty("spring.data.gemfire.cache.peer.search-timeout", 120)
|
||||
@@ -107,7 +109,9 @@ public class PeerCachePropertiesIntegrationTests {
|
||||
|
||||
assertThat(resourceManager).isNotNull();
|
||||
assertThat(resourceManager.getCriticalHeapPercentage()).isEqualTo(95.0f);
|
||||
assertThat(resourceManager.getCriticalOffHeapPercentage()).isEqualTo(90.0f);
|
||||
assertThat(resourceManager.getEvictionHeapPercentage()).isEqualTo(85.0f);
|
||||
assertThat(resourceManager.getEvictionOffHeapPercentage()).isEqualTo(80.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1656,14 +1656,12 @@ public abstract class MockGemFireObjectsSupport extends MockObjectsSupport {
|
||||
AtomicReference<Float> criticalHeapPercentage =
|
||||
new AtomicReference<>(ResourceManager.DEFAULT_CRITICAL_PERCENTAGE);
|
||||
|
||||
AtomicReference<Float> criticalOffHeapPercentage =
|
||||
new AtomicReference<>(ResourceManager.DEFAULT_CRITICAL_PERCENTAGE);
|
||||
AtomicReference<Float> criticalOffHeapPercentage = new AtomicReference<>(0.0f);
|
||||
|
||||
AtomicReference<Float> evictionHeapPercentage =
|
||||
new AtomicReference<>(ResourceManager.DEFAULT_EVICTION_PERCENTAGE);
|
||||
|
||||
AtomicReference<Float> evictionOffHeapPercentage =
|
||||
new AtomicReference<>(ResourceManager.DEFAULT_EVICTION_PERCENTAGE);
|
||||
AtomicReference<Float> evictionOffHeapPercentage = new AtomicReference<>(0.0f);
|
||||
|
||||
doAnswer(newSetter(criticalHeapPercentage, null))
|
||||
.when(mockResourceManager).setCriticalHeapPercentage(anyFloat());
|
||||
|
||||
Reference in New Issue
Block a user