use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class SqlConsole method sqlStartingPrompt.
private static String sqlStartingPrompt(HazelcastInstance hz) {
HazelcastClientInstanceImpl hazelcastClientImpl = getHazelcastClientInstanceImpl(hz);
ClientClusterService clientClusterService = hazelcastClientImpl.getClientClusterService();
MCClusterMetadata clusterMetadata = FutureUtil.getValue(getClusterMetadata(hazelcastClientImpl, clientClusterService.getMasterMember()));
Cluster cluster = hazelcastClientImpl.getCluster();
Set<Member> members = cluster.getMembers();
String versionString = "Hazelcast " + clusterMetadata.getMemberVersion();
return new AttributedStringBuilder().style(AttributedStyle.BOLD.foreground(PRIMARY_COLOR)).append("Connected to ").append(versionString).append(" at ").append(members.iterator().next().getAddress().toString()).append(" (+").append(String.valueOf(members.size() - 1)).append(" more)\n").append("Type 'help' for instructions").toAnsi();
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientRegressionWithRealNetworkTest method testNioChannelLeakTest.
@Test
public void testNioChannelLeakTest() {
ClientConfig config = new ClientConfig();
config.getConnectionStrategyConfig().setAsyncStart(true).setReconnectMode(ClientConnectionStrategyConfig.ReconnectMode.ASYNC).getConnectionRetryConfig().setInitialBackoffMillis(1).setClusterConnectTimeoutMillis(1000);
HazelcastInstance client = HazelcastClient.newHazelcastClient(config);
HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
TcpClientConnectionManager connectionManager = (TcpClientConnectionManager) clientInstanceImpl.getConnectionManager();
sleepSeconds(2);
assertTrueEventually(() -> assertEquals(0, connectionManager.getNetworking().getChannels().size()));
client.shutdown();
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientRegressionWithRealNetworkTest method testConnectionCountAfterClientReconnect.
private void testConnectionCountAfterClientReconnect(String memberAddress, String clientAddress) {
Config config = new Config();
config.getNetworkConfig().setPublicAddress(memberAddress);
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().addAddress(clientAddress);
clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(Long.MAX_VALUE);
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
ClientConnectionManager connectionManager = clientInstanceImpl.getConnectionManager();
assertTrueEventually(() -> assertEquals(1, connectionManager.getActiveConnections().size()));
ReconnectListener reconnectListener = new ReconnectListener();
client.getLifecycleService().addLifecycleListener(reconnectListener);
hazelcastInstance.shutdown();
assertOpenEventually(reconnectListener.disconnectedLatch);
Hazelcast.newHazelcastInstance(config);
assertOpenEventually(reconnectListener.reconnectedLatch);
assertEquals(1, connectionManager.getActiveConnections().size());
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class TcpClientConnectionTest method testAddingConnectionListenerTwice_shouldCauseEventDeliveredTwice.
@Test
public void testAddingConnectionListenerTwice_shouldCauseEventDeliveredTwice() {
hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
HazelcastClientInstanceImpl clientImpl = ClientTestUtil.getHazelcastClientInstanceImpl(client);
ClientConnectionManager connectionManager = clientImpl.getConnectionManager();
final CountingConnectionListener listener = new CountingConnectionListener();
connectionManager.addConnectionListener(listener);
connectionManager.addConnectionListener(listener);
hazelcastFactory.newHazelcastInstance();
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertEquals(listener.connectionAddedCount.get(), 2);
}
});
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientConfigLoadBalancerTest method shouldCreateCustomLoadBalancerWhenConfigInstanceNotProvidedAndClassNameSpecified.
@Test
public void shouldCreateCustomLoadBalancerWhenConfigInstanceNotProvidedAndClassNameSpecified() {
hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setLoadBalancerClassName("com.hazelcast.client.test.CustomLoadBalancer");
HazelcastInstance instance = hazelcastFactory.newHazelcastClient(clientConfig);
HazelcastClientInstanceImpl client = ClientTestUtil.getHazelcastClientInstanceImpl(instance);
LoadBalancer actual = client.getLoadBalancer();
assertTrue(actual instanceof CustomLoadBalancer);
}
Aggregations