use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testMapDestroyIssue764.
@Test
public void testMapDestroyIssue764() throws Exception {
HazelcastInstance server = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
assertNoOfDistributedObject("Initially the server should have %d distributed objects, but had %d", 0, server.getDistributedObjects());
assertNoOfDistributedObject("Initially the client should have %d distributed objects, but had %d", 0, client.getDistributedObjects());
IMap map = client.getMap("mapToDestroy");
assertNoOfDistributedObject("After getMap() the server should have %d distributed objects, but had %d", 1, server.getDistributedObjects());
assertNoOfDistributedObject("After getMap() the client should have %d distributed objects, but had %d", 1, client.getDistributedObjects());
map.destroy();
// Get the distributed objects as fast as possible to catch a race condition more likely
Collection<DistributedObject> serverDistributedObjects = server.getDistributedObjects();
Collection<DistributedObject> clientDistributedObjects = client.getDistributedObjects();
assertNoOfDistributedObject("After destroy() the server should should have %d distributed objects, but had %d", 0, serverDistributedObjects);
assertNoOfDistributedObject("After destroy() the client should should have %d distributed objects, but had %d", 0, clientDistributedObjects);
}
use of com.hazelcast.core.DistributedObject in project hazelcast by hazelcast.
the class DistributedObjectListenerTest method destroyedNotReceivedOnClient.
@Test
public void destroyedNotReceivedOnClient() throws Exception {
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
final HazelcastInstance client = hazelcastFactory.newHazelcastClient();
final CountDownLatch createdLatch = new CountDownLatch(1);
final CountDownLatch destroyedLatch = new CountDownLatch(1);
client.addDistributedObjectListener(new DistributedObjectListener() {
@Override
public void distributedObjectCreated(DistributedObjectEvent event) {
createdLatch.countDown();
}
@Override
public void distributedObjectDestroyed(DistributedObjectEvent event) {
destroyedLatch.countDown();
}
});
final String name = randomString();
final ITopic<Object> topic = instance.getTopic(name);
assertOpenEventually(createdLatch, 10);
assertEquals(1, client.getDistributedObjects().size());
topic.destroy();
assertOpenEventually(destroyedLatch, 10);
assertTrueAllTheTime(new AssertTask() {
@Override
public void run() throws Exception {
Collection<DistributedObject> distributedObjects = client.getDistributedObjects();
assertTrue(distributedObjects.isEmpty());
}
}, 5);
}
Aggregations