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);
}
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);
}
}
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());
}
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");
}
Aggregations