org.jgroups.protocols
Class TCPGOSSIP

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.Discovery
          extended by org.jgroups.protocols.TCPGOSSIP

public class TCPGOSSIP
extends Discovery

The TCPGOSSIP protocol layer retrieves the initial membership (used by the 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.

The FIND_INITIAL_MBRS event will eventually be answered with a FIND_INITIAL_MBRS_OK event up the stack.

Author:
Bela Ban

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jgroups.protocols.Discovery
Discovery.Responses
 
Field Summary
 
Fields inherited from class org.jgroups.protocols.Discovery
break_on_coord_rsp, current_coord, force_sending_discovery_rsps, group_addr, is_coord, is_leaving, is_server, local_addr, members, num_discovery_requests, num_initial_members, num_initial_srv_members, ping_responses, return_entire_cache, stagger_timeout, timeout, timer, use_disk_cache, view
 
Fields inherited from class org.jgroups.stack.Protocol
down_prot, ergonomics, id, log, name, stack, stats, up_prot
 
Constructor Summary
TCPGOSSIP()
           
 
Method Summary
 void addInitialHost(java.lang.String hostname, int port)
           
protected  void connect(RouterStub stub, java.lang.String group, Address logical_addr)
           
protected  void connectAllStubs(java.lang.String group, Address logical_addr)
           
 void destroy()
          This method is called on a Channel.close().
 java.util.Collection<PhysicalAddress> fetchClusterMembers(java.lang.String cluster_name)
          Grab all current cluster members
 java.util.List<java.net.InetSocketAddress> getInitialHosts()
           
 void handleConnect()
           
 void handleDisconnect()
           
 void init()
          Called after instance has been created (null constructor) and before protocol is started.
 boolean isDynamic()
           
 boolean removeInitialHost(java.lang.String hostname, int port)
           
 boolean sendDiscoveryRequestsInParallel()
          Whether or not to send each discovery request on a separate (timer) thread.
 void setInitialHosts(java.util.List<java.net.InetSocketAddress> hosts)
           
 void start()
          This method is called on a Channel.connect(String).
 void stop()
          This method is called on a Channel.disconnect().
 
Methods inherited from class org.jgroups.protocols.Discovery
deserialize, discoveryRequestReceived, down, findAllViews, findAllViewsAsString, findInitialMembers, findInitialMembersAsString, findMembers, getCurrentCoord, getNumberOfDiscoveryRequestsSent, getNumInitialMembers, getTimeout, getView, getViewId, isMergeRunning, providedUpServices, resetStats, sendDiscoveryRequest, sendDiscoveryResponse, sendMcastDiscoveryRequest, serializeWithoutView, setForceSendingDiscoveryRsps, setNumInitialMembers, setTimeout, up
 
Methods inherited from class org.jgroups.stack.Protocol
dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, printStats, providedDownServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, statsEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPGOSSIP

public TCPGOSSIP()
Method Detail

setInitialHosts

public void setInitialHosts(java.util.List<java.net.InetSocketAddress> hosts)

getInitialHosts

public java.util.List<java.net.InetSocketAddress> getInitialHosts()

isDynamic

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

init

public void init()
          throws java.lang.Exception
Description copied from class: Protocol
Called after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.

Overrides:
init in class Discovery
Throws:
java.lang.Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the channel constructor will throw an exception

start

public void start()
           throws java.lang.Exception
Description copied from class: Protocol
This method is called on a Channel.connect(String). Starts work. Protocols are connected and queues are ready to receive events. Will be called from bottom to top. This call will replace the START and START_OK events.

Overrides:
start in class Discovery
Throws:
java.lang.Exception - Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, so Channel.connect(String) will throw an exception

stop

public void stop()
Description copied from class: Protocol
This method is called on a Channel.disconnect(). Stops work (e.g. by closing multicast socket). Will be called from top to bottom. This means that at the time of the method invocation the neighbor protocol below is still working. This method will replace the STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that when this method is called all messages in the down queue will have been flushed

Overrides:
stop in class Discovery

destroy

public void destroy()
Description copied from class: Protocol
This method is called on a Channel.close(). Does some cleanup; after the call the VM will terminate

Overrides:
destroy in class Protocol

handleConnect

public void handleConnect()
Overrides:
handleConnect in class Discovery

handleDisconnect

public void handleDisconnect()
Overrides:
handleDisconnect in class Discovery

fetchClusterMembers

public java.util.Collection<PhysicalAddress> fetchClusterMembers(java.lang.String cluster_name)
Description copied from class: Discovery
Grab all current cluster members

Specified by:
fetchClusterMembers in class Discovery
Returns:
A list of the cluster members (usually IpAddresses), or null if the transport is multicast-enabled. Returns an empty list if no cluster members could be found.

sendDiscoveryRequestsInParallel

public boolean sendDiscoveryRequestsInParallel()
Description copied from class: Discovery
Whether or not to send each discovery request on a separate (timer) thread. If disabled, a discovery request will be sent to all members fetched by Discovery.fetchClusterMembers(String) sequentially

Specified by:
sendDiscoveryRequestsInParallel in class Discovery

addInitialHost

public void addInitialHost(java.lang.String hostname,
                           int port)

removeInitialHost

public boolean removeInitialHost(java.lang.String hostname,
                                 int port)

connectAllStubs

protected void connectAllStubs(java.lang.String group,
                               Address logical_addr)

connect

protected void connect(RouterStub stub,
                       java.lang.String group,
                       Address logical_addr)


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.