use of com.hazelcast.cluster.MembershipAdapter in project hazelcast by hazelcast.
the class ClientClusterProxyTest method removeMembershipListener.
@Test
public void removeMembershipListener() throws Exception {
Cluster cluster = client().getCluster();
UUID regId = cluster.addMembershipListener(new MembershipAdapter());
assertTrue(cluster.removeMembershipListener(regId));
}
use of com.hazelcast.cluster.MembershipAdapter in project hazelcast by hazelcast.
the class ClientTxnTest method testTxnRollback.
@Test
public void testTxnRollback() throws Exception {
final String queueName = randomString();
final TransactionContext context = client.newTransactionContext();
CountDownLatch txnRollbackLatch = new CountDownLatch(1);
final CountDownLatch memberRemovedLatch = new CountDownLatch(1);
client.getCluster().addMembershipListener(new MembershipAdapter() {
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
memberRemovedLatch.countDown();
}
});
try {
context.beginTransaction();
assertNotNull(context.getTxnId());
final TransactionalQueue queue = context.getQueue(queueName);
queue.offer(randomString());
server.shutdown();
context.commitTransaction();
fail("commit should throw exception!!!");
} catch (TransactionException e) {
context.rollbackTransaction();
txnRollbackLatch.countDown();
}
assertOpenEventually(txnRollbackLatch);
assertOpenEventually(memberRemovedLatch);
final IQueue<Object> q = client.getQueue(queueName);
assertNull(q.poll());
assertEquals(0, q.size());
}
Aggregations