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 etc.
    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
      • interval

        protected final long interval
      • use_nio

        protected boolean use_nio
      • reconnector_task

        protected java.util.concurrent.Future<?> reconnector_task
      • log

        protected final Log log
    • Constructor Detail

      • RouterStubManager

        public RouterStubManager​(Protocol owner,
                                 java.lang.String cluster_name,
                                 Address local_addr,
                                 java.lang.String logical_name,
                                 PhysicalAddress phys_addr,
                                 long interval)
    • Method Detail

      • forEach

        public void forEach​(java.util.function.Consumer<RouterStub> action)
        Applies action to all RouterStubs that are connected
        Parameters:
        action -
      • forAny

        public void forAny​(java.util.function.Consumer<RouterStub> action)
        Applies action to a randomly picked RouterStub that's connected
        Parameters:
        action -
      • 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
      • moveStubToReconnects

        protected void moveStubToReconnects​(RouterStub stub)
      • add

        protected boolean add​(RouterStub stub)
      • remove

        protected boolean remove​(RouterStub stub)
      • findRandomConnectedStub

        protected RouterStub findRandomConnectedStub()
      • connectedStubs

        protected int connectedStubs()
      • startReconnector

        protected void startReconnector()
      • stopReconnector

        protected void stopReconnector()