use of com.hazelcast.client.impl.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class AbstractListenersOnReconnectTest method testListenersHeartbeatTimeoutToOwner.
private void testListenersHeartbeatTimeoutToOwner() {
setupListener();
HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
HazelcastInstance server = getOwnerServer(factory, clientInstanceImpl);
final CountDownLatch disconnectedLatch = new CountDownLatch(1);
final CountDownLatch connectedLatch = new CountDownLatch(1);
client.getLifecycleService().addLifecycleListener(new LifecycleListener() {
@Override
public void stateChanged(LifecycleEvent event) {
if (LifecycleEvent.LifecycleState.CLIENT_DISCONNECTED == event.getState()) {
disconnectedLatch.countDown();
}
if (LifecycleEvent.LifecycleState.CLIENT_CONNECTED == event.getState()) {
connectedLatch.countDown();
}
}
});
blockMessagesFromInstance(server, client);
assertOpenEventually(disconnectedLatch);
unblockMessagesFromInstance(server, client);
assertOpenEventually(connectedLatch);
validateRegistrationsAndListenerFunctionality();
}
use of com.hazelcast.client.impl.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientPartitionLostListenerTest method test_partitionLostListener_invoked_fromOtherNode.
@Test
public void test_partitionLostListener_invoked_fromOtherNode() {
final HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance();
final HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setSmartRouting(false);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
warmUpPartitions(instance1, instance2, client);
final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
final Address clientOwnerAddress = clientInstanceImpl.getClientClusterService().getOwnerConnectionAddress();
final HazelcastInstance other = getAddress(instance1).equals(clientOwnerAddress) ? instance2 : instance1;
final EventCollectingPartitionLostListener listener = new EventCollectingPartitionLostListener();
client.getPartitionService().addPartitionLostListener(listener);
assertRegistrationsSizeEventually(instance1, 1);
assertRegistrationsSizeEventually(instance2, 1);
final InternalPartitionServiceImpl partitionService = getNode(other).getNodeEngine().getService(SERVICE_NAME);
final int partitionId = 5;
partitionService.onPartitionLost(new IPartitionLostEvent(partitionId, 0, null));
assertPartitionLostEventEventually(listener, partitionId);
}
use of com.hazelcast.client.impl.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ProxyManagerTest method testNextAddressToSendCreateRequestOnMultipleLiteMembers.
@Test
public void testNextAddressToSendCreateRequestOnMultipleLiteMembers() {
final List<HazelcastInstance> instances = createNodes(3, 0);
final HazelcastInstance client = factory.newHazelcastClient();
final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
Set<Address> addresses = new HashSet<Address>();
final ProxyManager proxyManager = clientInstanceImpl.getProxyManager();
for (int i = 0; i < instances.size() * 100; i++) {
addresses.add(proxyManager.findNextAddressToSendCreateRequest());
}
assertEquals(1, addresses.size());
}
use of com.hazelcast.client.impl.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientTestSupport method unblockMessagesToInstance.
/**
* Unblocks outgoing messages from client to given instance
*/
protected void unblockMessagesToInstance(HazelcastInstance instance, HazelcastInstance client) {
HazelcastClientInstanceImpl clientImpl = getHazelcastClientInstanceImpl(client);
ClientConnectionManager connectionManager = clientImpl.getConnectionManager();
Address address = instance.getCluster().getLocalMember().getAddress();
((TestClientRegistry.MockClientConnectionManager) connectionManager).unblockTo(address);
}
use of com.hazelcast.client.impl.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientTestSupport method unblockMessagesFromInstance.
/**
* Unblocks incoming messages to client from given instance
*/
protected void unblockMessagesFromInstance(HazelcastInstance instance, HazelcastInstance client) {
HazelcastClientInstanceImpl clientImpl = getHazelcastClientInstanceImpl(client);
ClientConnectionManager connectionManager = clientImpl.getConnectionManager();
Address address = instance.getCluster().getLocalMember().getAddress();
((TestClientRegistry.MockClientConnectionManager) connectionManager).unblockFrom(address);
}
Aggregations