示例#1
0
  public void testFlushWithCrashedParticipants() throws Exception {
    JChannel c1 = null;
    JChannel c2 = null;
    JChannel c3 = null;

    try {
      c1 = createChannel(true, 3, "C1");
      changeProps(c1);
      c1.connect("testFlushWithCrashedFlushCoordinator");

      c2 = createChannel(c1, "C2");
      changeProps(c2);
      c2.connect("testFlushWithCrashedFlushCoordinator");

      c3 = createChannel(c1, "C3");
      changeProps(c3);
      c3.connect("testFlushWithCrashedFlushCoordinator");

      // and then kill members other than flush coordinator
      Util.shutdown(c3);
      Util.shutdown(c1);

      // start flush
      Util.startFlush(c2);

      c2.stopFlush();
      Util.waitUntilAllChannelsHaveSameSize(10000, 500, c2);

      // cluster should not hang and one remaining member should have a correct view
      assertTrue("correct view size", c2.getView().size() == 1);
    } finally {
      Util.close(c3, c2, c1);
    }
  }
示例#2
0
  public void testFlushWithCrashedFlushCoordinator() throws Exception {
    JChannel a = null, b = null, c = null;
    try {
      a = createChannel(true, 3, "A");
      changeProps(a);
      a.connect("testFlushWithCrashedFlushCoordinator");

      b = createChannel(a, "B");
      changeProps(b);
      b.connect("testFlushWithCrashedFlushCoordinator");

      c = createChannel(a, "C");
      changeProps(c);
      c.connect("testFlushWithCrashedFlushCoordinator");

      System.out.println("shutting down flush coordinator B");
      b.down(new Event(Event.SUSPEND_BUT_FAIL)); // send out START_FLUSH and then return

      // now shut down B. This means, after failure detection kicks in and the new coordinator takes
      // over
      // (either A or C), that the current flush started by B will be cancelled and a new flush (by
      // A or C)
      // will be started
      Util.shutdown(b);

      a.getProtocolStack().findProtocol(FLUSH.class).setLevel("debug");
      c.getProtocolStack().findProtocol(FLUSH.class).setLevel("debug");

      Util.waitUntilAllChannelsHaveSameSize(10000, 500, a, c);

      // cluster should not hang and two remaining members should have a correct view
      assertTrue("correct view size", a.getView().size() == 2);
      assertTrue("correct view size", c.getView().size() == 2);

      a.getProtocolStack().findProtocol(FLUSH.class).setLevel("warn");
      c.getProtocolStack().findProtocol(FLUSH.class).setLevel("warn");

    } finally {
      Util.close(c, b, a);
    }
  }
示例#3
0
  public void testFlushWithCrashedParticipant() throws Exception {
    JChannel c1 = null;
    JChannel c2 = null;
    JChannel c3 = null;

    try {
      c1 = createChannel(true, 3, "C1");
      changeProps(c1);
      c1.connect("testFlushWithCrashedParticipant");

      c2 = createChannel(c1, "C2");
      changeProps(c2);
      c2.connect("testFlushWithCrashedParticipant");

      c3 = createChannel(c1, "C3");
      changeProps(c3);
      c3.connect("testFlushWithCrashedParticipant");

      System.out.println("shutting down C3");
      Util.shutdown(c3); // kill a flush participant

      System.out.println("C2: starting flush");
      boolean rc = Util.startFlush(c2);
      System.out.println("flush " + (rc ? " was successful" : "failed"));
      assert rc;

      System.out.println("stopping flush");
      c2.stopFlush();

      System.out.println("waiting for view to contain C1 and C2");
      Util.waitUntilAllChannelsHaveSameSize(10000, 500, c1, c2);

      // cluster should not hang and two remaining members should have a correct view
      System.out.println("C1: view=" + c1.getView() + "\nC2: view=" + c2.getView());
      assertTrue("correct view size", c1.getView().size() == 2);
      assertTrue("correct view size", c2.getView().size() == 2);
    } finally {
      Util.close(c3, c2, c1);
    }
  }
  public void testAndLoop() throws Exception {
    int numChannels = 10;
    Channel channels[] = new Channel[numChannels];
    for (int j = 0; j < numChannels; j++) {
      channels[j] = createChannel(String.valueOf((char) ('A' + j)));
      channels[j].connect(cName);
      if (j == 0) Util.sleep(1000);
    }
    Util.waitUntilAllChannelsHaveSameSize(10000, 500, channels);

    for (int i = 1; i <= 2; i++) {
      int killPositions[] = {0, 3, 5, 8};
      for (int index : killPositions) Util.shutdown(channels[index]);
      int ch = 'M';
      for (int index : killPositions) {
        channels[index] = createChannel(String.valueOf((char) ch++));
        channels[index].connect(cName);
      }
      System.out.println("***** Round " + i + " done *****");
    }
    Util.waitUntilAllChannelsHaveSameSize(10000, 500, channels);
  }