Package org.jgroups.stack
Class DiagnosticsHandler
- java.lang.Object
-
- org.jgroups.blocks.cs.ReceiverAdapter
-
- org.jgroups.stack.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
DiagnosticsHandler.ProbeHandler
-
Field Summary
Fields Modifier and Type Field Description protected java.net.InetAddress
bind_addr
protected java.util.List<java.net.NetworkInterface>
bind_interfaces
protected boolean
enable_tcp
protected boolean
enable_udp
protected boolean
enabled
protected java.util.Set<DiagnosticsHandler.ProbeHandler>
handlers
protected Log
log
protected java.net.InetAddress
mcast_addr
protected java.lang.String
passcode
protected int
port
protected int
port_range
protected java.util.function.Function<java.lang.Boolean,java.lang.String>
print_headers
protected java.util.function.Function<java.lang.String,java.lang.Boolean>
same_cluster
protected SocketFactory
socket_factory
protected java.net.ServerSocket
srv_sock
protected Runner
tcp_runner
static java.lang.String
TCP_THREAD_NAME
protected ThreadFactory
thread_factory
protected int
ttl
protected java.net.MulticastSocket
udp_mcast_sock
protected java.util.function.BiConsumer<java.net.SocketAddress,java.lang.String>
udp_response_sender
protected Runner
udp_runner
static java.lang.String
UDP_THREAD_NAME
protected java.net.DatagramSocket
udp_ucast_sock
-
Constructor Summary
Constructors Constructor Description DiagnosticsHandler()
Constructor used for standalone apps (without a JGroups stack)DiagnosticsHandler(Log log, SocketFactory socket_factory, ThreadFactory thread_factory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
authorizeProbeRequest(byte[] request)
Performs authorization on given byte arrayprotected void
bindToInterfaces(java.util.List<java.net.NetworkInterface> interfaces, java.net.MulticastSocket s)
void
close()
DiagnosticsHandler
enableTcp(boolean f)
DiagnosticsHandler
enableUdp(boolean f)
java.net.InetAddress
getBindAddress()
java.util.List<java.net.NetworkInterface>
getBindInterfaces()
java.net.SocketAddress
getLocalAddress()
Returns the local datagram socket address (UDP) or the srv address (TCP)java.net.InetAddress
getMcastAddress()
java.lang.String
getPasscode()
int
getPort()
int
getPortRange()
java.util.Set<DiagnosticsHandler.ProbeHandler>
getProbeHandlers()
int
getTtl()
protected void
handleDiagnosticProbe(java.net.SocketAddress sender, java.lang.String request, java.util.function.BiConsumer<java.net.SocketAddress,java.lang.String> rsp_sender)
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 addrboolean
isEnabled()
boolean
isRunning()
DiagnosticsHandler
printHeaders(java.util.function.Function<java.lang.Boolean,java.lang.String> f)
DiagnosticsHandler
registerProbeHandler(DiagnosticsHandler.ProbeHandler handler)
protected void
runTCP()
protected void
runUDP()
DiagnosticsHandler
sameCluster(java.util.function.Function<java.lang.String,java.lang.Boolean> f)
protected void
sendResponse(java.net.DatagramSocket sock, java.net.SocketAddress sender, byte[] buf)
DiagnosticsHandler
setBindAddress(java.net.InetAddress a)
DiagnosticsHandler
setBindInterfaces(java.util.List<java.net.NetworkInterface> l)
DiagnosticsHandler
setEnabled(boolean f)
DiagnosticsHandler
setMcastAddress(java.net.InetAddress a)
DiagnosticsHandler
setPasscode(java.lang.String d)
DiagnosticsHandler
setPort(int p)
DiagnosticsHandler
setPortRange(int r)
DiagnosticsHandler
setThreadNames()
DiagnosticsHandler
setTtl(int d)
DiagnosticsHandler
start()
protected DiagnosticsHandler
startTCP()
protected DiagnosticsHandler
startUDP()
DiagnosticsHandler
stop()
boolean
tcpEnabled()
boolean
udpEnabled()
DiagnosticsHandler
unregisterProbeHandler(DiagnosticsHandler.ProbeHandler handler)
DiagnosticsHandler
unsetThreadNames()
-
Methods inherited from class org.jgroups.blocks.cs.ReceiverAdapter
receive
-
-
-
-
Field Detail
-
UDP_THREAD_NAME
public static final java.lang.String UDP_THREAD_NAME
- See Also:
- Constant Field Values
-
TCP_THREAD_NAME
public static final java.lang.String TCP_THREAD_NAME
- See Also:
- Constant Field Values
-
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
-
handlers
protected final java.util.Set<DiagnosticsHandler.ProbeHandler> handlers
-
log
protected final Log log
-
socket_factory
protected final SocketFactory socket_factory
-
thread_factory
protected final ThreadFactory thread_factory
-
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
-
DiagnosticsHandler
public DiagnosticsHandler(Log log, SocketFactory socket_factory, ThreadFactory thread_factory)
-
-
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()
-
setEnabled
public DiagnosticsHandler setEnabled(boolean f)
-
setMcastAddress
public DiagnosticsHandler setMcastAddress(java.net.InetAddress a)
-
getMcastAddress
public java.net.InetAddress getMcastAddress()
-
setBindAddress
public DiagnosticsHandler setBindAddress(java.net.InetAddress a)
-
getBindAddress
public java.net.InetAddress getBindAddress()
-
udpEnabled
public boolean udpEnabled()
-
enableUdp
public DiagnosticsHandler enableUdp(boolean f)
-
tcpEnabled
public boolean tcpEnabled()
-
enableTcp
public DiagnosticsHandler enableTcp(boolean f)
-
getPort
public int getPort()
-
setPort
public DiagnosticsHandler setPort(int p)
-
getPortRange
public int getPortRange()
-
setPortRange
public DiagnosticsHandler setPortRange(int r)
-
getTtl
public int getTtl()
-
setTtl
public DiagnosticsHandler setTtl(int d)
-
getPasscode
public java.lang.String getPasscode()
-
setPasscode
public DiagnosticsHandler setPasscode(java.lang.String d)
-
getBindInterfaces
public java.util.List<java.net.NetworkInterface> getBindInterfaces()
-
setBindInterfaces
public DiagnosticsHandler setBindInterfaces(java.util.List<java.net.NetworkInterface> l)
-
setThreadNames
public DiagnosticsHandler setThreadNames()
-
unsetThreadNames
public DiagnosticsHandler unsetThreadNames()
-
getProbeHandlers
public java.util.Set<DiagnosticsHandler.ProbeHandler> getProbeHandlers()
-
registerProbeHandler
public DiagnosticsHandler registerProbeHandler(DiagnosticsHandler.ProbeHandler handler)
-
unregisterProbeHandler
public DiagnosticsHandler unregisterProbeHandler(DiagnosticsHandler.ProbeHandler handler)
-
start
public DiagnosticsHandler start() throws java.lang.Exception
- Throws:
java.lang.Exception
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
stop
public DiagnosticsHandler stop()
-
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(byte[] request) throws java.lang.Exception
Performs authorization on given byte array- Parameters:
request
- 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
-
-