Search in sources :

Example 1 with ConnectionRetryConfig

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);
}
Also used : ConnectionRetryConfig(com.hazelcast.client.config.ConnectionRetryConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with ConnectionRetryConfig

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);
}
Also used : ConnectionRetryConfig(com.hazelcast.client.config.ConnectionRetryConfig) Node(org.w3c.dom.Node)

Example 3 with 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);
}
Also used : ConnectionRetryConfig(com.hazelcast.client.config.ConnectionRetryConfig)

Example 4 with ConnectionRetryConfig

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ConnectionRetryConfig(com.hazelcast.client.config.ConnectionRetryConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

ConnectionRetryConfig (com.hazelcast.client.config.ConnectionRetryConfig)4 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 Node (org.w3c.dom.Node)1