Search in sources :

Example 1 with RaftMembershipManager

use of org.neo4j.causalclustering.core.consensus.membership.RaftMembershipManager in project neo4j by neo4j.

the class RaftMachineBuilder method build.

public RaftMachine build() {
    SendToMyself leaderOnlyReplicator = new SendToMyself(member, outbound);
    RaftMembershipManager membershipManager = new RaftMembershipManager(leaderOnlyReplicator, memberSetBuilder, raftLog, logProvider, expectedClusterSize, electionTimeout, clock, catchupTimeout, raftMembership);
    membershipManager.setRecoverFromIndexSupplier(() -> 0);
    RaftLogShippingManager logShipping = new RaftLogShippingManager(outbound, logProvider, raftLog, shippingClock, member, membershipManager, retryTimeMillis, catchupBatchSize, maxAllowedShippingLag, inFlightMap);
    RaftMachine raft = new RaftMachine(member, termState, voteState, raftLog, electionTimeout, heartbeatInterval, renewableTimeoutService, outbound, logProvider, membershipManager, logShipping, inFlightMap, false, monitors, clock);
    inbound.registerHandler((incomingMessage) -> {
        try {
            ConsensusOutcome outcome = raft.handle(incomingMessage);
            commitListener.notifyCommitted(outcome.getCommitIndex());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
    try {
        membershipManager.start();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return raft;
}
Also used : RaftMembershipManager(org.neo4j.causalclustering.core.consensus.membership.RaftMembershipManager) IOException(java.io.IOException) SendToMyself(org.neo4j.causalclustering.core.replication.SendToMyself) RaftLogShippingManager(org.neo4j.causalclustering.core.consensus.shipping.RaftLogShippingManager) ConsensusOutcome(org.neo4j.causalclustering.core.consensus.outcome.ConsensusOutcome)

Aggregations

IOException (java.io.IOException)1 RaftMembershipManager (org.neo4j.causalclustering.core.consensus.membership.RaftMembershipManager)1 ConsensusOutcome (org.neo4j.causalclustering.core.consensus.outcome.ConsensusOutcome)1 RaftLogShippingManager (org.neo4j.causalclustering.core.consensus.shipping.RaftLogShippingManager)1 SendToMyself (org.neo4j.causalclustering.core.replication.SendToMyself)1