Exemple #1
0
  public void testMergeWithAsymetricViewsCoordIsolated() {
    // Isolate the coord
    Address coord = a.getView().getCreator();
    System.out.println("Isolating coord: " + coord);
    List<Address> members = new ArrayList<>();
    members.add(coord);
    View coord_view = new View(coord, 4, members);
    System.out.println("coord_view: " + coord_view);
    Channel coord_channel = findChannel(coord);
    System.out.println("coord_channel: " + coord_channel.getAddress());

    MutableDigest digest = new MutableDigest(coord_view.getMembersRaw());
    NAKACK2 nakack = (NAKACK2) coord_channel.getProtocolStack().findProtocol(NAKACK2.class);
    digest.merge(nakack.getDigest(coord));

    GMS gms = (GMS) coord_channel.getProtocolStack().findProtocol(GMS.class);
    gms.installView(coord_view, digest);
    System.out.println("gms.getView() " + gms.getView());

    System.out.println("Views are:");
    for (JChannel ch : Arrays.asList(a, b, c, d))
      System.out.println(ch.getAddress() + ": " + ch.getView());

    JChannel merge_leader = findChannel(coord);
    MyReceiver receiver = new MyReceiver();
    merge_leader.setReceiver(receiver);

    System.out.println("merge_leader: " + merge_leader.getAddressAsString());

    System.out.println("Injecting MERGE event into merge leader " + merge_leader.getAddress());
    Map<Address, View> merge_views = new HashMap<>(4);
    merge_views.put(a.getAddress(), a.getView());
    merge_views.put(b.getAddress(), b.getView());
    merge_views.put(c.getAddress(), c.getView());
    merge_views.put(d.getAddress(), d.getView());

    gms = (GMS) merge_leader.getProtocolStack().findProtocol(GMS.class);
    gms.up(new Event(Event.MERGE, merge_views));

    Util.waitUntilAllChannelsHaveSameSize(10000, 1000, a, b, c, d);

    System.out.println("Views are:");
    for (JChannel ch : Arrays.asList(a, b, c, d)) {
      View view = ch.getView();
      System.out.println(ch.getAddress() + ": " + view);
      assert view.size() == 4;
    }
    MergeView merge_view = receiver.getView();
    System.out.println("merge_view = " + merge_view);
    assert merge_view.size() == 4;
    assert merge_view.getSubgroups().size() == 2;

    for (View view : merge_view.getSubgroups())
      assert contains(view, a.getAddress())
          || contains(view, b.getAddress(), c.getAddress(), d.getAddress());
  }
Exemple #2
0
 private static void setStableGossip(JChannel... channels) {
   for (Channel channel : channels) {
     ProtocolStack stack = channel.getProtocolStack();
     STABLE stable = (STABLE) stack.findProtocol(STABLE.class);
     stable.setDesiredAverageGossip(2000);
   }
 }
Exemple #3
0
 private static void setOOBPoolSize(JChannel... channels) {
   for (Channel channel : channels) {
     TP transport = channel.getProtocolStack().getTransport();
     transport.setOOBThreadPoolMinThreads(1);
     transport.setOOBThreadPoolMaxThreads(2);
   }
 }
 public static DISCARD getDiscardForCache(Cache<?, ?> c) throws Exception {
   JGroupsTransport jgt = (JGroupsTransport) TestingUtil.extractComponent(c, Transport.class);
   Channel ch = jgt.getChannel();
   ProtocolStack ps = ch.getProtocolStack();
   DISCARD discard = new DISCARD();
   ps.insertProtocol(discard, ProtocolStack.ABOVE, TP.class);
   return discard;
 }
  public void stop() {
    if (corr != null) corr.stop();

    if (channel instanceof JChannel) {
      TP transport = channel.getProtocolStack().getTransport();
      transport.unregisterProbeHandler(probe_handler);
      corr.unregisterProbeHandler(transport);
    }
  }
 /**
  * Inserts a DELAY protocol in the JGroups stack used by the cache, and returns it. The DELAY
  * protocol can then be used to inject delays in milliseconds both at receiver and sending side.
  *
  * @param cache
  * @param in_delay_millis
  * @param out_delay_millis
  * @return a reference to the DELAY instance being used by the JGroups stack
  * @throws Exception
  */
 public static DELAY setDelayForCache(Cache<?, ?> cache, int in_delay_millis, int out_delay_millis)
     throws Exception {
   JGroupsTransport jgt = (JGroupsTransport) TestingUtil.extractComponent(cache, Transport.class);
   Channel ch = jgt.getChannel();
   ProtocolStack ps = ch.getProtocolStack();
   DELAY delay = new DELAY();
   delay.setInDelay(in_delay_millis);
   delay.setOutDelay(out_delay_millis);
   ps.insertProtocol(delay, ProtocolStack.ABOVE, TP.class);
   return delay;
 }
  public void start() {
    if (corr == null)
      corr =
          createRequestCorrelator(prot_adapter, this, local_addr)
              .asyncDispatching(async_dispatching);
    correlatorStarted();
    corr.start();

    if (channel != null) {
      List<Address> tmp_mbrs = channel.getView() != null ? channel.getView().getMembers() : null;
      setMembers(tmp_mbrs);
      if (channel instanceof JChannel) {
        TP transport = channel.getProtocolStack().getTransport();
        corr.registerProbeHandler(transport);
      }
      TP transport = channel.getProtocolStack().getTransport();
      hardware_multicast_supported = transport.supportsMulticasting();
      transport.registerProbeHandler(probe_handler);
    }
  }
Exemple #8
0
    protected void makeUnique(Channel channel, int num, String mcast_address) throws Exception {
      ProtocolStack stack = channel.getProtocolStack();
      Protocol transport = stack.getTransport();

      if (transport instanceof UDP) {
        short mcast_port = ResourceManager.getNextMulticastPort(InetAddress.getByName(bind_addr));
        ((UDP) transport).setMulticastPort(mcast_port);
        if (mcast_address != null) {
          ((UDP) transport).setMulticastAddress(InetAddress.getByName(mcast_address));
        } else {
          String mcast_addr = ResourceManager.getNextMulticastAddress();
          ((UDP) transport).setMulticastAddress(InetAddress.getByName(mcast_addr));
        }
      } else if (transport instanceof BasicTCP) {
        List<Integer> ports =
            ResourceManager.getNextTcpPorts(InetAddress.getByName(bind_addr), num);
        ((TP) transport).setBindPort(ports.get(0));
        // ((TP) transport).setPortRange(num);

        Protocol ping = stack.findProtocol(TCPPING.class);
        if (ping == null)
          throw new IllegalStateException(
              "TCP stack must consist of TCP:TCPPING - other config are not supported");

        List<String> initial_hosts =
            ports
                .stream()
                .map(port -> String.format("%s[%d]", bind_addr, port))
                .collect(Collectors.toList());
        String tmp = Util.printListWithDelimiter(initial_hosts, ",", 2000, false);
        List<PhysicalAddress> init_hosts = Util.parseCommaDelimitedHosts(tmp, 0);
        ((TCPPING) ping).setInitialHosts(init_hosts);
      } else {
        throw new IllegalStateException("Only UDP and TCP are supported as transport protocols");
      }
    }
 @Override
 public boolean isMulticastCapable() {
   return channel.getProtocolStack().getTransport().supportsMulticasting();
 }