use of org.neo4j.causalclustering.core.consensus.explorer.ClusterState in project neo4j by neo4j.
the class DropMessage method advance.
@Override
public ClusterState advance(ClusterState previous) {
ClusterState newClusterState = new ClusterState(previous);
Queue<RaftMessages.RaftMessage> inboundQueue = new LinkedList<>(previous.queues.get(member));
RaftMessages.RaftMessage message = inboundQueue.poll();
if (message == null) {
return previous;
}
newClusterState.queues.put(member, inboundQueue);
return newClusterState;
}
use of org.neo4j.causalclustering.core.consensus.explorer.ClusterState in project neo4j by neo4j.
the class HeartbeatTimeout method advance.
@Override
public ClusterState advance(ClusterState previous) throws IOException {
ClusterState newClusterState = new ClusterState(previous);
Queue<RaftMessages.RaftMessage> newQueue = new LinkedList<>(previous.queues.get(member));
newQueue.offer(new RaftMessages.Timeout.Heartbeat(member));
newClusterState.queues.put(member, newQueue);
return newClusterState;
}
use of org.neo4j.causalclustering.core.consensus.explorer.ClusterState in project neo4j by neo4j.
the class OutOfOrderDelivery method advance.
@Override
public ClusterState advance(ClusterState previous) {
ClusterState newClusterState = new ClusterState(previous);
LinkedList<RaftMessages.RaftMessage> inboundQueue = new LinkedList<>(previous.queues.get(member));
if (inboundQueue.size() < 2) {
return previous;
}
RaftMessages.RaftMessage message = inboundQueue.poll();
inboundQueue.add(1, message);
newClusterState.queues.put(member, inboundQueue);
return newClusterState;
}
use of org.neo4j.causalclustering.core.consensus.explorer.ClusterState in project neo4j by neo4j.
the class NewEntry method advance.
@Override
public ClusterState advance(ClusterState previous) throws IOException {
ClusterState newClusterState = new ClusterState(previous);
Queue<RaftMessages.RaftMessage> newQueue = new LinkedList<>(previous.queues.get(member));
newQueue.offer(new RaftMessages.NewEntry.Request(member, new ReplicatedString("content")));
newClusterState.queues.put(member, newQueue);
return newClusterState;
}
use of org.neo4j.causalclustering.core.consensus.explorer.ClusterState in project neo4j by neo4j.
the class OutOfOrderDeliveryTest method shouldReOrder.
@Test
public void shouldReOrder() throws Exception {
// given
ClusterState clusterState = new ClusterState(asSet(member(0)));
clusterState.queues.get(member(0)).add(new Election(member(0)));
clusterState.queues.get(member(0)).add(new Heartbeat(member(0)));
// when
ClusterState reOrdered = new OutOfOrderDelivery(member(0)).advance(clusterState);
// then
assertEquals(new Heartbeat(member(0)), reOrdered.queues.get(member(0)).poll());
assertEquals(new Election(member(0)), reOrdered.queues.get(member(0)).poll());
}
Aggregations