use of org.neo4j.cluster.protocol.atomicbroadcast.AtomicBroadcast in project neo4j by neo4j.
the class MultiPaxosTest method testFailure.
@Test
public void testFailure() throws Exception {
ScriptableNetworkFailureLatencyStrategy networkLatency = new ScriptableNetworkFailureLatencyStrategy();
NetworkMock network = new NetworkMock(NullLogService.getInstance(), new Monitors(), 50, new MultipleFailureLatencyStrategy(networkLatency), new MessageTimeoutStrategy(new FixedTimeoutStrategy(1000)));
List<TestProtocolServer> nodes = new ArrayList<TestProtocolServer>();
TestProtocolServer server = network.addServer(1, URI.create("cluster://server1"));
server.newClient(Cluster.class).create("default");
network.tickUntilDone();
nodes.add(server);
for (int i = 1; i < 3; i++) {
TestProtocolServer protocolServer = network.addServer(i + 1, new URI("cluster://server" + (i + 1)));
protocolServer.newClient(Cluster.class).join("default", new URI("cluster://server1"));
network.tick(10);
nodes.add(protocolServer);
}
final AtomicBroadcast atomicBroadcast = nodes.get(0).newClient(AtomicBroadcast.class);
ObjectStreamFactory objectStreamFactory = new ObjectStreamFactory();
final AtomicBroadcastSerializer serializer = new AtomicBroadcastSerializer(objectStreamFactory, objectStreamFactory);
atomicBroadcast.broadcast(serializer.broadcast(new DaPayload()));
networkLatency.nodeIsDown("cluster://server2");
networkLatency.nodeIsDown("cluster://server3");
atomicBroadcast.broadcast(serializer.broadcast(new DaPayload()));
network.tick(100);
networkLatency.nodeIsUp("cluster://server3");
network.tick(1000);
for (TestProtocolServer node : nodes) {
node.newClient(Cluster.class).leave();
network.tick(10);
}
}
Aggregations