Package net.kuujo.copycat.test

Examples of net.kuujo.copycat.test.TestCluster.addNode()


    Protocol<Member> protocol = new LocalProtocol();
    TestCluster cluster = new TestCluster();
    TestNode node1 = new TestNode().withCluster("foo", "bar", "baz").withProtocol(protocol);
    cluster.addNode(node1);
    TestNode node2 = new TestNode().withCluster("bar", "foo", "baz").withProtocol(protocol);
    cluster.addNode(node2);
    TestNode node3 = new TestNode().withCluster("baz", "foo", "bar").withProtocol(protocol);
    cluster.addNode(node3);
    cluster.start();
    node1.await().leaderElected();
    Assert.assertTrue(node1.instance().isLeader() || node2.instance().isLeader() || node3.instance().isLeader());
View Full Code Here


    TestNode node1 = new TestNode().withCluster("foo", "bar", "baz").withProtocol(protocol);
    cluster.addNode(node1);
    TestNode node2 = new TestNode().withCluster("bar", "foo", "baz").withProtocol(protocol);
    cluster.addNode(node2);
    TestNode node3 = new TestNode().withCluster("baz", "foo", "bar").withProtocol(protocol);
    cluster.addNode(node3);
    cluster.start();
    node1.await().leaderElected();
    Assert.assertTrue(node1.instance().isLeader() || node2.instance().isLeader() || node3.instance().isLeader());
    cluster.stop();
  }
View Full Code Here

        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz")))
        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz"))))
      .withState(CopycatState.CANDIDATE)
      .withCommitIndex(6)
      .withLastApplied(6);
    cluster.addNode(node1);

    TestNode node2 = new TestNode()
      .withCluster("bar", "foo", "baz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

        .withEntry(new OperationEntry(1, "foo", Arrays.asList("bar", "baz")))
        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz"))))
      .withState(CopycatState.CANDIDATE)
      .withCommitIndex(5)
      .withLastApplied(5);
    cluster.addNode(node2);

    cluster.start();

    node1.await().electedLeader();
    Assert.assertTrue(node1.instance().isLeader());
View Full Code Here

        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz"))))
      .withState(CopycatState.FOLLOWER)
      .withCommitIndex(5)
      .withLastApplied(5)
      .withVotedFor(null);
    cluster.addNode(node1);

    TestNode node2 = new TestNode()
      .withCluster("bar", "foo", "baz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz"))))
      .withState(CopycatState.FOLLOWER)
      .withCommitIndex(6)
      .withLastApplied(6)
      .withVotedFor(null);
    cluster.addNode(node2);

    cluster.start();

    node2.await().electedLeader();
    Assert.assertTrue(node2.instance().isLeader());
View Full Code Here

        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz"))))
      .withState(CopycatState.CANDIDATE)
      .withCommitIndex(6)
      .withLastApplied(6)
      .withVotedFor("foo");
    cluster.addNode(node1);

    TestNode node2 = new TestNode()
      .withCluster("bar", "foo", "baz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz"))))
      .withState(CopycatState.CANDIDATE)
      .withCommitIndex(5)
      .withLastApplied(5)
      .withVotedFor("bar");
    cluster.addNode(node2);

    cluster.start();

    node1.await().electedLeader();
    Assert.assertTrue(node1.instance().isLeader());
View Full Code Here

        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz")))
        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz"))))
      .withState(CopycatState.FOLLOWER)
      .withCommitIndex(6)
      .withLastApplied(6);
    cluster.addNode(node1);

    TestNode node2 = new TestNode()
      .withCluster("bar", "foo", "baz", "foobar", "barbaz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz")))
        .withEntry(new OperationEntry(2, "foo", Arrays.asList("bar", "baz"))))
      .withState(CopycatState.FOLLOWER)
      .withCommitIndex(6)
      .withLastApplied(6);
    cluster.addNode(node2);

    TestNode node3 = new TestNode()
      .withCluster("baz", "bar", "foo", "foobar", "barbaz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.