private static void disableBundling(JChannel ch) {
   ProtocolStack stack = ch.getProtocolStack();
   TP transport = stack.getTransport();
   if (transport != null) {
     transport.setEnableBundling(false);
   }
 }
Пример #2
0
 protected TimeScheduler getTimer() {
   if (prot_stack != null) {
     TP transport = prot_stack.getTransport();
     if (transport != null) return transport.getTimer();
   }
   return null;
 }
Пример #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 stopStack(boolean stop, boolean destroy) {
    if (prot_stack != null) {
      try {
        if (stop) prot_stack.stopStack(cluster_name);

        if (destroy) prot_stack.destroy();
      } catch (Exception e) {
        log.error(Util.getMessage("StackDestroyFailure"), e);
      }

      TP transport = prot_stack.getTransport();
      if (transport != null) transport.unregisterProbeHandler(probe_handler);
    }
  }
Пример #5
0
  protected void startStack(String cluster_name) throws Exception {
    /*make sure the channel is not closed*/
    checkClosed();

    /*make sure we have a valid channel name*/
    if (cluster_name == null) log.debug("cluster_name is null, assuming unicast channel");
    else this.cluster_name = cluster_name;

    if (socket_factory != null) prot_stack.getTopProtocol().setSocketFactory(socket_factory);

    prot_stack.startStack(
        cluster_name, local_addr); // calls start() in all protocols, from top to bottom

    /*create a temporary view, assume this channel is the only member and is the coordinator*/
    List<Address> t = new ArrayList<>(1);
    t.add(local_addr);
    my_view = new View(local_addr, 0, t); // create a dummy view

    TP transport = prot_stack.getTransport();
    transport.registerProbeHandler(probe_handler);
  }
Пример #6
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");
      }
    }