Class 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 Detail

      • stubs

        protected final java.util.List<RouterStub> stubs
      • 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
      • 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
      • 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

      • reconnectorRunning

        public boolean reconnectorRunning()
      • heartbeaterRunning

        public boolean heartbeaterRunning()
      • timeouterRunning

        public boolean timeouterRunning()
      • nonBlockingSends

        public boolean nonBlockingSends()
      • maxSendQueue

        public int maxSendQueue()
      • 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 interface java.lang.Runnable
      • 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()