use of com.hazelcast.client.config.ConnectionRetryConfig in project hazelcast by hazelcast.
the class TestClientApplicationContext method testConnectionRetry.
@Test
public void testConnectionRetry() {
ConnectionRetryConfig connectionRetryConfig = connectionRetryClient.getClientConfig().getConnectionStrategyConfig().getConnectionRetryConfig();
assertEquals(5000, connectionRetryConfig.getClusterConnectTimeoutMillis());
assertEquals(0.5, connectionRetryConfig.getJitter(), 0);
assertEquals(2000, connectionRetryConfig.getInitialBackoffMillis());
assertEquals(60000, connectionRetryConfig.getMaxBackoffMillis());
assertEquals(3, connectionRetryConfig.getMultiplier(), 0);
}
use of com.hazelcast.client.config.ConnectionRetryConfig in project hazelcast by hazelcast.
the class ClientDomConfigProcessor method handleConnectionRetry.
private void handleConnectionRetry(Node node, ClientConnectionStrategyConfig strategyConfig) {
ConnectionRetryConfig connectionRetryConfig = new ConnectionRetryConfig();
String initialBackoffMillis = "initial-backoff-millis";
String maxBackoffMillis = "max-backoff-millis";
String multiplier = "multiplier";
String jitter = "jitter";
String timeoutMillis = "cluster-connect-timeout-millis";
for (Node child : childElements(node)) {
String nodeName = cleanNodeName(child);
if (matches(initialBackoffMillis, nodeName)) {
connectionRetryConfig.setInitialBackoffMillis(getIntegerValue(initialBackoffMillis, getTextContent(child)));
} else if (matches(maxBackoffMillis, nodeName)) {
connectionRetryConfig.setMaxBackoffMillis(getIntegerValue(maxBackoffMillis, getTextContent(child)));
} else if (matches(multiplier, nodeName)) {
connectionRetryConfig.setMultiplier(getDoubleValue(multiplier, getTextContent(child)));
} else if (matches(timeoutMillis, nodeName)) {
connectionRetryConfig.setClusterConnectTimeoutMillis(getLongValue(timeoutMillis, getTextContent(child)));
} else if (matches(jitter, nodeName)) {
connectionRetryConfig.setJitter(getDoubleValue(jitter, getTextContent(child)));
}
}
strategyConfig.setConnectionRetryConfig(connectionRetryConfig);
}
use of com.hazelcast.client.config.ConnectionRetryConfig in project hazelcast by hazelcast.
the class TcpClientConnectionManager method initializeWaitStrategy.
private WaitStrategy initializeWaitStrategy(ClientConfig clientConfig) {
ConnectionRetryConfig retryConfig = clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig();
long clusterConnectTimeout = retryConfig.getClusterConnectTimeoutMillis();
if (clusterConnectTimeout == DEFAULT_CLUSTER_CONNECT_TIMEOUT_MILLIS) {
// and infinite for the normal client.
if (failoverConfigProvided) {
clusterConnectTimeout = FAILOVER_CLIENT_DEFAULT_CLUSTER_CONNECT_TIMEOUT_MILLIS;
} else {
clusterConnectTimeout = Long.MAX_VALUE;
}
}
return new WaitStrategy(retryConfig.getInitialBackoffMillis(), retryConfig.getMaxBackoffMillis(), retryConfig.getMultiplier(), clusterConnectTimeout, retryConfig.getJitter(), logger);
}
use of com.hazelcast.client.config.ConnectionRetryConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testClientShutdown_shouldNotWaitForNextConnectionAttempt.
@Test(timeout = 20000)
public void testClientShutdown_shouldNotWaitForNextConnectionAttempt() throws InterruptedException {
HazelcastInstance server = hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
ConnectionRetryConfig connectionRetryConfig = clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig();
connectionRetryConfig.setInitialBackoffMillis(240000);
connectionRetryConfig.setMaxBackoffMillis(300000);
connectionRetryConfig.setMultiplier(1);
connectionRetryConfig.setClusterConnectTimeoutMillis(Integer.MAX_VALUE);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
// client will get into retry
server.shutdown();
// we expect this shutdown not to wait for 4 minutes (240000).
// Test will timeout in 20 seconds. Note that global executor shutdown in ClientExecutionServiceImpl timeout is 30 seconds
client.shutdown();
}
Aggregations