Пример #1
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);
   }
 }
Пример #2
0
 private static void changeProperties(JChannel ch) {
   ch.setOpt(Channel.AUTO_RECONNECT, true);
   ProtocolStack stack = ch.getProtocolStack();
   GMS gms = (GMS) stack.findProtocol("GMS");
   if (gms != null) {
     gms.setViewBundling(true);
     gms.setMaxBundlingTime(300);
     gms.setPrintLocalAddr(false);
   }
   MERGE2 merge = (MERGE2) stack.findProtocol("MERGE2");
   if (merge != null) {
     merge.setMinInterval(2000);
     merge.setMaxInterval(5000);
   }
   VIEW_SYNC sync = (VIEW_SYNC) stack.findProtocol(VIEW_SYNC.class);
   if (sync != null) sync.setAverageSendInterval(5000);
   NAKACK nakack = (NAKACK) stack.findProtocol(NAKACK.class);
   if (nakack != null) nakack.setLogDiscardMsgs(false);
 }
Пример #3
0
 protected void discard(boolean flag, JChannel... channels) throws Exception {
   for (JChannel ch : channels) {
     ProtocolStack stack = ch.getProtocolStack();
     DISCARD discard = (DISCARD) stack.findProtocol(DISCARD.class);
     if (discard == null)
       stack.insertProtocol(
           discard = new DISCARD(), ProtocolStack.ABOVE, stack.getTransport().getClass());
     discard.setDiscardAll(flag);
   }
 }
Пример #4
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");
      }
    }