Search in sources :

Example 11 with RaftNodeImpl

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

the class LocalRaftGroup method getLeaderEndpoint.

public RaftEndpoint getLeaderEndpoint() {
    RaftEndpoint leader = null;
    for (int i = 0; i < size(); i++) {
        if (integrations[i].isShutdown()) {
            continue;
        }
        RaftNodeImpl node = nodes[i];
        RaftEndpoint endpoint = getLeaderMember(node);
        if (leader == null) {
            leader = endpoint;
        } else if (!leader.equals(endpoint)) {
            throw new AssertionError("Group doesn't have a single leader endpoint yet!");
        }
    }
    return leader;
}
Also used : RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint)

Example 12 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(InstallSnapshot request, RaftEndpoint target) {
    assertNotEquals(localEndpoint, target);
    RaftNodeImpl node = nodes.get(target);
    if (node == null) {
        return false;
    }
    if (shouldDrop(request, target)) {
        return true;
    }
    node.handleInstallSnapshot(alterMessageIfNeeded(request, target));
    return true;
}
Also used : RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)

Example 13 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(AppendFailureResponse 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 14 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(PreVoteResponse response, RaftEndpoint target) {
    assertNotEquals(localEndpoint, target);
    RaftNodeImpl node = nodes.get(target);
    if (node == null) {
        return false;
    }
    if (shouldDrop(response, target)) {
        return true;
    }
    node.handlePreVoteResponse(alterMessageIfNeeded(response, target));
    return true;
}
Also used : RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)

Example 15 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(VoteResponse response, RaftEndpoint target) {
    assertNotEquals(localEndpoint, target);
    RaftNodeImpl node = nodes.get(target);
    if (node == null) {
        return false;
    }
    if (shouldDrop(response, target)) {
        return true;
    }
    node.handleVoteResponse(alterMessageIfNeeded(response, 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