use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testOperationRedo.
@Test(timeout = 60000)
public void testOperationRedo() throws Exception {
final HazelcastInstance hz1 = hazelcastFactory.newHazelcastInstance();
hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setRedoOperation(true);
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final Thread thread = new Thread() {
public void run() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
hz1.getLifecycleService().shutdown();
}
};
final IMap map = client.getMap("m");
thread.start();
int expected = 1000;
for (int i = 0; i < expected; i++) {
map.put(i, "item" + i);
}
thread.join();
assertEquals(expected, map.size());
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testLock_WhenClientAndOwnerNodeDiesTogether.
private void testLock_WhenClientAndOwnerNodeDiesTogether(boolean smart) throws InterruptedException {
hazelcastFactory.newHazelcastInstance();
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setSmartRouting(smart);
final int tryCount = 5;
for (int i = 0; i < tryCount; i++) {
final HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final ILock lock = client.getLock("lock");
assertTrue(lock.tryLock(1, TimeUnit.MINUTES));
//with client is dead, lock should be released.
client.getLifecycleService().terminate();
instance.getLifecycleService().terminate();
}
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testDeadlock_WhenDoingOperationFromLifecycleListenerWithInitialPartitionTable.
@Test
public void testDeadlock_WhenDoingOperationFromLifecycleListenerWithInitialPartitionTable() {
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
final ClientConfig clientConfig = new ClientConfig();
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig.setExecutorPoolSize(1));
hazelcastFactory.newHazelcastInstance();
final CountDownLatch latch = new CountDownLatch(1);
final IMap<Object, Object> map = client.getMap(randomMapName());
// Let the partition table retrieved the first time
map.get(1);
client.getLifecycleService().addLifecycleListener(new LifecycleListener() {
@Override
public void stateChanged(LifecycleEvent event) {
if (event.getState() == LifecycleState.CLIENT_DISCONNECTED) {
for (int i = 0; i < 1000; i++) {
map.get(i);
}
latch.countDown();
}
}
});
instance.shutdown();
assertOpenEventually(latch);
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testMemberAddedWithListeners_thenCheckOperationsNotHanging.
@Test(timeout = 120000)
public void testMemberAddedWithListeners_thenCheckOperationsNotHanging() throws Exception {
hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setProperty(ClientExecutionServiceImpl.INTERNAL_EXECUTOR_POOL_SIZE.getName(), "1");
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
IMap map = client.getMap("map");
map.addEntryListener(mock(MapListener.class), true);
HazelcastInstance h2 = hazelcastFactory.newHazelcastInstance();
String key = generateKeyOwnedBy(h2);
map.get(key);
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientRegressionWithRealNetworkTest method testClientConnectionBeforeServerReady.
@Test
public void testClientConnectionBeforeServerReady() throws InterruptedException {
ExecutorService executorService = Executors.newFixedThreadPool(2);
executorService.submit(new Runnable() {
@Override
public void run() {
Hazelcast.newHazelcastInstance();
}
});
final CountDownLatch clientLatch = new CountDownLatch(1);
executorService.submit(new Runnable() {
@Override
public void run() {
ClientConfig config = new ClientConfig();
config.getNetworkConfig().setConnectionAttemptLimit(10);
HazelcastInstance client = HazelcastClient.newHazelcastClient(config);
clientLatch.countDown();
}
});
assertOpenEventually(clientLatch);
}
Aggregations