use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientStatisticsTest method testStatisticsClusterReconnect.
@Test
public void testStatisticsClusterReconnect() {
HazelcastInstance hazelcastInstance = hazelcastFactory.newHazelcastInstance();
HazelcastClientInstanceImpl client = createHazelcastClient();
ReconnectListener reconnectListener = new ReconnectListener();
client.getLifecycleService().addLifecycleListener(reconnectListener);
hazelcastInstance.getLifecycleService().terminate();
hazelcastInstance = hazelcastFactory.newHazelcastInstance();
ClientEngineImpl clientEngine = getClientEngineImpl(hazelcastInstance);
assertOpenEventually(reconnectListener.reconnectedLatch);
// wait enough time for statistics collection
waitForFirstStatisticsCollection(client, clientEngine);
getStats(client, clientEngine);
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientStatisticsTest method testStatisticsPeriod.
@Test
public void testStatisticsPeriod() {
HazelcastInstance hazelcastInstance = hazelcastFactory.newHazelcastInstance();
HazelcastClientInstanceImpl client = createHazelcastClient();
ClientEngineImpl clientEngine = getClientEngineImpl(hazelcastInstance);
// wait enough time for statistics collection
waitForFirstStatisticsCollection(client, clientEngine);
Map<String, String> initialStats = getStats(client, clientEngine);
// produce map and cache stat
produceSomeStats(hazelcastInstance, client);
// wait enough time for statistics collection
waitForNextStatsCollection(client, clientEngine, initialStats.get("lastStatisticsCollectionTime"));
assertNotEquals("initial statistics should not be the same as current stats", initialStats, getStats(client, clientEngine));
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientStatisticsTest method testStatisticsTwoClients.
@Test
public void testStatisticsTwoClients() {
HazelcastInstance hazelcastInstance = hazelcastFactory.newHazelcastInstance();
final HazelcastClientInstanceImpl client1 = createHazelcastClient();
final HazelcastClientInstanceImpl client2 = createHazelcastClient();
final ClientEngineImpl clientEngine = getClientEngineImpl(hazelcastInstance);
assertTrueEventually(() -> {
Map<UUID, ClientStatistics> clientStatistics = clientEngine.getClientStatistics();
assertNotNull(clientStatistics);
assertEquals(2, clientStatistics.size());
List<UUID> expectedUUIDs = new ArrayList<>(2);
expectedUUIDs.add(client1.getClientClusterService().getLocalClient().getUuid());
expectedUUIDs.add(client2.getClientClusterService().getLocalClient().getUuid());
for (Map.Entry<UUID, ClientStatistics> clientEntry : clientStatistics.entrySet()) {
assertTrue(expectedUUIDs.contains(clientEntry.getKey()));
String clientAttributes = clientEntry.getValue().clientAttributes();
assertNotNull(clientAttributes);
}
});
}
use of com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientTestSupport method blockMessagesToInstance.
/**
* Blocks outgoing messages from client to given instance
*/
protected void blockMessagesToInstance(HazelcastInstance instance, HazelcastInstance client) {
HazelcastClientInstanceImpl clientImpl = getHazelcastClientInstanceImpl(client);
ClientConnectionManager connectionManager = clientImpl.getConnectionManager();
Address address = instance.getCluster().getLocalMember().getAddress();
((TestClientRegistry.MockTcpClientConnectionManager) connectionManager).blockTo(address);
}
Aggregations