Implements JIRA feature request SGF-226 enabling Spring Data GemFire to retrieve the shared, persistent cluster configuration from a GemFire 8 Locator Shared Configuration service when the SDG configured peer cache member joins the cluster.
This commit is contained in:
@@ -58,24 +58,28 @@ import com.gemstone.gemfire.pdx.PdxSerializable;
|
||||
import com.gemstone.gemfire.pdx.PdxSerializer;
|
||||
|
||||
/**
|
||||
* Factory used for configuring a Gemfire Cache manager. Allows either retrieval
|
||||
* of an existing, opened cache or the creation of a new one.
|
||||
*
|
||||
* FactoryBean used to configure a GemFire peer Cache node. Allows either retrieval of an existing, opened Cache
|
||||
* or the creation of a new Cache instance.
|
||||
* <p>
|
||||
* This class implements the
|
||||
* {@link org.springframework.dao.support.PersistenceExceptionTranslator}
|
||||
* This class implements the {@link org.springframework.dao.support.PersistenceExceptionTranslator}
|
||||
* interface, as auto-detected by Spring's
|
||||
* {@link org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor}
|
||||
* , for AOP-based translation of native exceptions to Spring
|
||||
* DataAccessExceptions. Hence, the presence of this class automatically enables
|
||||
* a PersistenceExceptionTranslationPostProcessor to translate GemFire
|
||||
* exceptions.
|
||||
* {@link org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor}, for AOP-based translation
|
||||
* of native Exceptions to Spring DataAccessExceptions. Hence, the presence of this class automatically enables
|
||||
* a PersistenceExceptionTranslationPostProcessor to translate GemFire Exceptions appropriately.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.BeanClassLoaderAware
|
||||
* @see org.springframework.beans.factory.BeanFactoryAware
|
||||
* @see org.springframework.beans.factory.BeanNameAware
|
||||
* @see org.springframework.beans.factory.FactoryBean
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @see org.springframework.beans.factory.DisposableBean
|
||||
* @see org.springframework.dao.support.PersistenceExceptionTranslator
|
||||
*/
|
||||
public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanClassLoaderAware, InitializingBean,
|
||||
DisposableBean, FactoryBean<Cache>, PersistenceExceptionTranslator {
|
||||
public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, FactoryBean<Cache>,
|
||||
InitializingBean, DisposableBean, PersistenceExceptionTranslator {
|
||||
|
||||
protected static final List<String> VALID_JNDI_DATASOURCE_TYPE_NAMES = Collections.unmodifiableList(
|
||||
Arrays.asList("ManagedDataSource", "PooledDataSource", "SimpleDataSource", "XAPooledDataSource"));
|
||||
@@ -93,6 +97,7 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
protected Boolean pdxIgnoreUnreadFields;
|
||||
protected Boolean pdxPersistent;
|
||||
protected Boolean pdxReadSerialized;
|
||||
protected Boolean useSharedConfiguration;
|
||||
|
||||
protected Cache cache;
|
||||
|
||||
@@ -114,7 +119,7 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
|
||||
protected List<TransactionListener> transactionListeners;
|
||||
|
||||
// Defined this way for backward compatibility
|
||||
// Declared with type 'Object' for backward compatibility
|
||||
protected Object gatewayConflictResolver;
|
||||
protected Object pdxSerializer;
|
||||
|
||||
@@ -128,20 +133,19 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
protected TransactionWriter transactionWriter;
|
||||
|
||||
public static class DynamicRegionSupport {
|
||||
private String diskDir;
|
||||
|
||||
private String poolName;
|
||||
|
||||
private Boolean persistent = Boolean.TRUE;
|
||||
|
||||
private Boolean registerInterest = Boolean.TRUE;
|
||||
|
||||
private String diskDirectory;
|
||||
private String poolName;
|
||||
|
||||
public String getDiskDir() {
|
||||
return diskDir;
|
||||
return diskDirectory;
|
||||
}
|
||||
|
||||
public void setDiskDir(String diskDir) {
|
||||
this.diskDir = diskDir;
|
||||
public void setDiskDir(String diskDirectory) {
|
||||
this.diskDirectory = diskDirectory;
|
||||
}
|
||||
|
||||
public Boolean getPersistent() {
|
||||
@@ -152,14 +156,6 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
this.persistent = persistent;
|
||||
}
|
||||
|
||||
public Boolean getRegisterInterest() {
|
||||
return registerInterest;
|
||||
}
|
||||
|
||||
public void setRegisterInterest(Boolean registerInterest) {
|
||||
this.registerInterest = registerInterest;
|
||||
}
|
||||
|
||||
public String getPoolName() {
|
||||
return poolName;
|
||||
}
|
||||
@@ -168,13 +164,20 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
this.poolName = poolName;
|
||||
}
|
||||
|
||||
public Boolean getRegisterInterest() {
|
||||
return registerInterest;
|
||||
}
|
||||
|
||||
public void setRegisterInterest(Boolean registerInterest) {
|
||||
this.registerInterest = registerInterest;
|
||||
}
|
||||
|
||||
public void initializeDynamicRegionFactory() {
|
||||
DynamicRegionFactory.Config config = null;
|
||||
if (diskDir == null) {
|
||||
config = new DynamicRegionFactory.Config(null, poolName, persistent, registerInterest);
|
||||
} else {
|
||||
config = new DynamicRegionFactory.Config(new File(diskDir), poolName, persistent, registerInterest);
|
||||
}
|
||||
File localDiskDirectory = (this.diskDirectory == null ? null : new File(this.diskDirectory));
|
||||
|
||||
DynamicRegionFactory.Config config = new DynamicRegionFactory.Config(localDiskDirectory, poolName,
|
||||
persistent, registerInterest);
|
||||
|
||||
DynamicRegionFactory.get().open(config);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +185,6 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
public static class JndiDataSource {
|
||||
|
||||
private List<ConfigProperty> props;
|
||||
|
||||
private Map<String, String> attributes;
|
||||
|
||||
public Map<String, String> getAttributes() {
|
||||
@@ -294,8 +296,8 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
|
||||
DistributedMember member = system.getDistributedMember();
|
||||
|
||||
log.info(String.format("Connected to Distributed System [%1$s] as Member [%2$s] on Host [%3$s].",
|
||||
system.getName(), member.getId(), member.getHost()));
|
||||
log.info(String.format("Connected to Distributed System [%1$s] as Member [%2$s] in Groups [%3$s] with Roles [%4$s] on Host [%5$s] having PID [%6$d].",
|
||||
system.getName(), member.getId(), member.getGroups(), member.getRoles(), member.getHost(), member.getProcessId()));
|
||||
|
||||
log.info(String.format("%1$s GemFire v.%2$s Cache [%3$s].", messagePrefix, CacheFactory.getVersion(),
|
||||
cache.getName()));
|
||||
@@ -428,43 +430,30 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
|
||||
if (ex instanceof GemFireException) {
|
||||
return GemfireCacheUtils.convertGemfireAccessException((GemFireException) ex);
|
||||
public DataAccessException translateExceptionIfPossible(final RuntimeException e) {
|
||||
if (e instanceof GemFireException) {
|
||||
return GemfireCacheUtils.convertGemfireAccessException((GemFireException) e);
|
||||
}
|
||||
if (ex instanceof IllegalArgumentException) {
|
||||
DataAccessException wrapped = GemfireCacheUtils.convertQueryExceptions(ex);
|
||||
|
||||
if (e instanceof IllegalArgumentException) {
|
||||
DataAccessException wrapped = GemfireCacheUtils.convertQueryExceptions(e);
|
||||
// ignore conversion if the generic exception is returned
|
||||
if (!(wrapped instanceof GemfireSystemException)) {
|
||||
return wrapped;
|
||||
}
|
||||
}
|
||||
if (ex.getCause() instanceof GemFireException) {
|
||||
return GemfireCacheUtils.convertGemfireAccessException((GemFireException) ex.getCause());
|
||||
|
||||
if (e.getCause() instanceof GemFireException) {
|
||||
return GemfireCacheUtils.convertGemfireAccessException((GemFireException) e.getCause());
|
||||
}
|
||||
if (ex.getCause() instanceof GemFireCheckedException) {
|
||||
return GemfireCacheUtils.convertGemfireAccessException((GemFireCheckedException) ex.getCause());
|
||||
|
||||
if (e.getCause() instanceof GemFireCheckedException) {
|
||||
return GemfireCacheUtils.convertGemfireAccessException((GemFireCheckedException) e.getCause());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cache getObject() throws Exception {
|
||||
init();
|
||||
return cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Cache> getObjectType() {
|
||||
return (cache != null ? cache.getClass() : Cache.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
@@ -518,7 +507,13 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
this.useBeanFactoryLocator = usage;
|
||||
}
|
||||
|
||||
public void setEnableAutoReconnect(final Boolean enableAutoReconnect) {
|
||||
/**
|
||||
* Controls whether auto-reconnect functionality introduced in GemFire 8 is enabled or not.
|
||||
*
|
||||
* @param enableAutoReconnect a boolean value to enable/disable auto-reconnect functionality.
|
||||
* @since GemFire 8.0
|
||||
*/
|
||||
public void setEnableAutoReconnect(Boolean enableAutoReconnect) {
|
||||
this.enableAutoReconnect = enableAutoReconnect;
|
||||
}
|
||||
|
||||
@@ -534,25 +529,24 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the object preference to PdxInstance type. Applicable on GemFire 6.6
|
||||
* or higher.
|
||||
*
|
||||
* @param pdxPersistent the pdxPersistent to set
|
||||
*/
|
||||
public void setPdxPersistent(Boolean pdxPersistent) {
|
||||
this.pdxPersistent = pdxPersistent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls whether the type metadata for PDX objects is persisted to disk.
|
||||
* Applicable on GemFire 6.6 or higher.
|
||||
*
|
||||
* @param pdxReadSerialized the pdxReadSerialized to set
|
||||
* Sets the object preference to PdxInstance. Applicable on GemFire 6.6 or higher.
|
||||
*
|
||||
* @param pdxReadSerialized a boolean value indicating the PDX instance should be returned from Region.get(key)
|
||||
* when available.
|
||||
*/
|
||||
public void setPdxReadSerialized(Boolean pdxReadSerialized) {
|
||||
this.pdxReadSerialized = pdxReadSerialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls whether type metadata for PDX objects is persisted to disk. Applicable on GemFire 6.6 or higher.
|
||||
*
|
||||
* @param pdxPersistent a boolean value indicating that PDX type meta-data should be persisted to disk.
|
||||
*/
|
||||
public void setPdxPersistent(Boolean pdxPersistent) {
|
||||
this.pdxPersistent = pdxPersistent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls whether pdx ignores fields that were unread during
|
||||
* deserialization. Applicable on GemFire 6.6 or higher.
|
||||
@@ -574,10 +568,12 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanFactory
|
||||
* Set whether the Cache should be closed.
|
||||
*
|
||||
* @param close set to false if destroy() should not close the cache
|
||||
*/
|
||||
public BeanFactory getBeanFactory() {
|
||||
return beanFactory;
|
||||
public void setClose(boolean close) {
|
||||
this.close = close;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -590,12 +586,21 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of seconds in which the implicit object lock request will timeout.
|
||||
* Set the Cache's critical heap percentage attribute.
|
||||
*
|
||||
* @param lockTimeout an integer value specifying the object lock request timeout.
|
||||
* @param criticalHeapPercentage floating point value indicating the critical heap percentage.
|
||||
*/
|
||||
public void setLockTimeout(Integer lockTimeout) {
|
||||
this.lockTimeout = lockTimeout;
|
||||
public void setCriticalHeapPercentage(Float criticalHeapPercentage) {
|
||||
this.criticalHeapPercentage = criticalHeapPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Cache's eviction heap percentage attribute.
|
||||
*
|
||||
* @param evictionHeapPercentage float-point value indicating the Cache's heap use percentage to trigger eviction.
|
||||
*/
|
||||
public void setEvictionHeapPercentage(Float evictionHeapPercentage) {
|
||||
this.evictionHeapPercentage = evictionHeapPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -607,6 +612,15 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
this.lockLease = lockLease;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of seconds in which the implicit object lock request will timeout.
|
||||
*
|
||||
* @param lockTimeout an integer value specifying the object lock request timeout.
|
||||
*/
|
||||
public void setLockTimeout(Integer lockTimeout) {
|
||||
this.lockTimeout = lockTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set for client subscription queue synchronization when this member acts as a server to clients
|
||||
* and server redundancy is used. Sets the frequency (in seconds) at which the primary server sends messages
|
||||
@@ -628,33 +642,6 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
this.searchTimeout = searchTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Cache's eviction heap percentage attribute.
|
||||
*
|
||||
* @param evictionHeapPercentage float-point value indicating the Cache's heap use percentage to trigger eviction.
|
||||
*/
|
||||
public void setEvictionHeapPercentage(Float evictionHeapPercentage) {
|
||||
this.evictionHeapPercentage = evictionHeapPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Cache's critical heap percentage attribute.
|
||||
*
|
||||
* @param criticalHeapPercentage floating point value indicating the critical heap percentage.
|
||||
*/
|
||||
public void setCriticalHeapPercentage(Float criticalHeapPercentage) {
|
||||
this.criticalHeapPercentage = criticalHeapPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the Cache should be closed.
|
||||
*
|
||||
* @param close set to false if destroy() should not close the cache
|
||||
*/
|
||||
public void setClose(boolean close) {
|
||||
this.close = close;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the list of TransactionListeners used to configure the Cache to receive transaction events after
|
||||
* the transaction is processed (committed, rolled back).
|
||||
@@ -677,16 +664,6 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
this.transactionWriter = transactionWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires GemFire 7.0 or higher
|
||||
* @param gatewayConflictResolver defined as Object in the signature for backward
|
||||
* compatibility with Gemfire 6 compatibility. This must be an instance of
|
||||
* {@link com.gemstone.gemfire.cache.util.GatewayConflictResolver}
|
||||
*/
|
||||
public void setGatewayConflictResolver(Object gatewayConflictResolver) {
|
||||
this.gatewayConflictResolver = gatewayConflictResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an instance of the DynamicRegionSupport to support Dynamic Regions in this GemFire Cache.
|
||||
*
|
||||
@@ -696,6 +673,16 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
this.dynamicRegionSupport = dynamicRegionSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires GemFire 7.0 or higher
|
||||
* @param gatewayConflictResolver defined as Object in the signature for backward
|
||||
* compatibility with Gemfire 6 compatibility. This must be an instance of
|
||||
* {@link com.gemstone.gemfire.cache.util.GatewayConflictResolver}
|
||||
*/
|
||||
public void setGatewayConflictResolver(Object gatewayConflictResolver) {
|
||||
this.gatewayConflictResolver = gatewayConflictResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jndiDataSources the list of configured JndiDataSources to use with this Cache.
|
||||
*/
|
||||
@@ -704,10 +691,12 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of configured JndiDataSources.
|
||||
* Sets the state of the use-shared-configuration GemFire distribution config setting.
|
||||
*
|
||||
* @param useSharedConfiguration a boolean value to set the use-shared-configuration GemFire distribution property.
|
||||
*/
|
||||
public List<JndiDataSource> getJndiDataSources() {
|
||||
return jndiDataSources;
|
||||
public void setUseSharedConfiguration(Boolean useSharedConfiguration) {
|
||||
this.useSharedConfiguration = useSharedConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -717,6 +706,20 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
return beanClassLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanFactory
|
||||
*/
|
||||
public BeanFactory getBeanFactory() {
|
||||
return beanFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanFactoryLocator
|
||||
*/
|
||||
public GemfireBeanFactoryLocator getBeanFactoryLocator() {
|
||||
return factoryLocator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanName
|
||||
*/
|
||||
@@ -742,10 +745,53 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
return properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cache getObject() throws Exception {
|
||||
init();
|
||||
return cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Cache> getObjectType() {
|
||||
return (cache != null ? cache.getClass() : Cache.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the copyOnRead
|
||||
*/
|
||||
public Boolean getCopyOnRead() {
|
||||
return copyOnRead;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the criticalHeapPercentage
|
||||
*/
|
||||
public Float getCriticalHeapPercentage() {
|
||||
return criticalHeapPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value for the auto-reconnect setting.
|
||||
*
|
||||
* @return a boolean value indicating whether auto-reconnect was specified (non-null) and whether it was enabled
|
||||
* or not.
|
||||
*/
|
||||
public Boolean getEnableAutoReconnect() {
|
||||
return enableAutoReconnect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the evictionHeapPercentage
|
||||
*/
|
||||
public Float getEvictionHeapPercentage() {
|
||||
return evictionHeapPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pdxSerializer
|
||||
*/
|
||||
@@ -753,13 +799,6 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
return pdxSerializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pdxPersistent
|
||||
*/
|
||||
public Boolean getPdxPersistent() {
|
||||
return pdxPersistent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pdxReadSerialized
|
||||
*/
|
||||
@@ -767,6 +806,13 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
return pdxReadSerialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pdxPersistent
|
||||
*/
|
||||
public Boolean getPdxPersistent() {
|
||||
return pdxPersistent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pdxIgnoreUnreadFields
|
||||
*/
|
||||
@@ -782,10 +828,10 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the copyOnRead
|
||||
* @return the lockLease
|
||||
*/
|
||||
public Boolean getCopyOnRead() {
|
||||
return copyOnRead;
|
||||
public Integer getLockLease() {
|
||||
return lockLease;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -795,13 +841,6 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
return lockTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lockLease
|
||||
*/
|
||||
public Integer getLockLease() {
|
||||
return lockLease;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the messageSyncInterval
|
||||
*/
|
||||
@@ -830,21 +869,6 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
return transactionWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the evictionHeapPercentage
|
||||
*/
|
||||
public Float getEvictionHeapPercentage() {
|
||||
return evictionHeapPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the criticalHeapPercentage
|
||||
*/
|
||||
public Float getCriticalHeapPercentage() {
|
||||
|
||||
return criticalHeapPercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dynamicRegionSupport
|
||||
*/
|
||||
@@ -860,10 +884,19 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanFactoryLocator
|
||||
* @return the list of configured JndiDataSources.
|
||||
*/
|
||||
public GemfireBeanFactoryLocator getBeanFactoryLocator() {
|
||||
return factoryLocator;
|
||||
public List<JndiDataSource> getJndiDataSources() {
|
||||
return jndiDataSources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value fo the use-shared-configuration GemFire setting.
|
||||
*
|
||||
* @return a boolean value indicating whether shared configuration use has been enabled or not.
|
||||
*/
|
||||
public Boolean getUseSharedConfiguration() {
|
||||
return this.useSharedConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -878,6 +911,8 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
protected void postProcessPropertiesBeforeInitialization(Properties gemfireProperties) {
|
||||
gemfireProperties.setProperty("disable-auto-reconnect", String.valueOf(
|
||||
!Boolean.TRUE.equals(getEnableAutoReconnect())));
|
||||
gemfireProperties.setProperty("use-shared-configuration", String.valueOf(
|
||||
Boolean.TRUE.equals(getUseSharedConfiguration())));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -891,4 +926,5 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -89,14 +89,12 @@ public class ClientCacheFactoryBean extends CacheFactoryBean {
|
||||
ClientCacheFactory clientCacheFactory = (ClientCacheFactory) factory;
|
||||
|
||||
initializePool(clientCacheFactory);
|
||||
|
||||
// Now create the cache
|
||||
|
||||
GemFireCache cache = clientCacheFactory.create();
|
||||
|
||||
// Register for events after pool/regions been created and iff non-durable client
|
||||
|
||||
// register for events after Pool and Regions been created and iff non-durable client...
|
||||
readyForEvents();
|
||||
|
||||
// Return the cache
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
||||
@@ -110,86 +108,110 @@ public class ClientCacheFactoryBean extends CacheFactoryBean {
|
||||
return ClientCacheFactory.getAnyInstance();
|
||||
}
|
||||
|
||||
private void initializePool(ClientCacheFactory ccf) {
|
||||
Pool p = pool;
|
||||
private void initializePool(ClientCacheFactory clientCacheFactory) {
|
||||
Pool localPool = pool;
|
||||
|
||||
if (p == null) {
|
||||
if (localPool == null) {
|
||||
if (StringUtils.hasText(poolName)) {
|
||||
p = PoolManager.find(poolName);
|
||||
localPool = PoolManager.find(poolName);
|
||||
}
|
||||
|
||||
// Bind this client cache to a pool that hasn't been created yet.
|
||||
if (p == null) {
|
||||
if (localPool == null) {
|
||||
PoolFactoryBean.connectToTemporaryDs(this.properties);
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(poolName)) {
|
||||
try {
|
||||
|
||||
getBeanFactory().isTypeMatch(poolName, Pool.class);
|
||||
} catch (Exception e) {
|
||||
String msg = "No bean found with name " + poolName
|
||||
+ " of type " + Pool.class.getName();
|
||||
if (poolName
|
||||
.equals(GemfireConstants.DEFAULT_GEMFIRE_POOL_NAME)) {
|
||||
msg += ". A client cache requires a pool";
|
||||
}
|
||||
throw new BeanInitializationException(msg);
|
||||
localPool = getBeanFactory().getBean(poolName, Pool.class);
|
||||
}
|
||||
p = getBeanFactory().getBean(poolName, Pool.class);
|
||||
} else {
|
||||
catch (Exception e) {
|
||||
String message = String.format("No bean found with name '%1$s' of type '%2$s'.%3$s", poolName,
|
||||
Pool.class.getName(), (GemfireConstants.DEFAULT_GEMFIRE_POOL_NAME.equals(poolName)
|
||||
? " A client cache requires a pool." : ""));
|
||||
|
||||
throw new BeanInitializationException(message);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Checking for a unique pool");
|
||||
log.debug("Checking for a unique pool...");
|
||||
}
|
||||
p = getBeanFactory().getBean(Pool.class);
|
||||
this.poolName = p.getName();
|
||||
|
||||
localPool = getBeanFactory().getBean(Pool.class);
|
||||
this.poolName = localPool.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (p != null) {
|
||||
if (localPool != null) {
|
||||
// copy the pool settings - this way if the pool is not found, at
|
||||
// least the cache will have a similar config
|
||||
ccf.setPoolFreeConnectionTimeout(p.getFreeConnectionTimeout());
|
||||
ccf.setPoolIdleTimeout(p.getIdleTimeout());
|
||||
ccf.setPoolLoadConditioningInterval(p.getLoadConditioningInterval());
|
||||
ccf.setPoolMaxConnections(p.getMaxConnections());
|
||||
ccf.setPoolMinConnections(p.getMinConnections());
|
||||
ccf.setPoolMultiuserAuthentication(p.getMultiuserAuthentication());
|
||||
ccf.setPoolPingInterval(p.getPingInterval());
|
||||
ccf.setPoolPRSingleHopEnabled(p.getPRSingleHopEnabled());
|
||||
ccf.setPoolReadTimeout(p.getReadTimeout());
|
||||
ccf.setPoolRetryAttempts(p.getRetryAttempts());
|
||||
ccf.setPoolServerGroup(p.getServerGroup());
|
||||
ccf.setPoolSocketBufferSize(p.getSocketBufferSize());
|
||||
ccf.setPoolStatisticInterval(p.getStatisticInterval());
|
||||
ccf.setPoolSubscriptionAckInterval(p.getSubscriptionAckInterval());
|
||||
ccf.setPoolSubscriptionEnabled(p.getSubscriptionEnabled());
|
||||
ccf.setPoolSubscriptionMessageTrackingTimeout(p
|
||||
.getSubscriptionMessageTrackingTimeout());
|
||||
ccf.setPoolSubscriptionRedundancy(p.getSubscriptionRedundancy());
|
||||
ccf.setPoolThreadLocalConnections(p.getThreadLocalConnections());
|
||||
clientCacheFactory.setPoolFreeConnectionTimeout(localPool.getFreeConnectionTimeout());
|
||||
clientCacheFactory.setPoolIdleTimeout(localPool.getIdleTimeout());
|
||||
clientCacheFactory.setPoolLoadConditioningInterval(localPool.getLoadConditioningInterval());
|
||||
clientCacheFactory.setPoolMaxConnections(localPool.getMaxConnections());
|
||||
clientCacheFactory.setPoolMinConnections(localPool.getMinConnections());
|
||||
clientCacheFactory.setPoolMultiuserAuthentication(localPool.getMultiuserAuthentication());
|
||||
clientCacheFactory.setPoolPingInterval(localPool.getPingInterval());
|
||||
clientCacheFactory.setPoolPRSingleHopEnabled(localPool.getPRSingleHopEnabled());
|
||||
clientCacheFactory.setPoolReadTimeout(localPool.getReadTimeout());
|
||||
clientCacheFactory.setPoolRetryAttempts(localPool.getRetryAttempts());
|
||||
clientCacheFactory.setPoolServerGroup(localPool.getServerGroup());
|
||||
clientCacheFactory.setPoolSocketBufferSize(localPool.getSocketBufferSize());
|
||||
clientCacheFactory.setPoolStatisticInterval(localPool.getStatisticInterval());
|
||||
clientCacheFactory.setPoolSubscriptionAckInterval(localPool.getSubscriptionAckInterval());
|
||||
clientCacheFactory.setPoolSubscriptionEnabled(localPool.getSubscriptionEnabled());
|
||||
clientCacheFactory.setPoolSubscriptionMessageTrackingTimeout(localPool.getSubscriptionMessageTrackingTimeout());
|
||||
clientCacheFactory.setPoolSubscriptionRedundancy(localPool.getSubscriptionRedundancy());
|
||||
clientCacheFactory.setPoolThreadLocalConnections(localPool.getThreadLocalConnections());
|
||||
|
||||
List<InetSocketAddress> locators = localPool.getLocators();
|
||||
|
||||
List<InetSocketAddress> locators = p.getLocators();
|
||||
if (locators != null) {
|
||||
for (InetSocketAddress inet : locators) {
|
||||
ccf.addPoolLocator(inet.getHostName(), inet.getPort());
|
||||
for (InetSocketAddress socketAddress : locators) {
|
||||
clientCacheFactory.addPoolLocator(socketAddress.getHostName(), socketAddress.getPort());
|
||||
}
|
||||
}
|
||||
|
||||
List<InetSocketAddress> servers = p.getServers();
|
||||
List<InetSocketAddress> servers = localPool.getServers();
|
||||
|
||||
if (servers != null) {
|
||||
for (InetSocketAddress inet : servers) {
|
||||
ccf.addPoolServer(inet.getHostName(), inet.getPort());
|
||||
for (InetSocketAddress socketAddress : servers) {
|
||||
clientCacheFactory.addPoolServer(socketAddress.getHostName(), socketAddress.getPort());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyPdxOptions(Object factory) {
|
||||
if (factory instanceof ClientCacheFactory) {
|
||||
new PdxOptions((ClientCacheFactory) factory).run();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postProcessPropertiesBeforeInitialization(final Properties gemfireProperties) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform the GemFire cluster that this client cache is ready to receive events.
|
||||
*/
|
||||
private void readyForEvents(){
|
||||
ClientCache clientCache = ClientCacheFactory.getAnyInstance();
|
||||
|
||||
if (Boolean.TRUE.equals(readyForEvents) && !clientCache.isClosed()) {
|
||||
try {
|
||||
clientCache.readyForEvents();
|
||||
}
|
||||
catch (IllegalStateException ignore) {
|
||||
// cannot be called for a non-durable client so exception is thrown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Boolean getEnableAutoReconnect() {
|
||||
return Boolean.FALSE;
|
||||
@@ -231,31 +253,23 @@ public class ClientCacheFactoryBean extends CacheFactoryBean {
|
||||
this.readyForEvents = readyForEvents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value for the readyForEvents property.
|
||||
*
|
||||
* @return a boolean value indicating the state of the 'readyForEvents' property.
|
||||
*/
|
||||
public Boolean getReadyForEvents(){
|
||||
return this.readyForEvents;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyPdxOptions(Object factory) {
|
||||
if (factory instanceof ClientCacheFactory) {
|
||||
new PdxOptions((ClientCacheFactory) factory).run();
|
||||
}
|
||||
public final Boolean getUseSharedConfiguration() {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform the GemFire cluster that this client cache is ready to receive events.
|
||||
*/
|
||||
private void readyForEvents(){
|
||||
ClientCache clientCache = ClientCacheFactory.getAnyInstance();
|
||||
|
||||
if (Boolean.TRUE.equals(readyForEvents) && !clientCache.isClosed()) {
|
||||
try {
|
||||
clientCache.readyForEvents();
|
||||
}
|
||||
catch (IllegalStateException ignore) {
|
||||
// cannot be called for a non-durable client so exception is thrown
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public final void setUseSharedConfiguration(Boolean useSharedConfiguration) {
|
||||
throw new UnsupportedOperationException("Shared, cluster configuration is not applicable to clients.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ class CacheParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
ParsingUtils.setPropertyValue(element, builder, "cache-xml-location", "cacheXml");
|
||||
ParsingUtils.setPropertyReference(element, builder, "properties-ref", "properties");
|
||||
ParsingUtils.setPropertyValue(element, builder, "lazy-init","lazyInitialize");
|
||||
ParsingUtils.setPropertyValue(element, builder, "use-bean-factory-locator");
|
||||
ParsingUtils.setPropertyValue(element, builder, "close");
|
||||
ParsingUtils.setPropertyValue(element, builder, "copy-on-read");
|
||||
ParsingUtils.setPropertyValue(element, builder, "critical-heap-percentage");
|
||||
@@ -70,8 +72,7 @@ class CacheParser extends AbstractSimpleBeanDefinitionParser {
|
||||
ParsingUtils.setPropertyValue(element, builder, "pdx-persistent");
|
||||
parsePdxDiskStore(element, parserContext, builder);
|
||||
ParsingUtils.setPropertyValue(element, builder, "search-timeout");
|
||||
ParsingUtils.setPropertyValue(element, builder, "lazy-init","lazyInitialize");
|
||||
ParsingUtils.setPropertyValue(element, builder, "use-bean-factory-locator");
|
||||
ParsingUtils.setPropertyValue(element, builder, "use-shared-configuration");
|
||||
|
||||
List<Element> txListeners = DomUtils.getChildElementsByTagName(element, "transaction-listener");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user