SGF-438 - Make <gfe:client-cache>, 'ready-for-events' true the default for durable clients.
This commit is contained in:
@@ -23,7 +23,10 @@ import org.springframework.util.ClassUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.CacheFactory;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
import com.gemstone.gemfire.cache.client.ClientCacheFactory;
|
||||
import com.gemstone.gemfire.distributed.DistributedSystem;
|
||||
import com.gemstone.gemfire.management.internal.cli.util.spring.StringUtils;
|
||||
|
||||
/**
|
||||
* GemfireUtils is an abstract utility class encapsulating common functionality to access features and capabilities
|
||||
@@ -38,6 +41,16 @@ public abstract class GemfireUtils extends DistributedSystemUtils {
|
||||
|
||||
public final static String GEMFIRE_VERSION = CacheFactory.getVersion();
|
||||
|
||||
public static boolean isDurable(ClientCache clientCache) {
|
||||
DistributedSystem distributedSystem = clientCache.getDistributedSystem();
|
||||
|
||||
// NOTE technically the following code snippet would be more useful/valuable but is not "testable"!
|
||||
//((InternalDistributedSystem) distributedSystem).getConfig().getDurableClientId();
|
||||
|
||||
return (isConnected(distributedSystem) && StringUtils.hasText(distributedSystem.getProperties()
|
||||
.getProperty(DURABLE_CLIENT_ID_PROPERTY_NAME, null)));
|
||||
}
|
||||
|
||||
public static boolean closeCache() {
|
||||
try {
|
||||
CacheFactory.getAnyInstance().close();
|
||||
|
||||
@@ -57,7 +57,7 @@ import com.gemstone.gemfire.pdx.PdxSerializer;
|
||||
public class ClientCacheFactoryBean extends CacheFactoryBean implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
protected Boolean keepAlive = false;
|
||||
protected Boolean readyForEvents = false;
|
||||
protected Boolean readyForEvents;
|
||||
|
||||
protected Integer durableClientTimeout;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class ClientCacheFactoryBean extends CacheFactoryBean implements Applicat
|
||||
gemfireProperties = distributedSystemProperties;
|
||||
}
|
||||
|
||||
DistributedSystemUtils.configureDurableClient(gemfireProperties, durableClientId, durableClientTimeout);
|
||||
GemfireUtils.configureDurableClient(gemfireProperties, durableClientId, durableClientTimeout);
|
||||
|
||||
return gemfireProperties;
|
||||
}
|
||||
@@ -389,7 +389,14 @@ public class ClientCacheFactoryBean extends CacheFactoryBean implements Applicat
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public boolean isReadyForEvents() {
|
||||
return Boolean.TRUE.equals(getReadyForEvents());
|
||||
Boolean readyForEvents = getReadyForEvents();
|
||||
|
||||
if (readyForEvents != null) {
|
||||
return Boolean.TRUE.equals(readyForEvents);
|
||||
}
|
||||
else {
|
||||
return GemfireUtils.isDurable((ClientCache) fetchCache());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Properties;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
import com.gemstone.gemfire.cache.server.CacheServer;
|
||||
import com.gemstone.gemfire.distributed.DistributedSystem;
|
||||
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
|
||||
@@ -57,11 +58,6 @@ public abstract class DistributedSystemUtils {
|
||||
return gemfireProperties;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends DistributedSystem> T getDistributedSystem() {
|
||||
return (T) InternalDistributedSystem.getAnyInstance();
|
||||
}
|
||||
|
||||
public static boolean isConnected(DistributedSystem distributedSystem) {
|
||||
return (distributedSystem != null && distributedSystem.isConnected());
|
||||
}
|
||||
@@ -70,4 +66,9 @@ public abstract class DistributedSystemUtils {
|
||||
return !isConnected(distributedSystem);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends DistributedSystem> T getDistributedSystem() {
|
||||
return (T) InternalDistributedSystem.getAnyInstance();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user