Package org.jgroups.raft.testfwk
Class RaftCluster
java.lang.Object
org.jgroups.raft.testfwk.MockRaftCluster
org.jgroups.raft.testfwk.RaftCluster
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 Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class org.jgroups.raft.testfwk.MockRaftCluster
async, interceptor, thread_pool -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends MockRaftCluster>
TAdd a new member to the cluster.<T extends MockRaftCluster>
Tclear()Remove all members from the cluster.clearDroppedTrafficTo(org.jgroups.Address a) booleandropTrafficTo(org.jgroups.Address a) voidhandleView(org.jgroups.View view) Emit the view update to all cluster members.protected static voidmove(org.jgroups.Address key, Map<org.jgroups.Address, RaftNode> from, Map<org.jgroups.Address, RaftNode> to) protected static void<T extends MockRaftCluster>
Tremove(org.jgroups.Address addr) Remove a member from the cluster.voidsend(org.jgroups.Message msg) Send a message in the cluster.voidsend(org.jgroups.Message msg, boolean async) intsize()The number of member in the cluster.toString()Methods inherited from class org.jgroups.raft.testfwk.MockRaftCluster
addCommandInterceptor, async, async, createThreadPool, deliverAsync, self
-
Field Details
-
nodes
-
dropped_members
-
-
Constructor Details
-
RaftCluster
public RaftCluster()
-
-
Method Details
-
add
Description copied from class:MockRaftClusterAdd 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:
addin classMockRaftCluster- Type Parameters:
T- : The current instance type.- Parameters:
addr- : The new member's address.node- : The member abstraction wrapped inRaftNode.- Returns:
- The fluent current class.
-
remove
Description copied from class:MockRaftClusterRemove a member from the cluster.A view update is necessary to propagate the member removal.
- Specified by:
removein classMockRaftCluster- Type Parameters:
T- : The current instance type.- Parameters:
addr- : The address of the member to remove.- Returns:
- The fluent current class.
-
clear
Description copied from class:MockRaftClusterRemove all members from the cluster.- Specified by:
clearin classMockRaftCluster- Type Parameters:
T- : The current instance type.- Returns:
- The fluent current class.
-
dropTraffic
public boolean dropTraffic() -
dropTrafficTo
-
clearDroppedTrafficTo
-
clearDroppedTraffic
-
handleView
public void handleView(org.jgroups.View view) Description copied from class:MockRaftClusterEmit 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:
handleViewin classMockRaftCluster- Parameters:
view- : The newViewinstance to update the member.
-
send
public void send(org.jgroups.Message msg) Description copied from class:MockRaftClusterSend a message in the cluster.- Specified by:
sendin classMockRaftCluster- Parameters:
msg- : Message to send.
-
size
public int size()Description copied from class:MockRaftClusterThe number of member in the cluster.- Specified by:
sizein classMockRaftCluster- Returns:
- The size of the cluster.
-
send
public void send(org.jgroups.Message msg, boolean async) -
toString
-
move
-
moveAll
-