Package net.kuujo.copycat.protocol

Examples of net.kuujo.copycat.protocol.LocalProtocol


  /**
   * Creates a cluster of uniquely named CopyCat contexts.
   */
  protected Set<Copycat> createCluster(int numInstances) {
    LocalProtocol protocol = new LocalProtocol();
    Set<Copycat> instances = new HashSet<>(numInstances);
    for (int i = 1; i <= numInstances; i++) {
      LocalClusterConfig config = new LocalClusterConfig();
      config.setLocalMember(String.valueOf(i));
      for (int j = 1; j <= numInstances; j++) {
View Full Code Here


  /**
   * Tests that the leader's expanded configuration is logged and replicated.
   */
  public void testLeaderReplicatesExpandedConfiguration() {
    Protocol<Member> protocol = new LocalProtocol();
    TestCluster cluster = new TestCluster();
    TestNode node1 = new TestNode()
      .withCluster("foo", "bar", "baz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

  /**
   * Tests that the leader's reduced cluster configuration is logged and replicated.
   */
  public void testLeaderReplicatesReducedConfiguration() {
    Protocol<Member> protocol = new LocalProtocol();
    TestCluster cluster = new TestCluster();
    TestNode node1 = new TestNode()
      .withCluster("foo", "bar", "baz", "foobarbaz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

  /**
   * Tests that a leader is elected in a single-node cluster.
   */
  public void testSingleNodeClusterLeaderIsElected() {
    Protocol<Member> protocol = new LocalProtocol();
    TestCluster cluster = new TestCluster();
    TestNode node1 = new TestNode().withCluster("foo").withProtocol(protocol);
    cluster.addNode(node1);
    cluster.start();
    node1.await().electedLeader();
View Full Code Here

  /**
   * Tests that a leader is elected in a double-node cluster.
   */
  public void testTwoNodeClusterLeaderIsElected() {
    Protocol<Member> protocol = new LocalProtocol();
    TestCluster cluster = new TestCluster();
    TestNode node1 = new TestNode().withCluster("foo", "bar").withProtocol(protocol);
    cluster.addNode(node1);
    TestNode node2 = new TestNode().withCluster("bar", "foo").withProtocol(protocol);
    cluster.addNode(node2);
View Full Code Here

  /**
   * Tests that a leader is elected in a triple-node cluster.
   */
  public void testThreeNodeClusterLeaderIsElected() {
    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);
View Full Code Here

  /**
   * Tests that the candidate with the most up-to-date log is elected on startup.
   */
  public void testCandidateWithMostUpToDateLogIsElectedOnStartup() {
    Protocol<Member> protocol = new LocalProtocol();
    TestCluster cluster = new TestCluster();
    TestNode node1 = new TestNode()
      .withCluster("foo", "bar", "baz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

  /**
   * Test candidate with most up-to-date log elected after failure.
   */
  public void testCandidateWithMostUpToDateLogIsElectedAfterFailure() {
    Protocol<Member> protocol = new LocalProtocol();
    TestCluster cluster = new TestCluster();
    TestNode node1 = new TestNode()
      .withCluster("foo", "bar", "baz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

  /**
   * Tests that candidates restart an election during a split vote.
   */
  public void testCandidatesIncrementTermAndRestartElectionDuringSplitVote() {
    Protocol<Member> protocol = new LocalProtocol();
    TestCluster cluster = new TestCluster();
    TestNode node1 = new TestNode()
      .withCluster("foo", "bar", "baz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

  /**
   * Tests that only a single leader is elected when more than one node is equal in terms of state.
   */
  public void testThatOneLeaderElectedWhenTwoNodesAreEqual() {
    Protocol<Member> protocol = new LocalProtocol();
    TestCluster cluster = new TestCluster();
    TestNode node1 = new TestNode()
      .withCluster("foo", "bar", "baz", "foobar", "barbaz")
      .withProtocol(protocol)
      .withTerm(3)
View Full Code Here

TOP

Related Classes of net.kuujo.copycat.protocol.LocalProtocol

Copyright © 2018 www.massapicom. 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.