Class RaftCluster

java.lang.Object
org.jgroups.raft.testfwk.MockRaftCluster
org.jgroups.raft.testfwk.RaftCluster

public class RaftCluster extends MockRaftCluster
Orchestrates a number of RaftNode objects, to be used in a unit test, for example a leader and a follower.
Since:
1.0.5
Author:
Bela Ban
  • Field Details

    • nodes

      protected final Map<org.jgroups.Address,RaftNode> nodes
    • dropped_members

      protected final Map<org.jgroups.Address,RaftNode> dropped_members
  • Constructor Details

    • RaftCluster

      public RaftCluster()
  • Method Details

    • add

      public <T extends MockRaftCluster> T add(org.jgroups.Address addr, RaftNode node)
      Description copied from class: MockRaftCluster
      Add a new member to the cluster.

      The new member is associated with the given address. A member is resolved by the address when sending a message. Also, note that a view update is necessary to propagate the member addition.

      Specified by:
      add in class MockRaftCluster
      Type Parameters:
      T - : The current instance type.
      Parameters:
      addr - : The new member's address.
      node - : The member abstraction wrapped in RaftNode.
      Returns:
      The fluent current class.
    • remove

      public <T extends MockRaftCluster> T remove(org.jgroups.Address addr)
      Description copied from class: MockRaftCluster
      Remove a member from the cluster.

      A view update is necessary to propagate the member removal.

      Specified by:
      remove in class MockRaftCluster
      Type Parameters:
      T - : The current instance type.
      Parameters:
      addr - : The address of the member to remove.
      Returns:
      The fluent current class.
    • clear

      public <T extends MockRaftCluster> T clear()
      Description copied from class: MockRaftCluster
      Remove all members from the cluster.
      Specified by:
      clear in class MockRaftCluster
      Type Parameters:
      T - : The current instance type.
      Returns:
      The fluent current class.
    • dropTraffic

      public boolean dropTraffic()
    • dropTrafficTo

      public RaftCluster dropTrafficTo(org.jgroups.Address a)
    • clearDroppedTrafficTo

      public RaftCluster clearDroppedTrafficTo(org.jgroups.Address a)
    • clearDroppedTraffic

      public RaftCluster clearDroppedTraffic()
    • handleView

      public void handleView(org.jgroups.View view)
      Description copied from class: MockRaftCluster
      Emit the view update to all cluster members.

      How the view is updated might vary from implementation. The basic idea is to iterate over all members and invoke each protocol in the stack to handle the view.

      Specified by:
      handleView in class MockRaftCluster
      Parameters:
      view - : The new View instance to update the member.
    • send

      public void send(org.jgroups.Message msg)
      Description copied from class: MockRaftCluster
      Send a message in the cluster.
      Specified by:
      send in class MockRaftCluster
      Parameters:
      msg - : Message to send.
    • size

      public int size()
      Description copied from class: MockRaftCluster
      The number of member in the cluster.
      Specified by:
      size in class MockRaftCluster
      Returns:
      The size of the cluster.
    • send

      public void send(org.jgroups.Message msg, boolean async)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • move

      protected static void move(org.jgroups.Address key, Map<org.jgroups.Address,RaftNode> from, Map<org.jgroups.Address,RaftNode> to)
    • moveAll

      protected static void moveAll(Map<org.jgroups.Address,RaftNode> from, Map<org.jgroups.Address,RaftNode> to)