Class TCPGOSSIP

All Implemented Interfaces:
Lifecycle, RouterStub.MembersNotification

public class TCPGOSSIP extends Discovery implements RouterStub.MembersNotification
The TCPGOSSIP protocol layer retrieves the initial membership (used by GMS when started by sending event FIND_INITIAL_MBRS down the stack). We do this by contacting one or more GossipRouters, which must be running at well-known addresses:ports. The responses should allow us to determine the coordinator whom we have to contact, e.g. in case we want to join the group. When we are a server (after having received the BECOME_SERVER event), we'll respond to TCPGOSSIP requests with a TCPGOSSIP response.
Since:
a long time ago
  • Field Details

    • sock_conn_timeout

      protected int sock_conn_timeout
    • reconnect_interval

      protected long reconnect_interval
    • use_nio

      protected boolean use_nio
    • initial_hosts

      private final List<InetSocketAddress> initial_hosts
    • stubManager

      protected volatile RouterStubManager stubManager
  • Constructor Details

    • TCPGOSSIP

      public TCPGOSSIP()
  • Method Details

    • setInitialHosts

      public TCPGOSSIP setInitialHosts(List<InetSocketAddress> hosts)
    • setInitialHosts

      public TCPGOSSIP setInitialHosts(Collection<InetSocketAddress> hosts)
    • getInitialHosts

      public List<InetSocketAddress> getInitialHosts()
    • isDynamic

      public boolean isDynamic()
      Specified by:
      isDynamic in class Discovery
    • initialHosts

      public String initialHosts()
    • sockConnTimeout

      public long sockConnTimeout()
    • sockConnTimeout

      public TCPGOSSIP sockConnTimeout(int t)
    • reconnectInterval

      public long reconnectInterval()
    • reconnectInterval

      public TCPGOSSIP reconnectInterval(long r)
    • getStubManager

      public RouterStubManager getStubManager()
    • init

      public void init() throws Exception
      Description copied from class: Protocol
      Called after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent.
      Specified by:
      init in interface Lifecycle
      Overrides:
      init in class Discovery
      Throws:
      Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the the channel constructor will throw an exception
    • stop

      public void stop()
      Description copied from class: Protocol
      Called on a JChannel.disconnect(); stops work (e.g. by closing multicast socket). Will be called from top to bottom.
      Specified by:
      stop in interface Lifecycle
      Overrides:
      stop in class Discovery
    • destroy

      public void destroy()
      Description copied from class: Protocol
      This method is called on a JChannel.close(). Does some cleanup; after the call, the VM will terminate
      Specified by:
      destroy in interface Lifecycle
      Overrides:
      destroy in class Protocol
    • handleConnect

      public void handleConnect()
      Overrides:
      handleConnect in class Discovery
    • print

      public String print()
    • printStubs

      public String printStubs()
    • printReconnectList

      public String printReconnectList()
    • handleDisconnect

      public void handleDisconnect()
      Overrides:
      handleDisconnect in class Discovery
    • findMembers

      public void findMembers(List<Address> members, boolean initial_discovery, Responses responses)
      Description copied from class: Discovery
      Fetches information (e.g. physical address, logical name) for the given member addresses. Needs to add responses to the Responses object. If Discovery.async_discovery is true, this method will be called in a separate thread, otherwise the caller's thread will be used.
      Specified by:
      findMembers in class Discovery
      Parameters:
      members - A list of logical addresses (typically UUIDs). If null, then information for all members is fetched
      initial_discovery - Set to true if this is for the initial membership discovery. Some protocols (e.g. file based ones) may return only the information for the coordinator(s).
      responses - The list to which responses should be added
    • members

      public void members(List<PingData> mbrs)
      Specified by:
      members in interface RouterStub.MembersNotification
    • addInitialHost

      public void addInitialHost(String hostname, int port)
    • removeInitialHost

      public boolean removeInitialHost(String hostname, int port)