Search in sources :

Example 16 with RaftLog

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

the class RaftStateTest method test_initialState.

@Test
public void test_initialState() {
    assertEquals(name, state.name());
    assertEquals(groupId, state.groupId());
    assertEquals(members.size(), state.memberCount());
    assertEquals(members, state.members());
    Collection<RaftEndpoint> remoteMembers = new HashSet<RaftEndpoint>(members);
    remoteMembers.remove(localMember);
    assertEquals(remoteMembers, state.remoteMembers());
    assertEquals(0, state.term());
    assertEquals(RaftRole.FOLLOWER, state.role());
    assertNull(state.leader());
    assertEquals(0, state.commitIndex());
    assertEquals(0, state.lastApplied());
    assertEquals(3, state.majority());
    assertNull(state.votedFor());
    assertNull(state.leaderState());
    assertNull(state.candidateState());
    RaftLog log = state.log();
    assertEquals(0, log.lastLogOrSnapshotIndex());
    assertEquals(0, log.lastLogOrSnapshotTerm());
}
Also used : TestRaftEndpoint(com.hazelcast.cp.internal.raft.impl.testing.TestRaftEndpoint) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint) HashSet(java.util.HashSet) RaftLog(com.hazelcast.cp.internal.raft.impl.log.RaftLog) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

RaftLog (com.hazelcast.cp.internal.raft.impl.log.RaftLog)16 LogEntry (com.hazelcast.cp.internal.raft.impl.log.LogEntry)11 RaftEndpoint (com.hazelcast.cp.internal.raft.impl.RaftEndpoint)6 RaftState (com.hazelcast.cp.internal.raft.impl.state.RaftState)6 DestroyRaftGroupCmd (com.hazelcast.cp.internal.raft.command.DestroyRaftGroupCmd)3 RaftGroupCmd (com.hazelcast.cp.internal.raft.command.RaftGroupCmd)3 UpdateRaftGroupMembersCmd (com.hazelcast.cp.internal.raft.impl.command.UpdateRaftGroupMembersCmd)3 StaleAppendRequestException (com.hazelcast.cp.exception.StaleAppendRequestException)2 AppendRequest (com.hazelcast.cp.internal.raft.impl.dto.AppendRequest)2 AppendSuccessResponse (com.hazelcast.cp.internal.raft.impl.dto.AppendSuccessResponse)2 InstallSnapshot (com.hazelcast.cp.internal.raft.impl.dto.InstallSnapshot)2 PreVoteRequest (com.hazelcast.cp.internal.raft.impl.dto.PreVoteRequest)2 PreVoteResponse (com.hazelcast.cp.internal.raft.impl.dto.PreVoteResponse)2 VoteResponse (com.hazelcast.cp.internal.raft.impl.dto.VoteResponse)2 FollowerState (com.hazelcast.cp.internal.raft.impl.state.FollowerState)2 LeaderState (com.hazelcast.cp.internal.raft.impl.state.LeaderState)2 QueryState (com.hazelcast.cp.internal.raft.impl.state.QueryState)2 RaftAlgorithmConfig (com.hazelcast.config.cp.RaftAlgorithmConfig)1 CPGroupId (com.hazelcast.cp.CPGroupId)1 CPMember (com.hazelcast.cp.CPMember)1