Search in sources :

Example 1 with ClientConnectionStrategyConfig

use of com.hazelcast.client.config.ClientConnectionStrategyConfig in project hazelcast by hazelcast.

the class ClientDomConfigProcessor method handleConnectionStrategy.

private void handleConnectionStrategy(Node node) {
    ClientConnectionStrategyConfig strategyConfig = clientConfig.getConnectionStrategyConfig();
    String attrValue = getAttribute(node, "async-start");
    strategyConfig.setAsyncStart(attrValue != null && getBooleanValue(attrValue.trim()));
    attrValue = getAttribute(node, "reconnect-mode");
    if (attrValue != null) {
        strategyConfig.setReconnectMode(ClientConnectionStrategyConfig.ReconnectMode.valueOf(upperCaseInternal(attrValue.trim())));
    }
    for (Node child : childElements(node)) {
        String nodeName = cleanNodeName(child);
        if (matches("connection-retry", nodeName)) {
            handleConnectionRetry(child, strategyConfig);
        }
    }
    clientConfig.setConnectionStrategyConfig(strategyConfig);
}
Also used : Node(org.w3c.dom.Node) ClientConnectionStrategyConfig(com.hazelcast.client.config.ClientConnectionStrategyConfig)

Example 2 with ClientConnectionStrategyConfig

use of com.hazelcast.client.config.ClientConnectionStrategyConfig in project hazelcast by hazelcast.

the class HazelcastClientInstanceImpl method start.

public void start() {
    try {
        lifecycleService.start();
        startMetrics();
        invocationService.start();
        ClientContext clientContext = new ClientContext(this);
        userCodeDeploymentService.start();
        Collection<EventListener> configuredListeners = instantiateConfiguredListenerObjects();
        clusterService.start(configuredListeners);
        clientClusterViewListenerService.start();
        connectionManager.start();
        startHeartbeat();
        startIcmpPing();
        connectionManager.connectToCluster();
        diagnostics.start();
        // static loggers at beginning of file
        diagnostics.register(new BuildInfoPlugin(loggingService.getLogger(BuildInfoPlugin.class)));
        diagnostics.register(new ConfigPropertiesPlugin(loggingService.getLogger(ConfigPropertiesPlugin.class), properties));
        diagnostics.register(new SystemPropertiesPlugin(loggingService.getLogger(SystemPropertiesPlugin.class)));
        // periodic loggers
        diagnostics.register(new MetricsPlugin(loggingService.getLogger(MetricsPlugin.class), metricsRegistry, properties));
        diagnostics.register(new SystemLogPlugin(properties, connectionManager, this, loggingService.getLogger(SystemLogPlugin.class)));
        diagnostics.register(new NetworkingImbalancePlugin(properties, connectionManager.getNetworking(), loggingService.getLogger(NetworkingImbalancePlugin.class)));
        diagnostics.register(new EventQueuePlugin(loggingService.getLogger(EventQueuePlugin.class), listenerService.getEventExecutor(), properties));
        metricsRegistry.provideMetrics(listenerService);
        ClientConnectionStrategyConfig connectionStrategyConfig = config.getConnectionStrategyConfig();
        boolean asyncStart = connectionStrategyConfig.isAsyncStart();
        if (!asyncStart) {
            waitForInitialMembershipEvents();
        }
        connectionManager.tryConnectToAllClusterMembers(!asyncStart);
        listenerService.start();
        proxyManager.init(config, clientContext);
        invocationService.addBackupListener();
        loadBalancer.init(getCluster(), config);
        clientStatisticsService.start();
        clientExtension.afterStart(this);
        cpSubsystem.init(clientContext);
        addClientConfigAddedListeners(configuredListeners);
        sendStateToCluster();
    } catch (Throwable e) {
        try {
            lifecycleService.terminate();
        } catch (Throwable t) {
            ignore(t);
        }
        throw rethrow(e);
    }
}
Also used : ConfigPropertiesPlugin(com.hazelcast.internal.diagnostics.ConfigPropertiesPlugin) MetricsPlugin(com.hazelcast.internal.diagnostics.MetricsPlugin) ClientContext(com.hazelcast.client.impl.spi.ClientContext) BuildInfoPlugin(com.hazelcast.internal.diagnostics.BuildInfoPlugin) NetworkingImbalancePlugin(com.hazelcast.internal.diagnostics.NetworkingImbalancePlugin) EventQueuePlugin(com.hazelcast.internal.diagnostics.EventQueuePlugin) ClientConnectionStrategyConfig(com.hazelcast.client.config.ClientConnectionStrategyConfig) SystemPropertiesPlugin(com.hazelcast.internal.diagnostics.SystemPropertiesPlugin) EventListener(java.util.EventListener) SystemLogPlugin(com.hazelcast.internal.diagnostics.SystemLogPlugin)

Example 3 with ClientConnectionStrategyConfig

use of com.hazelcast.client.config.ClientConnectionStrategyConfig in project hazelcast by hazelcast.

the class TestClientApplicationContext method testClientConnectionStrategyConfig.

@Test
public void testClientConnectionStrategyConfig() {
    ClientConnectionStrategyConfig connectionStrategyConfig = client8.getClientConfig().getConnectionStrategyConfig();
    assertTrue(connectionStrategyConfig.isAsyncStart());
    assertEquals(ReconnectMode.ASYNC, connectionStrategyConfig.getReconnectMode());
}
Also used : ClientConnectionStrategyConfig(com.hazelcast.client.config.ClientConnectionStrategyConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with ClientConnectionStrategyConfig

use of com.hazelcast.client.config.ClientConnectionStrategyConfig in project hazelcast by hazelcast.

the class ClientTransactionManagerServiceImpl method throwException.

private RuntimeException throwException(boolean smartRouting) {
    ClientConfig clientConfig = client.getClientConfig();
    ClientConnectionStrategyConfig connectionStrategyConfig = clientConfig.getConnectionStrategyConfig();
    ClientConnectionStrategyConfig.ReconnectMode reconnectMode = connectionStrategyConfig.getReconnectMode();
    if (reconnectMode.equals(ClientConnectionStrategyConfig.ReconnectMode.ASYNC)) {
        throw new HazelcastClientOfflineException();
    }
    if (smartRouting) {
        Set<Member> members = client.getCluster().getMembers();
        String msg;
        if (members.isEmpty()) {
            msg = "No address was return by the LoadBalancer since there are no members in the cluster";
        } else {
            msg = "No address was return by the LoadBalancer. " + "But the cluster contains the following members:" + members;
        }
        throw new IllegalStateException(msg);
    }
    throw new IllegalStateException("No active connection is found");
}
Also used : ClientConnectionStrategyConfig(com.hazelcast.client.config.ClientConnectionStrategyConfig) StringUtil.timeToString(com.hazelcast.internal.util.StringUtil.timeToString) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientOfflineException(com.hazelcast.client.HazelcastClientOfflineException) Member(com.hazelcast.cluster.Member)

Aggregations

ClientConnectionStrategyConfig (com.hazelcast.client.config.ClientConnectionStrategyConfig)4 HazelcastClientOfflineException (com.hazelcast.client.HazelcastClientOfflineException)1 ClientConfig (com.hazelcast.client.config.ClientConfig)1 ClientContext (com.hazelcast.client.impl.spi.ClientContext)1 Member (com.hazelcast.cluster.Member)1 BuildInfoPlugin (com.hazelcast.internal.diagnostics.BuildInfoPlugin)1 ConfigPropertiesPlugin (com.hazelcast.internal.diagnostics.ConfigPropertiesPlugin)1 EventQueuePlugin (com.hazelcast.internal.diagnostics.EventQueuePlugin)1 MetricsPlugin (com.hazelcast.internal.diagnostics.MetricsPlugin)1 NetworkingImbalancePlugin (com.hazelcast.internal.diagnostics.NetworkingImbalancePlugin)1 SystemLogPlugin (com.hazelcast.internal.diagnostics.SystemLogPlugin)1 SystemPropertiesPlugin (com.hazelcast.internal.diagnostics.SystemPropertiesPlugin)1 StringUtil.timeToString (com.hazelcast.internal.util.StringUtil.timeToString)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 EventListener (java.util.EventListener)1 Test (org.junit.Test)1 Node (org.w3c.dom.Node)1