@Test public void whenTargetMemberDiesThenOperationAbortedWithMembersLeftException() throws Exception { TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2); HazelcastInstance local = factory.newHazelcastInstance(); HazelcastInstance remote = factory.newHazelcastInstance(); warmUpPartitions(local, remote); OperationService service = getNode(local).nodeEngine.getOperationService(); Operation op = new TargetOperation(); Address address = new Address(remote.getCluster().getLocalMember().getSocketAddress()); Future f = service.createInvocationBuilder(null, op, address).invoke(); sleepSeconds(1); remote.getLifecycleService().terminate(); try { f.get(); fail(); } catch (MemberLeftException expected) { } }
@Test public void whenPartitionTargetMemberDiesThenOperationSendToNewPartitionOwner() throws Exception { TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2); HazelcastInstance local = factory.newHazelcastInstance(); HazelcastInstance remote = factory.newHazelcastInstance(); warmUpPartitions(local, remote); Node localNode = getNode(local); OperationService service = localNode.nodeEngine.getOperationService(); Operation op = new PartitionTargetOperation(); String partitionKey = generateKeyOwnedBy(remote); int partitionId = localNode.nodeEngine.getPartitionService().getPartitionId(partitionKey); Future f = service.createInvocationBuilder(null, op, partitionId).setCallTimeout(30000).invoke(); sleepSeconds(1); remote.shutdown(); // the get should work without a problem because the operation should be re-targeted at the // newest owner // for that given partition f.get(); }