use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class LeadershipTransferTest method testFollowerCannotTransferLeadership.
@Test
public void testFollowerCannotTransferLeadership() throws Exception {
group = newGroup(3);
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
RaftNodeImpl follower = group.getNodesExcept(leader.getLocalMember())[0];
InternalCompletableFuture f = follower.transferLeadership(leader.getLocalMember());
exceptionRule.expect(IllegalStateException.class);
f.joinInternal();
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class LeadershipTransferTest method testTransferLeadershipTimesOutWhenTargetCannotCatchupInTime.
@Test
public void testTransferLeadershipTimesOutWhenTargetCannotCatchupInTime() throws Exception {
group = newGroup(3);
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
RaftNodeImpl follower = group.getNodesExcept(leader.getLocalMember())[0];
group.dropMessagesToMember(leader.getLocalMember(), follower.getLocalMember(), AppendRequest.class);
leader.replicate(new NopEntry()).get();
InternalCompletableFuture f = leader.transferLeadership(follower.getLocalMember());
exceptionRule.expect(IllegalStateException.class);
f.joinInternal();
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class LeadershipTransferTest method testAnotherTransferLeadershipRequestFailsDuringOngoingLeadershipTransfer.
@Test
public void testAnotherTransferLeadershipRequestFailsDuringOngoingLeadershipTransfer() throws Exception {
group = newGroup(3);
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
RaftNodeImpl[] followers = group.getNodesExcept(leader.getLocalMember());
RaftNodeImpl follower1 = followers[0];
RaftNodeImpl follower2 = followers[1];
group.dropMessagesToMember(leader.getLocalMember(), follower1.getLocalMember(), AppendRequest.class);
leader.replicate(new NopEntry()).get();
leader.transferLeadership(follower1.getLocalMember());
InternalCompletableFuture f = leader.transferLeadership(follower2.getLocalMember());
exceptionRule.expect(IllegalStateException.class);
f.joinInternal();
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class LeadershipTransferTest method testCannotTransferLeadershipToNull.
@Test
public void testCannotTransferLeadershipToNull() throws Exception {
group = newGroup(3);
group.start();
RaftNodeImpl leader = group.waitUntilLeaderElected();
InternalCompletableFuture future = leader.transferLeadership(null);
exceptionRule.expect(IllegalArgumentException.class);
future.joinInternal();
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class MapRemoveFailingBackupTest method testMapRemoveFailingBackupShouldNotLeadToStaleDataWhenReadBackupIsEnabled.
@Test
public void testMapRemoveFailingBackupShouldNotLeadToStaleDataWhenReadBackupIsEnabled() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
final String mapName = randomMapName();
final String key = "2";
final String value = "value2";
Config config = getConfig();
config.getSerializationConfig().addDataSerializableFactory(100, new Factory());
config.setProperty(ClusterProperty.PARTITION_BACKUP_SYNC_INTERVAL.getName(), "5");
config.getMapConfig(mapName).setReadBackupData(true);
HazelcastInstance hz1 = factory.newHazelcastInstance(config);
HazelcastInstance hz2 = factory.newHazelcastInstance(config);
final NodeEngine nodeEngine = getNodeEngineImpl(hz1);
final IMap<Object, Object> map1 = hz1.getMap(mapName);
final IMap<Object, Object> map2 = hz2.getMap(mapName);
MapProxyImpl<Object, Object> mock1 = (MapProxyImpl<Object, Object>) spy(map1);
when(mock1.remove(anyString())).then(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object object = invocation.getArguments()[0];
final Data key = nodeEngine.toData(object);
RemoveOperation operation = new RemoveOperation(mapName, key);
int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
operation.setThreadId(ThreadUtil.getThreadId());
OperationService operationService = nodeEngine.getOperationService();
InternalCompletableFuture<Data> f = operationService.createInvocationBuilder(SERVICE_NAME, operation, partitionId).setResultDeserialized(false).invoke();
Data result = f.get();
return nodeEngine.toObject(result);
}
});
mock1.put(key, value);
mock1.remove(key);
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertNull(map1.get(key));
assertNull(map2.get(key));
}
}, 30);
}
Aggregations