Пример #1
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);
    }
  }
Пример #2
0
 private boolean viewContains(View view, JChannel... channels) {
   boolean b = true;
   for (JChannel ch : channels) {
     b = b && view.containsMember(ch.getAddress());
   }
   return b;
 }
Пример #3
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));
 }
Пример #4
0
 private static JChannel findChannelByAddress(Address address, JChannel... channels) {
   for (JChannel ch : channels) {
     if (ch.getAddress().equals(address)) {
       return ch;
     }
   }
   return null;
 }