Package org.jgroups.stack
Class RouterStubManager
- java.lang.Object
-
- org.jgroups.stack.RouterStubManager
-
- All Implemented Interfaces:
java.lang.Runnable
,RouterStub.CloseListener
public class RouterStubManager extends java.lang.Object implements java.lang.Runnable, RouterStub.CloseListener
Manages a list of RouterStubs (e.g. health checking, reconnecting).- Author:
- Vladimir Blagojevic, Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Runnable
check_timeouts
protected java.lang.String
cluster_name
protected long
heartbeat_interval
protected java.util.concurrent.Future<?>
heartbeat_task
protected long
heartbeat_timeout
protected Address
local_addr
protected Log
log
protected java.lang.String
logical_name
protected int
max_send_queue
protected boolean
non_blocking_sends
protected PhysicalAddress
phys_addr
protected long
reconnect_interval
protected java.util.concurrent.Future<?>
reconnector_task
protected java.lang.Runnable
send_heartbeat
protected SocketFactory
socket_factory
protected java.util.List<RouterStub>
stubs
protected java.util.concurrent.Future<?>
timeout_checker_task
protected TimeScheduler
timer
protected boolean
use_nio
-
Constructor Summary
Constructors Constructor Description RouterStubManager(Log log, TimeScheduler timer, java.lang.String cluster_name, Address local_addr, java.lang.String logical_name, PhysicalAddress phys_addr, long reconnect_interval)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkTimeouts()
void
closed(RouterStub stub)
int
connectedStubs()
void
connectStubs()
RouterStub
createAndRegisterStub(java.net.InetSocketAddress local, java.net.InetSocketAddress router_addr)
RouterStub
createAndRegisterStub(java.net.InetSocketAddress local, java.net.InetSocketAddress router_addr, int linger)
void
destroyStubs()
boolean
disconnectedStubs()
void
disconnectStubs()
static RouterStubManager
emptyGossipClientStubManager(Log log, TimeScheduler timer)
protected RouterStub
findRandomConnectedStub()
void
forAny(java.util.function.Consumer<RouterStub> action)
Applies action to a randomly picked RouterStub that's connectedvoid
forEach(java.util.function.Consumer<RouterStub> action)
Applies action to all connected RouterStubsRouterStubManager
heartbeat(long heartbeat_interval, long heartbeat_timeout)
boolean
heartbeaterRunning()
int
maxSendQueue()
RouterStubManager
maxSendQueue(int s)
boolean
nonBlockingSends()
RouterStubManager
nonBlockingSends(boolean b)
java.lang.String
print()
java.lang.String
printReconnectList()
java.lang.String
printStubs()
boolean
reconnectorRunning()
void
run()
protected void
sendHeartbeat()
RouterStubManager
socketFactory(SocketFactory socket_factory)
protected void
startHeartbeatTask()
protected void
startReconnector()
protected void
startTimeoutChecker()
protected void
stopHeartbeatTask()
protected void
stopReconnector()
protected void
stopTimeoutChecker()
boolean
timeouterRunning()
RouterStub
unregisterStub(java.net.InetSocketAddress router_addr_sa)
RouterStubManager
useNio(boolean flag)
-
-
-
Field Detail
-
stubs
protected final java.util.List<RouterStub> stubs
-
timer
protected final TimeScheduler timer
-
cluster_name
protected final java.lang.String cluster_name
-
local_addr
protected final Address local_addr
-
logical_name
protected final java.lang.String logical_name
-
phys_addr
protected final PhysicalAddress phys_addr
-
reconnect_interval
protected final long reconnect_interval
-
use_nio
protected boolean use_nio
-
reconnector_task
protected java.util.concurrent.Future<?> reconnector_task
-
heartbeat_task
protected java.util.concurrent.Future<?> heartbeat_task
-
timeout_checker_task
protected java.util.concurrent.Future<?> timeout_checker_task
-
log
protected final Log log
-
socket_factory
protected SocketFactory socket_factory
-
heartbeat_interval
protected long heartbeat_interval
-
heartbeat_timeout
protected long heartbeat_timeout
-
send_heartbeat
protected final java.lang.Runnable send_heartbeat
-
check_timeouts
protected final java.lang.Runnable check_timeouts
-
non_blocking_sends
protected boolean non_blocking_sends
-
max_send_queue
protected int max_send_queue
-
-
Constructor Detail
-
RouterStubManager
public RouterStubManager(Log log, TimeScheduler timer, java.lang.String cluster_name, Address local_addr, java.lang.String logical_name, PhysicalAddress phys_addr, long reconnect_interval)
-
-
Method Detail
-
emptyGossipClientStubManager
public static RouterStubManager emptyGossipClientStubManager(Log log, TimeScheduler timer)
-
useNio
public RouterStubManager useNio(boolean flag)
-
reconnectorRunning
public boolean reconnectorRunning()
-
heartbeaterRunning
public boolean heartbeaterRunning()
-
timeouterRunning
public boolean timeouterRunning()
-
nonBlockingSends
public boolean nonBlockingSends()
-
nonBlockingSends
public RouterStubManager nonBlockingSends(boolean b)
-
maxSendQueue
public int maxSendQueue()
-
maxSendQueue
public RouterStubManager maxSendQueue(int s)
-
socketFactory
public RouterStubManager socketFactory(SocketFactory socket_factory)
-
heartbeat
public RouterStubManager heartbeat(long heartbeat_interval, long heartbeat_timeout)
-
forEach
public void forEach(java.util.function.Consumer<RouterStub> action)
Applies action to all connected RouterStubs
-
forAny
public void forAny(java.util.function.Consumer<RouterStub> action)
Applies action to a randomly picked RouterStub that's connected- Parameters:
action
-
-
createAndRegisterStub
public RouterStub createAndRegisterStub(java.net.InetSocketAddress local, java.net.InetSocketAddress router_addr)
-
createAndRegisterStub
public RouterStub createAndRegisterStub(java.net.InetSocketAddress local, java.net.InetSocketAddress router_addr, int linger)
-
unregisterStub
public RouterStub unregisterStub(java.net.InetSocketAddress router_addr_sa)
-
connectStubs
public void connectStubs()
-
disconnectStubs
public void disconnectStubs()
-
destroyStubs
public void destroyStubs()
-
printStubs
public java.lang.String printStubs()
-
printReconnectList
public java.lang.String printReconnectList()
-
print
public java.lang.String print()
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
closed
public void closed(RouterStub stub)
- Specified by:
closed
in interfaceRouterStub.CloseListener
-
startReconnector
protected void startReconnector()
-
stopReconnector
protected void stopReconnector()
-
startHeartbeatTask
protected void startHeartbeatTask()
-
stopHeartbeatTask
protected void stopHeartbeatTask()
-
startTimeoutChecker
protected void startTimeoutChecker()
-
stopTimeoutChecker
protected void stopTimeoutChecker()
-
findRandomConnectedStub
protected RouterStub findRandomConnectedStub()
-
sendHeartbeat
protected void sendHeartbeat()
-
checkTimeouts
protected void checkTimeouts()
-
connectedStubs
public int connectedStubs()
-
disconnectedStubs
public boolean disconnectedStubs()
-
-