Class DiagnosticsHandler

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, Receiver

    public class DiagnosticsHandler
    extends ReceiverAdapter
    implements java.io.Closeable
    Since:
    3.0
    Author:
    Bela Ban
    • Field Detail

      • enabled

        protected boolean enabled
      • enable_udp

        protected volatile boolean enable_udp
      • enable_tcp

        protected volatile boolean enable_tcp
      • mcast_addr

        protected java.net.InetAddress mcast_addr
      • port

        protected int port
      • bind_addr

        protected java.net.InetAddress bind_addr
      • port_range

        protected int port_range
      • ttl

        protected int ttl
      • bind_interfaces

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

        protected java.lang.String passcode
      • 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
      • log

        protected final Log log
      • print_headers

        protected java.util.function.Function<java.lang.Boolean,​java.lang.String> print_headers
      • same_cluster

        protected java.util.function.Function<java.lang.String,​java.lang.Boolean> same_cluster
      • udp_response_sender

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

      • DiagnosticsHandler

        public DiagnosticsHandler()
                           throws java.lang.Exception
        Constructor used for standalone apps (without a JGroups stack)
        Throws:
        java.lang.Exception
    • Method Detail

      • printHeaders

        public DiagnosticsHandler printHeaders​(java.util.function.Function<java.lang.Boolean,​java.lang.String> f)
      • sameCluster

        public DiagnosticsHandler sameCluster​(java.util.function.Function<java.lang.String,​java.lang.Boolean> f)
      • isEnabled

        public boolean isEnabled()
      • getMcastAddress

        public java.net.InetAddress getMcastAddress()
      • getBindAddress

        public java.net.InetAddress getBindAddress()
      • udpEnabled

        public boolean udpEnabled()
      • tcpEnabled

        public boolean tcpEnabled()
      • getPort

        public int getPort()
      • getPortRange

        public int getPortRange()
      • getTtl

        public int getTtl()
      • getPasscode

        public java.lang.String getPasscode()
      • getBindInterfaces

        public java.util.List<java.net.NetworkInterface> getBindInterfaces()
      • setBindInterfaces

        public DiagnosticsHandler setBindInterfaces​(java.util.List<java.net.NetworkInterface> l)
      • start

        public DiagnosticsHandler start()
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • isRunning

        public boolean isRunning()
      • getLocalAddress

        public java.net.SocketAddress getLocalAddress()
        Returns the local datagram socket address (UDP) or the srv address (TCP)
      • 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)
      • 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)
      • isCompatible

        protected static boolean isCompatible​(java.net.InetAddress addr,
                                              java.util.List<java.net.InterfaceAddress> addrs)
        Checks if there's any address in the address list that's compatible (same address family) to addr