Class DiagnosticsHandler

  • All Implemented Interfaces:
    Receiver

    public class DiagnosticsHandler
    extends ReceiverAdapter
    Since:
    3.0
    Author:
    Bela Ban
    • Field Detail

      • transport

        protected TP transport
      • udp_enabled

        protected volatile boolean udp_enabled
      • tcp_enabled

        protected volatile boolean tcp_enabled
      • srv_sock

        protected java.net.ServerSocket srv_sock
      • udp_runner

        protected Runner udp_runner
      • tcp_runner

        protected Runner tcp_runner
      • udp_mcast_sock

        protected java.net.MulticastSocket udp_mcast_sock
      • udp_ucast_sock

        protected java.net.DatagramSocket udp_ucast_sock
      • diagnostics_addr

        protected java.net.InetAddress diagnostics_addr
      • diagnostics_bind_addr

        protected java.net.InetAddress diagnostics_bind_addr
      • diagnostics_port

        protected int diagnostics_port
      • diagnostics_port_range

        protected int diagnostics_port_range
      • ttl

        protected int ttl
      • bind_interfaces

        protected java.util.List<java.net.NetworkInterface> bind_interfaces
      • log

        protected final Log log
      • passcode

        protected final java.lang.String passcode
      • udp_response_sender

        protected final java.util.function.BiConsumer<java.net.SocketAddress,​java.lang.String> udp_response_sender
    • Constructor Detail

      • DiagnosticsHandler

        public DiagnosticsHandler​(java.net.InetAddress diagnostics_addr,
                                  int diagnostics_port,
                                  Log log,
                                  SocketFactory socket_factory,
                                  ThreadFactory thread_factory)
      • DiagnosticsHandler

        public DiagnosticsHandler​(java.net.InetAddress diagnostics_addr,
                                  int diagnostics_port,
                                  Log log,
                                  SocketFactory socket_factory,
                                  ThreadFactory thread_factory,
                                  java.lang.String passcode)
      • DiagnosticsHandler

        public DiagnosticsHandler​(java.net.InetAddress diagnostics_addr,
                                  int diagnostics_port,
                                  java.util.List<java.net.NetworkInterface> bind_interfaces,
                                  int diagnostics_ttl,
                                  Log log,
                                  SocketFactory socket_factory,
                                  ThreadFactory thread_factory,
                                  java.lang.String passcode)
    • Method Detail

      • transport

        public TP transport()
      • setDiagnosticsBindAddress

        public DiagnosticsHandler setDiagnosticsBindAddress​(java.net.InetAddress a)
      • getDiagnosticsBindAddress

        public java.net.InetAddress getDiagnosticsBindAddress()
      • udpEnabled

        public boolean udpEnabled()
      • tcpEnabled

        public boolean tcpEnabled()
      • getDiagnosticsPortRange

        public int getDiagnosticsPortRange()
      • start

        public void start()
                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • stop

        public void stop()
      • isRunning

        public boolean isRunning()
      • runUDP

        protected void runUDP()
      • runTCP

        protected void runTCP()
      • startUDP

        protected DiagnosticsHandler startUDP()
                                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • startTCP

        protected DiagnosticsHandler startTCP()
                                       throws java.lang.Exception
        Throws:
        java.lang.Exception
      • handleDiagnosticProbe

        protected void handleDiagnosticProbe​(java.net.SocketAddress sender,
                                             java.lang.String request,
                                             java.util.function.BiConsumer<java.net.SocketAddress,​java.lang.String> rsp_sender)
      • defaultHeaders

        protected java.lang.String defaultHeaders()
      • sameCluster

        protected boolean sameCluster​(java.lang.String req)
      • authorizeProbeRequest

        protected int authorizeProbeRequest​(java.net.DatagramPacket packet)
                                     throws java.lang.Exception
        Performs authorization on given DatagramPacket.
        Parameters:
        packet - to authorize
        Returns:
        offset in DatagramPacket where request payload starts
        Throws:
        java.lang.Exception - thrown if passcode received from client does not match set passcode
      • sendResponse

        protected void sendResponse​(java.net.DatagramSocket sock,
                                    java.net.SocketAddress sender,
                                    byte[] buf)
      • bindToInterfaces

        protected void bindToInterfaces​(java.util.List<java.net.NetworkInterface> interfaces,
                                        java.net.MulticastSocket s)