예제 #1
0
 private boolean viewContains(View view, JChannel... channels) {
   boolean b = true;
   for (JChannel ch : channels) {
     b = b && view.containsMember(ch.getAddress());
   }
   return b;
 }
예제 #2
0
 private boolean checkViewSize(int expectedSize, JChannel... channels) {
   boolean b = true;
   for (JChannel ch : channels) {
     b = b && ch.getView().size() == expectedSize;
   }
   return b;
 }
예제 #3
0
 public void testSASLDigestMD5() throws Exception {
   a = createChannel("A", "DIGEST-MD5", "jack");
   b = createChannel("B", "DIGEST-MD5", "jack");
   a.connect("SaslTest");
   b.connect("SaslTest");
   assertTrue(b.isConnected());
 }
예제 #4
0
 private static JChannel findChannelByAddress(Address address, JChannel... channels) {
   for (JChannel ch : channels) {
     if (ch.getAddress().equals(address)) {
       return ch;
     }
   }
   return null;
 }
예제 #5
0
 @Test(expectedExceptions = SecurityException.class)
 public void testSASLDigestMD5Failure() throws Throwable {
   a = createChannel("A", "DIGEST-MD5", "jack");
   b = createChannel("B", "DIGEST-MD5", "jill");
   a.connect("SaslTest");
   try {
     b.connect("SaslTest");
   } catch (Exception e) {
     if (e.getCause() != null) throw e.getCause();
   }
 }
예제 #6
0
 public void testSASLDigestMD5Merge() throws Exception {
   a = createChannel("A", "DIGEST-MD5", "jack");
   b = createChannel("B", "DIGEST-MD5", "jack");
   a.connect("SaslTest");
   b.connect("SaslTest");
   assertTrue(b.isConnected());
   print(a, b);
   createPartitions(a, b);
   print(a, b);
   assertTrue(checkViewSize(1, a, b));
   dropDiscard(a, b);
   mergePartitions(a, b);
   for (int i = 0; i < 10 && !checkViewSize(2, a, b); i++) {
     Util.sleep(500);
   }
   assertTrue(viewContains(a.getView(), a, b));
   assertTrue(viewContains(b.getView(), a, b));
 }
예제 #7
0
 private static void mergePartitions(JChannel... channels) throws Exception {
   Membership membership = new Membership();
   for (JChannel ch : channels) {
     membership.add(ch.getAddress());
   }
   membership.sort();
   Address leaderAddress = membership.elementAt(0);
   JChannel leader = findChannelByAddress(leaderAddress, channels);
   GMS gms = (GMS) leader.getProtocolStack().findProtocol(GMS.class);
   gms.setLevel("trace");
   Map<Address, View> views = new HashMap<>();
   for (JChannel ch : channels) {
     views.put(ch.getAddress(), ch.getView());
   }
   gms.up(new Event(Event.MERGE, views));
 }
예제 #8
0
  private static void createPartitions(JChannel... channels) throws Exception {
    for (JChannel ch : channels) {
      DISCARD discard = new DISCARD();
      discard.setDiscardAll(true);
      ch.getProtocolStack().insertProtocol(discard, ProtocolStack.Position.ABOVE, TP.class);
    }

    for (JChannel ch : channels) {
      View view = View.create(ch.getAddress(), 10, ch.getAddress());
      GMS gms = (GMS) ch.getProtocolStack().findProtocol(GMS.class);
      gms.installView(view);
    }
  }
예제 #9
0
 private void dropDiscard(JChannel... channels) {
   for (JChannel ch : channels) {
     ch.getProtocolStack().removeProtocol(DISCARD.class);
   }
 }
예제 #10
0
 private static void print(JChannel... channels) {
   for (JChannel ch : channels) {
     System.out.println(ch.getName() + ": " + ch.getView());
   }
 }
예제 #11
0
 @AfterMethod
 public void cleanup() {
   a.close();
   b.close();
 }