use of com.hazelcast.client.impl.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientServiceTest method testPendingEventPacketsWithEvents.
@Test(timeout = 120000)
public void testPendingEventPacketsWithEvents() throws InterruptedException, UnknownHostException {
HazelcastInstance hazelcastInstance = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
IMap map = client.getMap(randomName());
map.addEntryListener(new EntryAdapter(), false);
for (int i = 0; i < 10; i++) {
map.put(randomString(), randomString());
}
HazelcastClientInstanceImpl clientInstanceImpl = ClientTestUtil.getHazelcastClientInstanceImpl(client);
InetSocketAddress socketAddress = hazelcastInstance.getCluster().getLocalMember().getSocketAddress();
Address address = new Address(socketAddress.getAddress().getHostAddress(), socketAddress.getPort());
ClientConnectionManager connectionManager = clientInstanceImpl.getConnectionManager();
final ClientConnection connection = (ClientConnection) connectionManager.getConnection(address);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(0, connection.getPendingPacketCount());
}
});
}
use of com.hazelcast.client.impl.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientPartitionCancellableDelegatingFuture method invokeCancelRequest.
private boolean invokeCancelRequest(boolean mayInterruptIfRunning) throws InterruptedException {
waitForRequestToBeSend();
ClientInvocation clientInvocation;
final HazelcastClientInstanceImpl client = (HazelcastClientInstanceImpl) context.getHazelcastInstance();
ClientMessage request = ExecutorServiceCancelOnPartitionCodec.encodeRequest(uuid, partitionId, mayInterruptIfRunning);
clientInvocation = new ClientInvocation(client, request, partitionId);
try {
ClientInvocationFuture f = clientInvocation.invoke();
return ExecutorServiceCancelOnPartitionCodec.decodeResponse(f.get()).response;
} catch (Exception e) {
throw rethrow(e);
}
}
use of com.hazelcast.client.impl.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ProxyManagerTest method testNextAddressToSendCreateRequestOnMultipleDataMembers.
@Test
public void testNextAddressToSendCreateRequestOnMultipleDataMembers() {
final List<HazelcastInstance> instances = createNodes(3, 3);
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(3, addresses.size());
for (HazelcastInstance lite : instances.subList(3, 6)) {
assertContains(addresses, getAddress(lite));
}
}
use of com.hazelcast.client.impl.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ProxyManagerTest method testNextAddressToSendCreateRequestOnSingleDataMember.
@Test
public void testNextAddressToSendCreateRequestOnSingleDataMember() {
final List<HazelcastInstance> instances = createNodes(3, 1);
final Address dataInstanceAddress = getAddress(instances.get(3));
final HazelcastInstance client = factory.newHazelcastClient();
final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
final ProxyManager proxyManager = clientInstanceImpl.getProxyManager();
for (int i = 0; i < instances.size(); i++) {
assertEquals(dataInstanceAddress, proxyManager.findNextAddressToSendCreateRequest());
}
}
use of com.hazelcast.client.impl.HazelcastClientInstanceImpl in project hazelcast by hazelcast.
the class ClientMapPartitionLostListenerTest method test_mapPartitionLostListener_invoked_fromOtherNode.
@Test
public void test_mapPartitionLostListener_invoked_fromOtherNode() {
final String mapName = randomMapName();
final Config config = new Config();
config.getMapConfig(mapName).setBackupCount(0);
final HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance(config);
final HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance(config);
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setSmartRouting(false);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
final Address clientOwnerAddress = clientInstanceImpl.getClientClusterService().getOwnerConnectionAddress();
final HazelcastInstance other = getAddress(instance1).equals(clientOwnerAddress) ? instance2 : instance1;
final TestEventCollectingMapPartitionLostListener listener = new TestEventCollectingMapPartitionLostListener(0);
client.getMap(mapName).addPartitionLostListener(listener);
assertRegistrationEventually(instance1, mapName, true);
assertRegistrationEventually(instance2, mapName, true);
assertProxyExistsEventually(instance1, mapName);
assertProxyExistsEventually(instance2, mapName);
final MapService mapService = getNode(other).getNodeEngine().getService(SERVICE_NAME);
final int partitionId = 5;
mapService.onPartitionLost(new IPartitionLostEvent(partitionId, 0, null));
assertMapPartitionLostEventEventually(listener, partitionId);
}
Aggregations