Package org.jgroups.stack
Class DiagnosticsHandler
- java.lang.Object
-
- org.jgroups.blocks.cs.ReceiverAdapter
-
- org.jgroups.stack.DiagnosticsHandler
-
- All Implemented Interfaces:
Receiver
public class DiagnosticsHandler extends ReceiverAdapter
- 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.util.List<java.net.NetworkInterface>
bind_interfaces
protected java.net.InetAddress
diagnostics_addr
protected java.net.InetAddress
diagnostics_bind_addr
protected int
diagnostics_port
protected int
diagnostics_port_range
protected java.util.Set<DiagnosticsHandler.ProbeHandler>
handlers
protected Log
log
protected java.lang.String
passcode
protected SocketFactory
socket_factory
protected java.net.ServerSocket
srv_sock
protected boolean
tcp_enabled
protected Runner
tcp_runner
static java.lang.String
TCP_THREAD_NAME
protected ThreadFactory
thread_factory
protected TP
transport
protected int
ttl
protected boolean
udp_enabled
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(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)
DiagnosticsHandler(java.net.InetAddress diagnostics_addr, int diagnostics_port, Log log, SocketFactory socket_factory, ThreadFactory thread_factory)
DiagnosticsHandler(java.net.InetAddress diagnostics_addr, int diagnostics_port, Log log, SocketFactory socket_factory, ThreadFactory thread_factory, java.lang.String passcode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
authorizeProbeRequest(java.net.DatagramPacket packet)
Performs authorization on given DatagramPacket.protected void
bindToInterfaces(java.util.List<java.net.NetworkInterface> interfaces, java.net.MulticastSocket s)
protected java.lang.String
defaultHeaders()
DiagnosticsHandler
enableTcp(boolean f)
DiagnosticsHandler
enableUdp(boolean f)
java.net.InetAddress
getDiagnosticsBindAddress()
int
getDiagnosticsPortRange()
java.util.Set<DiagnosticsHandler.ProbeHandler>
getProbeHandlers()
protected void
handleDiagnosticProbe(java.net.SocketAddress sender, java.lang.String request, java.util.function.BiConsumer<java.net.SocketAddress,java.lang.String> rsp_sender)
boolean
isRunning()
void
registerProbeHandler(DiagnosticsHandler.ProbeHandler handler)
protected void
runTCP()
protected void
runUDP()
protected boolean
sameCluster(java.lang.String req)
protected void
sendResponse(java.net.DatagramSocket sock, java.net.SocketAddress sender, byte[] buf)
DiagnosticsHandler
setDiagnosticsBindAddress(java.net.InetAddress a)
DiagnosticsHandler
setDiagnosticsPortRange(int r)
DiagnosticsHandler
setThreadNames()
void
start()
protected DiagnosticsHandler
startTCP()
protected DiagnosticsHandler
startUDP()
void
stop()
boolean
tcpEnabled()
TP
transport()
DiagnosticsHandler
transport(TP tp)
boolean
udpEnabled()
void
unregisterProbeHandler(DiagnosticsHandler.ProbeHandler handler)
DiagnosticsHandler
unsetThreadNames()
-
Methods inherited from class org.jgroups.blocks.cs.ReceiverAdapter
receive, receive, 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
-
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
-
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
-
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()
-
transport
public DiagnosticsHandler transport(TP tp)
-
setDiagnosticsBindAddress
public DiagnosticsHandler setDiagnosticsBindAddress(java.net.InetAddress a)
-
getDiagnosticsBindAddress
public java.net.InetAddress getDiagnosticsBindAddress()
-
udpEnabled
public boolean udpEnabled()
-
enableUdp
public DiagnosticsHandler enableUdp(boolean f)
-
tcpEnabled
public boolean tcpEnabled()
-
enableTcp
public DiagnosticsHandler enableTcp(boolean f)
-
getDiagnosticsPortRange
public int getDiagnosticsPortRange()
-
setDiagnosticsPortRange
public DiagnosticsHandler setDiagnosticsPortRange(int r)
-
setThreadNames
public DiagnosticsHandler setThreadNames()
-
unsetThreadNames
public DiagnosticsHandler unsetThreadNames()
-
getProbeHandlers
public java.util.Set<DiagnosticsHandler.ProbeHandler> getProbeHandlers()
-
registerProbeHandler
public void registerProbeHandler(DiagnosticsHandler.ProbeHandler handler)
-
unregisterProbeHandler
public void unregisterProbeHandler(DiagnosticsHandler.ProbeHandler handler)
-
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)
-
-