Class PartitionedRaftCluster

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

public class PartitionedRaftCluster extends MockRaftCluster
Manipulate the cluster during tests.

This class offers the possibility of creating partitions in the cluster. The partitions are created by view updates.

Since:
1.0.12
Author:
José Bolina
  • Field Details

    • partitions

      protected final Map<org.jgroups.Address,List<org.jgroups.Address>> partitions
    • nodes

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

    • PartitionedRaftCluster

      public PartitionedRaftCluster()
  • Method Details

    • 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.
    • 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.
    • 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.
    • 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.