SGF-434 - Add a durable GemFire client cache test to assert proper behavior by SDG.
Removed the ClientCacheFactoryBean.readyForEvents() method and moved the logic to onApplicationEvent(..). Updated the spring-gemfire 1.6 and 1.7 XSD with the new keep-alive attribue on the client-cache element. Changed the generic signature of the CacheFactoryBean class back to com.gemstone.gemfire.cache.Cache due to the Spring container bean resolution Exception when using JavaConfig in SDG 1.7 with GemFire 8.1 and core Spring Framework 4.1.7.
This commit is contained in:
@@ -76,9 +76,15 @@ import com.gemstone.gemfire.pdx.PdxSerializer;
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @see org.springframework.beans.factory.DisposableBean
|
||||
* @see org.springframework.dao.support.PersistenceExceptionTranslator
|
||||
* @see com.gemstone.gemfire.cache.Cache
|
||||
* @see com.gemstone.gemfire.cache.CacheFactory
|
||||
* @see com.gemstone.gemfire.cache.DynamicRegionFactory
|
||||
* @see com.gemstone.gemfire.cache.GemFireCache
|
||||
* @see com.gemstone.gemfire.distributed.DistributedMember
|
||||
* @see com.gemstone.gemfire.distributed.DistributedSystem
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, FactoryBean<GemFireCache>,
|
||||
public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, FactoryBean<Cache>,
|
||||
InitializingBean, DisposableBean, PersistenceExceptionTranslator {
|
||||
|
||||
protected boolean close = true;
|
||||
@@ -96,7 +102,7 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware,
|
||||
protected Boolean pdxReadSerialized;
|
||||
protected Boolean useClusterConfiguration;
|
||||
|
||||
protected GemFireCache cache;
|
||||
protected Cache cache;
|
||||
|
||||
protected ClassLoader beanClassLoader;
|
||||
|
||||
@@ -226,7 +232,7 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware,
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private GemFireCache init() throws Exception {
|
||||
private Cache init() throws Exception {
|
||||
initBeanFactoryLocator();
|
||||
|
||||
final ClassLoader currentThreadContextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
@@ -396,6 +402,7 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware,
|
||||
* Post processes the GemFire Cache instance by loading any cache.xml, applying settings specified in SDG XML
|
||||
* configuration meta-data, and registering the appropriate Transaction Listeners, Writer and JNDI settings.
|
||||
*
|
||||
* @param <T> parameterized Class type extension of GemFireCache.
|
||||
* @param cache the GemFire Cache instance to process.
|
||||
* @return the GemFire Cache instance after processing.
|
||||
* @throws IOException if the cache.xml Resource could not be loaded and applied to the Cache instance.
|
||||
@@ -785,35 +792,44 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware,
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanClassLoader
|
||||
* Gets a reference to the JRE ClassLoader used to load and create bean classes in the Spring container.
|
||||
*
|
||||
* @return the JRE ClassLoader used to load and created beans in the Spring container.
|
||||
* @see java.lang.ClassLoader
|
||||
*/
|
||||
public ClassLoader getBeanClassLoader() {
|
||||
return beanClassLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanFactory
|
||||
* Gets a reference to the Spring BeanFactory that created this GemFire Cache FactoryBean.
|
||||
*
|
||||
* @return a reference to the Spring BeanFactory.
|
||||
* @see org.springframework.beans.factory.BeanFactory
|
||||
*/
|
||||
public BeanFactory getBeanFactory() {
|
||||
return beanFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanFactoryLocator
|
||||
*/
|
||||
/* (non-Javadoc) */
|
||||
public GemfireBeanFactoryLocator getBeanFactoryLocator() {
|
||||
return beanFactoryLocator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanName
|
||||
* Gets the Spring bean name for the GemFire Cache.
|
||||
*
|
||||
* @return a String value indicating the Spring container bean name for the GemFire Cache object/component.
|
||||
*/
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cacheXml
|
||||
* Gets a reference to the GemFire native cache.xml file as a Spring Resource.
|
||||
*
|
||||
* @return the a reference to the GemFire native cache.xml as a Spring Resource.
|
||||
* @see org.springframework.core.io.Resource
|
||||
*/
|
||||
public Resource getCacheXml() {
|
||||
return cacheXml;
|
||||
@@ -841,14 +857,17 @@ public class CacheFactoryBean implements BeanClassLoaderAware, BeanFactoryAware,
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the properties
|
||||
* Gets a reference to the GemFire System Properties.
|
||||
*
|
||||
* @return a reference to the GemFire System Properties.
|
||||
* @see java.util.Properties
|
||||
*/
|
||||
public Properties getProperties() {
|
||||
return (properties != null ? properties : (properties = new Properties()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GemFireCache getObject() throws Exception {
|
||||
public Cache getObject() throws Exception {
|
||||
return init();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.data.gemfire.config.GemfireConstants;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.CacheClosedException;
|
||||
import com.gemstone.gemfire.cache.GemFireCache;
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
import com.gemstone.gemfire.cache.client.ClientCacheFactory;
|
||||
@@ -219,32 +220,25 @@ public class ClientCacheFactoryBean extends CacheFactoryBean implements Applicat
|
||||
}
|
||||
|
||||
/**
|
||||
* Register for events after Pool and Regions have been created and iff non-durable client...
|
||||
* Inform the GemFire cluster that this client cache is ready to receive events iff the client is non-durable.
|
||||
*
|
||||
* @param event the ApplicationContextEvent fired when the ApplicationContext is refreshed.
|
||||
* @see org.springframework.context.Lifecycle#start()
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache
|
||||
* @see #readyForEvents(com.gemstone.gemfire.cache.GemFireCache)
|
||||
* @see com.gemstone.gemfire.cache.client.ClientCache#readyForEvents()
|
||||
* @see #getReadyForEvents()
|
||||
* @see #getObject()
|
||||
*/
|
||||
@Override
|
||||
public void onApplicationEvent(final ContextRefreshedEvent event) {
|
||||
readyForEvents(this.cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform the GemFire cluster that this client cache is ready to receive events.
|
||||
*/
|
||||
private <T extends GemFireCache> T readyForEvents(T clientCache) {
|
||||
if (Boolean.TRUE.equals(getReadyForEvents()) && !clientCache.isClosed()) {
|
||||
if (isReadyForEvents()) {
|
||||
try {
|
||||
((ClientCache) clientCache).readyForEvents();
|
||||
((ClientCache) fetchCache()).readyForEvents();
|
||||
}
|
||||
catch (IllegalStateException ignore) {
|
||||
// cannot be called for a non-durable client so exception is thrown
|
||||
// thrown if clientCache.readyForEvents() is called on a non-durable client
|
||||
}
|
||||
catch (CacheClosedException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
return clientCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -336,6 +330,11 @@ public class ClientCacheFactoryBean extends CacheFactoryBean implements Applicat
|
||||
return readyForEvents;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public boolean isReadyForEvents() {
|
||||
return Boolean.TRUE.equals(getReadyForEvents());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setUseClusterConfiguration(Boolean useClusterConfiguration) {
|
||||
throw new UnsupportedOperationException("Shared, cluster configuration is not applicable to clients.");
|
||||
|
||||
Reference in New Issue
Block a user