DATAGEODE-335 - Add @ClientCacheApplication and @EnablePool annotation attribute and property support for socketConnectTimeout.
This commit is contained in:
@@ -162,6 +162,11 @@ public class AddPoolConfiguration extends AbstractAnnotationConfigSupport
|
||||
resolveProperty(poolProperty("socket-buffer-size"),
|
||||
(Integer) enablePoolAttributes.get("socketBufferSize"))));
|
||||
|
||||
poolFactoryBean.addPropertyValue("socketConnectTimeout",
|
||||
resolveProperty(namedPoolProperty(poolName, "socket-connect-timeout"),
|
||||
resolveProperty(poolProperty("socket-connect-timeout"),
|
||||
(Integer) enablePoolAttributes.get("socketConnectTimeout"))));
|
||||
|
||||
poolFactoryBean.addPropertyValue("statisticInterval",
|
||||
resolveProperty(namedPoolProperty(poolName, "statistic-interval"),
|
||||
resolveProperty(poolProperty("statistic-interval"),
|
||||
|
||||
@@ -24,6 +24,8 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
import org.apache.geode.cache.client.PoolFactory;
|
||||
import org.apache.geode.cache.control.ResourceManager;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -33,10 +35,11 @@ import org.springframework.data.gemfire.GemfireUtils;
|
||||
import org.springframework.data.gemfire.support.GemfireBeanFactoryLocator;
|
||||
|
||||
/**
|
||||
* The {@link ClientCacheApplication} annotation enables a SDG based application to become a
|
||||
* Pivotal GemFire cache client (i.e. {@link org.apache.geode.cache.client.ClientCache}).
|
||||
* The {@link ClientCacheApplication} annotation enables a Spring Data GemFire/Geode based application to become
|
||||
* a GemFire/Geode cache client (i.e. {@link ClientCache}).
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.client.PoolFactory
|
||||
* @see org.apache.geode.cache.control.ResourceManager
|
||||
* @see org.springframework.context.annotation.Configuration
|
||||
@@ -302,6 +305,20 @@ public @interface ClientCacheApplication {
|
||||
*/
|
||||
int socketBufferSize() default PoolFactory.DEFAULT_SOCKET_BUFFER_SIZE;
|
||||
|
||||
/**
|
||||
* Configures the {@link Integer socket connect timeout} for the {@literal DEFAULT} {@link Pool}.
|
||||
*
|
||||
* The number of milliseconds specified as socket timeout when the client connects to the servers/locators.
|
||||
* A timeout of zero is interpreted as an infinite timeout. The connection will then block until established
|
||||
* or an error occurs.
|
||||
*
|
||||
* Defaults to {@link PoolFactory#DEFAULT_SOCKET_CONNECT_TIMEOUT}.
|
||||
*
|
||||
* Use either the {@literal spring.data.gemfire.pool.default.socket-connect-timeout} property
|
||||
* or the {@literal spring.data.gemfire.pool.socket-connect-timeout} property in {@literal application.properties}.
|
||||
*/
|
||||
int socketConnectTimeout() default PoolFactory.DEFAULT_SOCKET_CONNECT_TIMEOUT;
|
||||
|
||||
/**
|
||||
* Configures how often to send client statistics to the server.
|
||||
*
|
||||
|
||||
@@ -90,6 +90,7 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
private Integer readTimeout;
|
||||
private Integer retryAttempts;
|
||||
private Integer socketBufferSize;
|
||||
private Integer socketConnectTimeout;
|
||||
private Integer statisticsInterval;
|
||||
private Integer subscriptionAckInterval;
|
||||
private Integer subscriptionMessageTrackingTimeout;
|
||||
@@ -140,6 +141,7 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
gemfireCache.setServerGroup(getServerGroup());
|
||||
gemfireCache.setServers(getPoolServers());
|
||||
gemfireCache.setSocketBufferSize(getSocketBufferSize());
|
||||
gemfireCache.setSocketConnectTimeout(getSocketConnectTimeout());
|
||||
gemfireCache.setStatisticsInterval(getStatisticsInterval());
|
||||
gemfireCache.setSubscriptionAckInterval(getSubscriptionAckInterval());
|
||||
gemfireCache.setSubscriptionEnabled(getSubscriptionEnabled());
|
||||
@@ -201,7 +203,8 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
*/
|
||||
|
||||
register(BeanDefinitionBuilder.rootBeanDefinition(ClientRegionPoolBeanFactoryPostProcessor.class)
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE).getBeanDefinition());
|
||||
.setRole(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
.getBeanDefinition());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,6 +299,11 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
resolveProperty(poolProperty("socket-buffer-size"),
|
||||
(Integer) clientCacheApplicationAttributes.get("socketBufferSize"))));
|
||||
|
||||
setSocketConnectTimeout(
|
||||
resolveProperty(namedPoolProperty("default", "socket-connect-timeout"),
|
||||
resolveProperty(poolProperty("socket-connect-timeout"),
|
||||
(Integer) clientCacheApplicationAttributes.get("socketConnectTimeout"))));
|
||||
|
||||
setStatisticsInterval(
|
||||
resolveProperty(namedPoolProperty("default", "statistic-interval"),
|
||||
resolveProperty(poolProperty("statistic-interval"),
|
||||
@@ -546,6 +554,14 @@ public class ClientCacheConfiguration extends AbstractCacheConfiguration {
|
||||
return this.socketBufferSize;
|
||||
}
|
||||
|
||||
void setSocketConnectTimeout(Integer socketConnectTimeout) {
|
||||
this.socketConnectTimeout = socketConnectTimeout;
|
||||
}
|
||||
|
||||
protected Integer getSocketConnectTimeout() {
|
||||
return this.socketConnectTimeout;
|
||||
}
|
||||
|
||||
void setStatisticsInterval(Integer statisticsInterval) {
|
||||
this.statisticsInterval = statisticsInterval;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
@@ -242,6 +241,20 @@ public @interface EnablePool {
|
||||
*/
|
||||
int socketBufferSize() default PoolFactory.DEFAULT_SOCKET_BUFFER_SIZE;
|
||||
|
||||
/**
|
||||
* Configures the {@link Integer socket connect timeout} for this "named" {@link Pool}.
|
||||
*
|
||||
* The number of milliseconds specified as socket timeout when the client connects to the servers/locators.
|
||||
* A timeout of zero is interpreted as an infinite timeout. The connection will then block until established
|
||||
* or an error occurs.
|
||||
*
|
||||
* Defaults to {@link PoolFactory#DEFAULT_SOCKET_CONNECT_TIMEOUT}.
|
||||
*
|
||||
* Use either the {@literal spring.data.gemfire.pool.<poolName>.socket-connect-timeout} property
|
||||
* or the {@literal spring.data.gemfire.pool.socket-connect-timeout} property in {@literal application.properties}.
|
||||
*/
|
||||
int socketConnectTimeout() default PoolFactory.DEFAULT_SOCKET_CONNECT_TIMEOUT;
|
||||
|
||||
/**
|
||||
* Configures how often to send client statistics to the server.
|
||||
*
|
||||
|
||||
@@ -13,33 +13,36 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.annotation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.CacheLoader;
|
||||
import org.apache.geode.cache.CacheLoaderException;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.LoaderHelper;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ClientCacheApplication}.
|
||||
* Integration Tests for {@link ClientCacheApplication}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see org.springframework.data.gemfire.client.ClientRegionFactoryBean
|
||||
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
@@ -47,7 +50,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
@SuppressWarnings("all")
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientCacheApplicationIntegrationTests {
|
||||
|
||||
@Resource(name = "Echo")
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.data.gemfire.test.mock.annotation.EnableGemFireMockOb
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ClientCacheConfigurer}.
|
||||
* Integration Tests for {@link ClientCacheConfigurer}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
|
||||
@@ -92,8 +92,8 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
.withProperty("spring.data.gemfire.pool.max-connections", 250)
|
||||
.withProperty("spring.data.gemfire.pool.ping-interval", 5000L)
|
||||
.withProperty("spring.data.gemfire.pool.pr-single-hop-enabled", false)
|
||||
.withProperty("spring.data.gemfire.pool.default.read-timeout", 5000L)
|
||||
.withProperty("spring.data.gemfire.pool.read-timeout", 20000L)
|
||||
.withProperty("spring.data.gemfire.pool.default.read-timeout", 5000L)
|
||||
.withProperty("spring.data.gemfire.pool.retry-attempts", 2)
|
||||
.withProperty("spring.data.gemfire.pool.server-group", "testGroup")
|
||||
.withProperty("spring.data.gemfire.pool.default.subscription-redundancy", 2);
|
||||
@@ -141,6 +141,7 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
assertThat(defaultPool.getRetryAttempts()).isEqualTo(2);
|
||||
assertThat(defaultPool.getServerGroup()).isEqualTo("testGroup");
|
||||
assertThat(defaultPool.getSocketBufferSize()).isEqualTo(PoolFactory.DEFAULT_SOCKET_BUFFER_SIZE);
|
||||
assertThat(defaultPool.getSocketConnectTimeout()).isEqualTo(20001);
|
||||
assertThat(defaultPool.getStatisticInterval()).isEqualTo(500);
|
||||
assertThat(defaultPool.getSubscriptionAckInterval()).isEqualTo(PoolFactory.DEFAULT_SUBSCRIPTION_ACK_INTERVAL);
|
||||
assertThat(defaultPool.getSubscriptionEnabled()).isTrue();
|
||||
@@ -182,6 +183,7 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
.withProperty("spring.data.gemfire.pool.default.retry-attempts", 2)
|
||||
.withProperty("spring.data.gemfire.pool.default.server-group", "testGroup")
|
||||
.withProperty("spring.data.gemfire.pool.default.socket-buffer-size", 65535)
|
||||
.withProperty("spring.data.gemfire.pool.default.socket-connect-timeout", 30001)
|
||||
.withProperty("spring.data.gemfire.pool.default.statistic-interval", 100)
|
||||
.withProperty("spring.data.gemfire.pool.default.subscription-ack-interval", 250)
|
||||
.withProperty("spring.data.gemfire.pool.default.subscription-enabled", true)
|
||||
@@ -248,6 +250,7 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
assertThat(defaultPool.getRetryAttempts()).isEqualTo(2);
|
||||
assertThat(defaultPool.getServerGroup()).isEqualTo("testGroup");
|
||||
assertThat(defaultPool.getSocketBufferSize()).isEqualTo(65535);
|
||||
assertThat(defaultPool.getSocketConnectTimeout()).isEqualTo(30001);
|
||||
assertThat(defaultPool.getStatisticInterval()).isEqualTo(100);
|
||||
assertThat(defaultPool.getSubscriptionAckInterval()).isEqualTo(250);
|
||||
assertThat(defaultPool.getSubscriptionEnabled()).isTrue();
|
||||
@@ -268,7 +271,7 @@ public class ClientCachePropertiesIntegrationTests {
|
||||
@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)
|
||||
socketConnectTimeout = 20001, subscriptionEnabled = true, subscriptionRedundancy = 1)
|
||||
@EnablePdx(ignoreUnreadFields = true, readSerialized = true, serializerBeanName = "mockPdxSerializer")
|
||||
@SuppressWarnings("unused")
|
||||
static class TestClientCacheConfiguration {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.annotation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -34,11 +33,12 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link PoolConfigurer}.
|
||||
* Integration Tests for {@link PoolConfigurer}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see org.springframework.context.annotation.Configuration
|
||||
* @see org.springframework.data.gemfire.client.PoolFactoryBean
|
||||
* @see org.springframework.data.gemfire.config.annotation.AddPoolConfiguration
|
||||
@@ -48,7 +48,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
* @see org.springframework.data.gemfire.config.annotation.EnablePools
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringRunner
|
||||
* @since 1.1.0
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@ContextConfiguration
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.annotation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -21,11 +20,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
import org.apache.geode.cache.client.PoolFactory;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -35,12 +36,20 @@ import org.springframework.data.gemfire.test.mock.annotation.EnableGemFireMockOb
|
||||
import org.springframework.mock.env.MockPropertySource;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link EnablePool} and {@link EnablePools}.
|
||||
* Integration Tests for {@link EnablePool} and {@link EnablePools}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see org.apache.geode.cache.client.PoolFactory
|
||||
* @see org.springframework.context.ConfigurableApplicationContext
|
||||
* @see org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see org.springframework.core.env.PropertySource
|
||||
* @see org.springframework.data.gemfire.config.annotation.EnablePool
|
||||
* @see org.springframework.data.gemfire.config.annotation.EnablePools
|
||||
* @see org.springframework.data.gemfire.test.mock.annotation.EnableGemFireMockObjects
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class PoolPropertiesIntegrationTests {
|
||||
@@ -71,7 +80,7 @@ public class PoolPropertiesIntegrationTests {
|
||||
private void assertPool(Pool pool, int freeConnectionTimeout, long idleTimeout, int loadConditioningInterval,
|
||||
int maxConnections, int minConnections, boolean multiUserAuthentication, String name, long pingInterval,
|
||||
boolean prSinglehopEnabled, int readTimeout, int retryAttempts, String serverGroup, int socketBufferSize,
|
||||
int statisticInterval, int subscriptionAckInterval, boolean subscriptionEnabled,
|
||||
int socketConnectTimeout, int statisticInterval, int subscriptionAckInterval, boolean subscriptionEnabled,
|
||||
int subscriptionMessageTrackingTimeout, int subscriptionRedundancy, boolean threadLocalConnections) {
|
||||
|
||||
assertThat(pool).isNotNull();
|
||||
@@ -88,6 +97,7 @@ public class PoolPropertiesIntegrationTests {
|
||||
assertThat(pool.getRetryAttempts()).isEqualTo(retryAttempts);
|
||||
assertThat(pool.getServerGroup()).isEqualTo(serverGroup);
|
||||
assertThat(pool.getSocketBufferSize()).isEqualTo(socketBufferSize);
|
||||
assertThat(pool.getSocketConnectTimeout()).isEqualTo(socketConnectTimeout);
|
||||
assertThat(pool.getStatisticInterval()).isEqualTo(statisticInterval);
|
||||
assertThat(pool.getSubscriptionAckInterval()).isEqualTo(subscriptionAckInterval);
|
||||
assertThat(pool.getSubscriptionEnabled()).isEqualTo(subscriptionEnabled);
|
||||
@@ -106,10 +116,11 @@ public class PoolPropertiesIntegrationTests {
|
||||
.withProperty("spring.data.gemfire.pool.min-connections", 25)
|
||||
.withProperty("spring.data.gemfire.pool.ping-interval", 5000L)
|
||||
.withProperty("spring.data.gemfire.pool.pr-single-hop-enabled", false)
|
||||
.withProperty("spring.data.gemfire.pool.default.read-timeout", 5000L)
|
||||
.withProperty("spring.data.gemfire.pool.read-timeout", 15000)
|
||||
.withProperty("spring.data.gemfire.pool.default.read-timeout", 5000L)
|
||||
.withProperty("spring.data.gemfire.pool.retry-attempts", 2)
|
||||
.withProperty("spring.data.gemfire.pool.server-group", "testGroup")
|
||||
.withProperty("spring.data.gemfire.pool.default.socket-connect-timeout", 5000)
|
||||
.withProperty("spring.data.gemfire.pool.subscription-enabled", true)
|
||||
.withProperty("spring.data.gemfire.pool.TestPool.subscription-redundancy", 2);
|
||||
|
||||
@@ -135,6 +146,7 @@ public class PoolPropertiesIntegrationTests {
|
||||
assertThat(testPool.getReadTimeout()).isEqualTo(15000);
|
||||
assertThat(testPool.getRetryAttempts()).isEqualTo(1);
|
||||
assertThat(testPool.getServerGroup()).isEqualTo("testGroup");
|
||||
assertThat(testPool.getSocketConnectTimeout()).isEqualTo(PoolFactory.DEFAULT_SOCKET_CONNECT_TIMEOUT);
|
||||
assertThat(testPool.getSubscriptionAckInterval()).isEqualTo(PoolFactory.DEFAULT_SUBSCRIPTION_ACK_INTERVAL);
|
||||
assertThat(testPool.getSubscriptionEnabled()).isEqualTo(true);
|
||||
assertThat(testPool.getSubscriptionMessageTrackingTimeout()).isEqualTo(PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT);
|
||||
@@ -159,6 +171,7 @@ public class PoolPropertiesIntegrationTests {
|
||||
.withProperty("spring.data.gemfire.pool.retry-attempts", 2)
|
||||
.withProperty("spring.data.gemfire.pool.server-group", "testGroup")
|
||||
.withProperty("spring.data.gemfire.pool.socket-buffer-size", 8192)
|
||||
.withProperty("spring.data.gemfire.pool.socket-connect-timeout", 5000)
|
||||
.withProperty("spring.data.gemfire.pool.statistic-interval", 1000)
|
||||
.withProperty("spring.data.gemfire.pool.subscription-ack-interval", 5000)
|
||||
.withProperty("spring.data.gemfire.pool.subscription-enabled", true)
|
||||
@@ -178,6 +191,7 @@ public class PoolPropertiesIntegrationTests {
|
||||
.withProperty("spring.data.gemfire.pool.default.retry-attempts", 1)
|
||||
.withProperty("spring.data.gemfire.pool.default.server-group", "testDefaultGroup")
|
||||
.withProperty("spring.data.gemfire.pool.default.socket-buffer-size", 16384)
|
||||
.withProperty("spring.data.gemfire.pool.default.socket-connect-timeout", 10000)
|
||||
.withProperty("spring.data.gemfire.pool.default.statistic-interval", 500)
|
||||
.withProperty("spring.data.gemfire.pool.default.subscription-ack-interval", 250)
|
||||
.withProperty("spring.data.gemfire.pool.default.subscription-enabled", true)
|
||||
@@ -197,6 +211,7 @@ public class PoolPropertiesIntegrationTests {
|
||||
.withProperty("spring.data.gemfire.pool.TestPoolTwo.retry-attempts", 4)
|
||||
.withProperty("spring.data.gemfire.pool.TestPoolTwo.server-group", "testTwoGroup")
|
||||
.withProperty("spring.data.gemfire.pool.TestPoolTwo.socket-buffer-size", 65536)
|
||||
.withProperty("spring.data.gemfire.pool.TestPoolTwo.socket-connect-timeout", 15000)
|
||||
.withProperty("spring.data.gemfire.pool.TestPoolTwo.statistic-interval", 2000)
|
||||
.withProperty("spring.data.gemfire.pool.TestPoolTwo.subscription-ack-interval", 500)
|
||||
.withProperty("spring.data.gemfire.pool.TestPoolTwo.subscription-enabled", true)
|
||||
@@ -220,29 +235,33 @@ public class PoolPropertiesIntegrationTests {
|
||||
assertPool(defaultPool, 15000, 20000L, 180000,
|
||||
275, 27, true, "DEFAULT", 15000L,
|
||||
false, 2000, 1, "testDefaultGroup",
|
||||
16384, 500, 250, true,
|
||||
300000, 3, true);
|
||||
16384, 10000, 500, 250,
|
||||
true, 300000, 3,
|
||||
true);
|
||||
|
||||
Pool testPoolOne = this.applicationContext.getBean("TestPoolOne", Pool.class);
|
||||
|
||||
assertPool(testPoolOne, 5000, 10000L, 120000,
|
||||
500, 50, true, "TestPoolOne", 5000L,
|
||||
false, 15000, 2, "testGroup",
|
||||
8192, 1000, 5000, true,
|
||||
180000, 2, true);
|
||||
8192, 5000,1000, 5000,
|
||||
true, 180000, 2,
|
||||
true);
|
||||
|
||||
Pool testPoolTwo = this.applicationContext.getBean("TestPoolTwo", Pool.class);
|
||||
|
||||
assertPool(testPoolTwo, 20000, 15000L, 60000,
|
||||
1000, 100, true, "TestPoolTwo", 20000L,
|
||||
false, 5000, 4, "testTwoGroup",
|
||||
65536, 2000, 500, true,
|
||||
300000, 4, true);
|
||||
65536, 15000,2000, 500,
|
||||
true, 300000, 4,
|
||||
true);
|
||||
}
|
||||
|
||||
@EnableGemFireMockObjects
|
||||
@ClientCacheApplication
|
||||
@EnablePool(name = "TestPool", idleTimeout = 10000L, maxConnections = 200, minConnections = 20)
|
||||
@SuppressWarnings("unused")
|
||||
static class TestPoolConfiguration {
|
||||
|
||||
@Bean
|
||||
@@ -256,7 +275,10 @@ public class PoolPropertiesIntegrationTests {
|
||||
|
||||
@EnableGemFireMockObjects
|
||||
@ClientCacheApplication
|
||||
@EnablePools(pools = { @EnablePool(name = "TestPoolOne"), @EnablePool(name = "TestPoolTwo") })
|
||||
static class TestPoolsConfiguration {
|
||||
}
|
||||
@EnablePools(pools = {
|
||||
@EnablePool(name = "TestPoolOne"),
|
||||
@EnablePool(name = "TestPoolTwo")
|
||||
})
|
||||
static class TestPoolsConfiguration { }
|
||||
|
||||
}
|
||||
|
||||
@@ -125,7 +125,6 @@ import org.apache.geode.cache.wan.GatewayTransportFilter;
|
||||
import org.apache.geode.compression.Compressor;
|
||||
import org.apache.geode.distributed.DistributedMember;
|
||||
import org.apache.geode.distributed.DistributedSystem;
|
||||
import org.apache.geode.internal.concurrent.ConcurrentHashSet;
|
||||
import org.apache.geode.pdx.PdxSerializer;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
@@ -1424,6 +1423,7 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
AtomicInteger readTimeout = new AtomicInteger(PoolFactory.DEFAULT_READ_TIMEOUT);
|
||||
AtomicInteger retryAttempts = new AtomicInteger(PoolFactory.DEFAULT_RETRY_ATTEMPTS);
|
||||
AtomicInteger socketBufferSize = new AtomicInteger(PoolFactory.DEFAULT_SOCKET_BUFFER_SIZE);
|
||||
AtomicInteger socketConnectTimeout = new AtomicInteger(PoolFactory.DEFAULT_SOCKET_CONNECT_TIMEOUT);
|
||||
AtomicInteger statisticInterval = new AtomicInteger(PoolFactory.DEFAULT_STATISTIC_INTERVAL);
|
||||
AtomicInteger subscriptionAckInterval = new AtomicInteger(PoolFactory.DEFAULT_SUBSCRIPTION_ACK_INTERVAL);
|
||||
AtomicInteger subscriptionMessageTrackingTimeout = new AtomicInteger(PoolFactory.DEFAULT_SUBSCRIPTION_MESSAGE_TRACKING_TIMEOUT);
|
||||
@@ -1483,6 +1483,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
when(mockPoolFactory.setSocketBufferSize(anyInt()))
|
||||
.thenAnswer(newSetter(socketBufferSize, mockPoolFactory));
|
||||
|
||||
when(mockPoolFactory.setSocketConnectTimeout(anyInt()))
|
||||
.thenAnswer(newSetter(socketConnectTimeout, mockPoolFactory));
|
||||
|
||||
when(mockPoolFactory.setStatisticInterval(anyInt()))
|
||||
.thenAnswer(newSetter(statisticInterval, mockPoolFactory));
|
||||
|
||||
@@ -1535,6 +1538,7 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
when(mockPool.getServerGroup()).thenReturn(serverGroup.get());
|
||||
when(mockPool.getServers()).thenReturn(servers);
|
||||
when(mockPool.getSocketBufferSize()).thenReturn(socketBufferSize.get());
|
||||
when(mockPool.getSocketConnectTimeout()).thenReturn(socketConnectTimeout.get());
|
||||
when(mockPool.getStatisticInterval()).thenReturn(statisticInterval.get());
|
||||
when(mockPool.getSubscriptionAckInterval()).thenReturn(subscriptionAckInterval.get());
|
||||
when(mockPool.getSubscriptionEnabled()).thenReturn(subscriptionEnabled.get());
|
||||
@@ -1575,8 +1579,8 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
|
||||
QueryService mockQueryService = mock(QueryService.class);
|
||||
|
||||
Set<CqQuery> cqQueries = new ConcurrentHashSet<>();
|
||||
Set<Index> indexes = new ConcurrentHashSet<>();
|
||||
Set<CqQuery> cqQueries = Collections.synchronizedSet(new HashSet<>());
|
||||
Set<Index> indexes = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
try {
|
||||
when(mockQueryService.getCqs()).thenAnswer(invocation -> cqQueries.toArray(new CqQuery[cqQueries.size()]));
|
||||
@@ -2734,6 +2738,11 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
return clientCacheFactorySpy;
|
||||
}).when(clientCacheFactorySpy).setPoolSocketBufferSize(anyInt());
|
||||
|
||||
doAnswer(invocation -> {
|
||||
mockPoolFactory.setSocketConnectTimeout(invocation.getArgument(0));
|
||||
return clientCacheFactorySpy;
|
||||
}).when(clientCacheFactorySpy).setPoolSocketConnectTimeout(anyInt());
|
||||
|
||||
doAnswer(invocation -> {
|
||||
mockPoolFactory.setStatisticInterval(invocation.getArgument(0));
|
||||
return clientCacheFactorySpy;
|
||||
|
||||
Reference in New Issue
Block a user