Class FD_SOCK2

    • Field Detail

      • bind_addr

        protected java.net.InetAddress bind_addr
      • offset

        protected int offset
      • port_range

        protected int port_range
      • client_bind_port

        protected int client_bind_port
      • external_addr

        protected java.net.InetAddress external_addr
      • external_port

        protected int external_port
      • suspect_msg_interval

        protected long suspect_msg_interval
      • connect_timeout

        protected int connect_timeout
      • min_port

        protected int min_port
      • max_port

        protected int max_port
      • linger

        protected int linger
      • num_suspect_events

        protected int num_suspect_events
      • shutting_down

        protected volatile boolean shutting_down
      • pingable_mbrs

        protected final Membership pingable_mbrs
      • suspected_mbrs

        protected final Membership suspected_mbrs
      • cluster

        protected java.lang.String cluster
      • suspect_history

        protected final BoundedList<java.lang.String> suspect_history
    • Constructor Detail

      • FD_SOCK2

        public FD_SOCK2()
    • Method Detail

      • getNumSuspectedMembers

        public int getNumSuspectedMembers()
      • getPingDest

        public java.lang.String getPingDest()
      • getClientState

        public java.lang.String getClientState()
      • getBindAddress

        public java.net.InetAddress getBindAddress()
      • setBindAddress

        public FD_SOCK2 setBindAddress​(java.net.InetAddress b)
      • getExternalAddress

        public java.net.InetAddress getExternalAddress()
      • setExternalAddress

        public FD_SOCK2 setExternalAddress​(java.net.InetAddress e)
      • getExternalPort

        public int getExternalPort()
      • setExternalPort

        public FD_SOCK2 setExternalPort​(int e)
      • getSuspectMsgInterval

        public long getSuspectMsgInterval()
      • setSuspectMsgInterval

        public FD_SOCK2 setSuspectMsgInterval​(long s)
      • getClientBindPort

        public int getClientBindPort()
      • setClientBindPort

        public FD_SOCK2 setClientBindPort​(int c)
      • getPortRange

        public int getPortRange()
      • setPortRange

        public FD_SOCK2 setPortRange​(int p)
      • getOffset

        public int getOffset()
      • setOffset

        public FD_SOCK2 setOffset​(int o)
      • getLinger

        public int getLinger()
      • setLinger

        public FD_SOCK2 setLinger​(int l)
      • getActualBindPort

        public int getActualBindPort()
      • printSuspectHistory

        public java.lang.String printSuspectHistory()
      • printConnections

        public java.lang.String printConnections()
      • start

        public void start()
                   throws java.lang.Exception
        Description copied from class: Protocol
        This method is called on a JChannel.connect(String); starts work. Protocols are connected ready to receive events. Will be called from bottom to top.
        Specified by:
        start in interface Lifecycle
        Overrides:
        start in class Protocol
        Throws:
        java.lang.Exception - Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, so JChannel.connect(String) will throw an exception
      • up

        public java.lang.Object up​(Message msg)
        Description copied from class: Protocol
        A single message was received. Protocols may examine the message and do something (e.g. add a header) with it before passing it up.
        Overrides:
        up in class Protocol
      • up

        public void up​(MessageBatch batch)
        Description copied from class: Protocol
        Sends up a multiple messages in a MessageBatch. The sender of the batch is always the same, and so is the destination (null == multicast messages). Messages in a batch can be OOB messages, regular messages, or mixed messages, although the transport itself will create initial MessageBatches that contain only either OOB or regular messages.

        The default processing below sends messages up the stack individually, based on a matching criteria (calling Protocol.accept(Message)), and - if true - calls Protocol.up(org.jgroups.Event) for that message and removes the message. If the batch is not empty, it is passed up, or else it is dropped.

        Subclasses should check if there are any messages destined for them (e.g. using MessageBatch.iterator(Predicate)), then possibly remove and process them and finally pass the batch up to the next protocol. Protocols can also modify messages in place, e.g. ENCRYPT could decrypt all encrypted messages in the batch, not remove them, and pass the batch up when done.

        Overrides:
        up in class Protocol
        Parameters:
        batch - The message batch
      • down

        public java.lang.Object down​(Event evt)
        Description copied from class: Protocol
        An event is to be sent down the stack. A protocol may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the protocol may need to add a header to it (or do nothing at all) before sending it down the stack using down_prot.down().
        Overrides:
        down in class Protocol
      • 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
        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,
                            int length)
                     throws java.lang.Exception
        Description copied from interface: Receiver
        Receive data from the given sender
        Specified by:
        receive in interface Receiver
        Parameters:
        sender - The sender
        in - The data input from which to read
        length - The number of bytes to read
        Throws:
        java.lang.Exception
      • createServer

        protected NioServer createServer​(int[] bind_ports)
      • closeConnectionToPingDest

        protected void closeConnectionToPingDest()
      • handleView

        protected void handleView​(View v)
      • connectToNextPingDest

        protected void connectToNextPingDest​(Address already_suspect)
      • connectTo

        protected boolean connectTo​(Address new_ping_dest,
                                    Membership mbrs)
      • connectTo

        protected boolean connectTo​(IpAddress dest,
                                    Address logical_addr)
      • getPhysicalAddresses

        protected java.util.List<IpAddress> getPhysicalAddresses​(Address a)
        Returns the physical addresses for in range [a+offset..a+offset+port_range
      • messageToBuffer

        public static ByteArray messageToBuffer​(Message msg)
                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • computeBindPorts

        protected int[] computeBindPorts​(int actual_port)
      • suspect

        protected void suspect​(java.util.Collection<Address> suspects)
      • unsuspect

        protected void unsuspect​(Address mbr)
      • broadcastSuspectMessage

        protected void broadcastSuspectMessage​(java.util.List<Address> suspected_members)
        Sends a SUSPECT message to all group members. Only the coordinator (or the next member in line if the coord itself is suspected) will react to this message by installing a new view. To overcome the unreliability of the SUSPECT message (it may be lost because we are not above any retransmission layer), the following scheme is used: after sending the SUSPECT message, it is also added to the broadcast task, which will periodically re-send the SUSPECT until a view is received in which the suspected process is not a member anymore. The reason is that - at one point - either the coordinator or another participant taking over for a crashed coordinator, will react to the SUSPECT message and issue a new view, at which point the broadcast task stops.
      • broadcastUnuspectMessage

        protected void broadcastUnuspectMessage​(Address mbr)