예제 #1
0
 @After
 public void tearDown() throws Exception {
   leader.cancel();
   followA.cancel();
   followB.cancel();
   followC.cancel();
 }
예제 #2
0
  @Test(timeout = 1000)
  public void testMultiCommit() throws Exception {
    log.trace("PaxosTest::testCommit()");

    serverL.run();
    serverA.run();
    serverB.run();
    serverC.run();

    long id1 = leader.addProposal(new NullOperation("one"));
    long id2 = leader.addProposal(new NullOperation("two"));
    long id3 = leader.addProposal(new NullOperation("three"));

    while (isProposalPending(id1) || isProposalPending(id2) || isProposalPending(id3)) {
      Thread.sleep(100);
    }
  }
예제 #3
0
  // TODO fix test
  // @Test(timeout = 1000)
  public void testCommitWithFailure() throws Exception {
    log.trace("PaxosTest::testCommit()");

    serverL.run();
    serverA.run();
    serverB.run();
    // C missing

    long id = leader.addProposal(new NullOperation("one"));

    while (followA.getProposal(id) == null
        || followA.getProposal(id).getState() != ProposalState.ACCEPTED
        || followB.getProposal(id) == null
        || followB.getProposal(id).getState() != ProposalState.ACCEPTED) {
      Thread.sleep(100);
    }
  }
예제 #4
0
  @Test(timeout = 1000)
  public void testOperationHanddown() throws Exception {
    log.trace("PaxosTest::testCommit()");

    serverL.run();
    serverA.run();
    serverB.run();
    serverC.run();

    long id = leader.addProposal(new NullOperation("one"));

    while (isProposalPending(id)) {
      Thread.sleep(100);
    }

    assertNotNull(followA.getProposal(id).getOperation());
    assertNotNull(followB.getProposal(id).getOperation());
    assertNotNull(followC.getProposal(id).getOperation());
  }