Class RouterStub

    • Field Detail

      • remote_sa

        protected java.net.InetSocketAddress remote_sa
      • use_nio

        protected final boolean use_nio
      • log

        protected static final Log log
      • sock_conn_timeout

        protected int sock_conn_timeout
      • tcp_nodelay

        protected boolean tcp_nodelay
      • handle_heartbeats

        protected boolean handle_heartbeats
      • last_heartbeat

        protected volatile long last_heartbeat
    • Method Detail

      • tcpNoDelay

        public boolean tcpNoDelay()
      • tcpNoDelay

        public RouterStub tcpNoDelay​(boolean tcp_nodelay)
      • socketConnectionTimeout

        public int socketConnectionTimeout()
      • socketConnectionTimeout

        public RouterStub socketConnectionTimeout​(int timeout)
      • useNio

        public boolean useNio()
      • gossipRouterAddress

        public IpAddress gossipRouterAddress()
      • isConnected

        public boolean isConnected()
      • handleHeartbeats

        public RouterStub handleHeartbeats​(boolean f)
      • handleHeartbeats

        public boolean handleHeartbeats()
      • lastHeartbeat

        public long lastHeartbeat()
      • connect

        public void connect​(java.lang.String group,
                            Address addr,
                            java.lang.String logical_name,
                            PhysicalAddress phys_addr)
                     throws java.lang.Exception
        Registers mbr with the GossipRouter under the given group, with the given logical name and physical address. Establishes a connection to the GossipRouter and sends a CONNECT message.
        Parameters:
        group - The group cluster) name under which to register the member
        addr - The address of the member
        logical_name - The logical name of the member
        phys_addr - The physical address of the member
        Throws:
        java.lang.Exception - Thrown when the registration failed
      • connect

        public void connect()
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • _doConnect

        protected void _doConnect()
                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • disconnect

        public void disconnect​(java.lang.String group,
                               Address addr)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • destroy

        public void destroy()
      • getMembers

        public void getMembers​(java.lang.String group,
                               RouterStub.MembersNotification callback)
                        throws java.lang.Exception
        Fetches a list of PingData from the GossipRouter, one for each member in the given group. This call returns immediately and when the results are available, the RouterStub.MembersNotification.members(List) callback will be invoked.
        Parameters:
        group - The group for which we need members information
        callback - The callback to be invoked.
        Throws:
        java.lang.Exception
      • sendToAllMembers

        public void sendToAllMembers​(java.lang.String group,
                                     Address sender,
                                     byte[] data,
                                     int offset,
                                     int length)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception
      • sendToMember

        public void sendToMember​(java.lang.String group,
                                 Address dest,
                                 Address sender,
                                 byte[] data,
                                 int offset,
                                 int length)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • receive

        public void receive​(Address sender,
                            byte[] buf,
                            int offset,
                            int length)
        Description copied from interface: Receiver
        Delivers a message from a given sender to the application
        Specified by:
        receive in interface Receiver
        Overrides:
        receive in class ReceiverAdapter
        Parameters:
        sender - The sender of the message
        buf - The buffer. An application typically de-serializes data from the buffer into objects used by the application. Note that when receive() returns, it is not safe to use the buffer any longer; if an application needs to use a buffer after this callback returns, it must make a copy.
        offset - The offset at which the received data starts
        length - The length of the received data
      • receive

        public void receive​(Address sender,
                            java.io.DataInput in)
                     throws java.lang.Exception
        Specified by:
        receive in interface Receiver
        Overrides:
        receive in class ReceiverAdapter
        Throws:
        java.lang.Exception
      • compareTo

        public int compareTo​(RouterStub o)
        Specified by:
        compareTo in interface java.lang.Comparable<RouterStub>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • resolveRemoteAddress

        protected boolean resolveRemoteAddress()
        Creates remote from remote_sa. If the latter is unresolved, tries to resolve it one more time (e.g. via DNS)
      • writeRequest

        public void writeRequest​(GossipData req)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • notifyResponse

        protected void notifyResponse​(java.lang.String group,
                                      java.util.List<PingData> list)