Search in sources :

Example 26 with RaftNodeImpl

use of com.hazelcast.cp.internal.raft.impl.RaftNodeImpl in project hazelcast by hazelcast.

the class HazelcastRaftTestSupport method getRandomFollowerInstance.

protected static HazelcastInstance getRandomFollowerInstance(HazelcastInstance[] instances, CPGroupId groupId) {
    RaftNodeImpl[] raftNodeRef = new RaftNodeImpl[1];
    assertTrueEventually(() -> {
        for (HazelcastInstance instance : instances) {
            RaftNodeImpl raftNode = getRaftNode(instance, groupId);
            if (raftNode != null) {
                raftNodeRef[0] = raftNode;
                return;
            }
        }
        fail();
    });
    RaftNodeImpl raftNode = raftNodeRef[0];
    waitUntilLeaderElected(raftNode);
    RaftEndpoint leaderEndpoint = getLeaderMember(raftNode);
    assertNotNull(leaderEndpoint);
    for (HazelcastInstance instance : instances) {
        CPMember cpMember = instance.getCPSubsystem().getLocalCPMember();
        if (cpMember != null && !cpMember.getUuid().equals(leaderEndpoint.getUuid())) {
            return instance;
        }
    }
    throw new AssertionError();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint) CPMember(com.hazelcast.cp.CPMember)

Example 27 with RaftNodeImpl

use of com.hazelcast.cp.internal.raft.impl.RaftNodeImpl in project hazelcast by hazelcast.

the class LocalRaftIntegration method send.

@Override
public boolean send(AppendSuccessResponse response, RaftEndpoint target) {
    assertNotEquals(localEndpoint, target);
    RaftNodeImpl node = nodes.get(target);
    if (node == null) {
        return false;
    }
    if (shouldDrop(response, target)) {
        return true;
    }
    node.handleAppendResponse(alterMessageIfNeeded(response, target));
    return true;
}
Also used : RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)

Example 28 with RaftNodeImpl

use of com.hazelcast.cp.internal.raft.impl.RaftNodeImpl in project hazelcast by hazelcast.

the class LocalRaftIntegration method send.

@Override
public boolean send(TriggerLeaderElection request, RaftEndpoint target) {
    assertNotEquals(localEndpoint, target);
    RaftNodeImpl node = nodes.get(target);
    if (node == null) {
        return false;
    }
    if (shouldDrop(request, target)) {
        return true;
    }
    node.handleTriggerLeaderElection(alterMessageIfNeeded(request, target));
    return true;
}
Also used : RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)

Example 29 with RaftNodeImpl

use of com.hazelcast.cp.internal.raft.impl.RaftNodeImpl in project hazelcast by hazelcast.

the class LocalRaftIntegration method discoverNode.

void discoverNode(RaftNodeImpl node) {
    assertNotEquals(localEndpoint, node.getLocalMember());
    RaftNodeImpl old = nodes.putIfAbsent(node.getLocalMember(), node);
    assertThat(old, anyOf(nullValue(), sameInstance(node)));
}
Also used : RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)

Example 30 with RaftNodeImpl

use of com.hazelcast.cp.internal.raft.impl.RaftNodeImpl in project hazelcast by hazelcast.

the class LocalRaftIntegration method send.

@Override
public boolean send(AppendRequest request, RaftEndpoint target) {
    assertNotEquals(localEndpoint, target);
    RaftNodeImpl node = nodes.get(target);
    if (node == null) {
        return false;
    }
    if (shouldDrop(request, target)) {
        return true;
    }
    node.handleAppendRequest(alterMessageIfNeeded(request, target));
    return true;
}
Also used : RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)

Aggregations

RaftNodeImpl (com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)38 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 RaftEndpoint (com.hazelcast.cp.internal.raft.impl.RaftEndpoint)17 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)14 Test (org.junit.Test)14 CPGroupId (com.hazelcast.cp.CPGroupId)9 CPMember (com.hazelcast.cp.CPMember)9 CPGroup (com.hazelcast.cp.CPGroup)8 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)7 QuickTest (com.hazelcast.test.annotation.QuickTest)7 SlowTest (com.hazelcast.test.annotation.SlowTest)7 ArrayList (java.util.ArrayList)5 Config (com.hazelcast.config.Config)4 MigrationEndpoint (com.hazelcast.internal.partition.MigrationEndpoint)4 TestHazelcastInstanceFactory.initOrCreateConfig (com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig)4 ResourceRegistry (com.hazelcast.cp.internal.datastructures.spi.blocking.ResourceRegistry)3 LogEntry (com.hazelcast.cp.internal.raft.impl.log.LogEntry)3 RaftStateStore (com.hazelcast.cp.internal.raft.impl.persistence.RaftStateStore)3 RestoreSnapshotOp (com.hazelcast.cp.internal.raftop.snapshot.RestoreSnapshotOp)3 List (java.util.List)3