protected GemFireCache fetchCache() {
return ClientCacheFactory.getAnyInstance();
}
private void initializePool(ClientCacheFactory clientCacheFactory) {
Pool localPool = pool;
if (localPool == null) {
if (StringUtils.hasText(poolName)) {
localPool = PoolManager.find(poolName);
}
// Bind this client cache to a pool that hasn't been created yet.
if (localPool == null) {
PoolFactoryBean.connectToTemporaryDs(this.properties);
}
if (StringUtils.hasText(poolName)) {
try {
getBeanFactory().isTypeMatch(poolName, Pool.class);
localPool = getBeanFactory().getBean(poolName, Pool.class);
}
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...");
}
localPool = getBeanFactory().getBean(Pool.class);
this.poolName = localPool.getName();
}
}
if (localPool != null) {
// copy the pool settings - this way if the pool is not found, at
// least the cache will have a similar config
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();
if (locators != null) {
for (InetSocketAddress socketAddress : locators) {
clientCacheFactory.addPoolLocator(socketAddress.getHostName(), socketAddress.getPort());
}
}
List<InetSocketAddress> servers = localPool.getServers();
if (servers != null) {
for (InetSocketAddress socketAddress : servers) {
clientCacheFactory.addPoolServer(socketAddress.getHostName(), socketAddress.getPort());
}