Package org.jgroups.protocols
Class TCPGOSSIP
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.Discovery
-
- org.jgroups.protocols.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
- Author:
- Bela Ban
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jgroups.protocols.Discovery
Discovery.DiscoveryCacheDisseminationTask
-
-
Field Summary
Fields Modifier and Type Field Description protected longreconnect_intervalprotected intsock_conn_timeoutprotected RouterStubManagerstubManagerprotected booleanuse_nio-
Fields inherited from class org.jgroups.protocols.Discovery
async_discovery, async_discovery_use_separate_thread_per_request, break_on_coord_rsp, cluster_name, current_coord, discovery_req_futures, discovery_rsp_callback, discovery_rsp_expiry_time, is_coord, is_leaving, is_server, max_members_in_discovery_request, max_rank_to_reply, num_discovery_requests, num_discovery_runs, ping_responses, return_entire_cache, send_cache_on_join, sends_can_block, stagger_timeout, timer, transport, transport_supports_multicasting, use_disk_cache, view, WHITESPACE
-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description TCPGOSSIP()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInitialHost(java.lang.String hostname, int port)voiddestroy()This method is called on aJChannel.close().voidfindMembers(java.util.List<Address> members, boolean initial_discovery, Responses responses)Fetches information (e.g.java.util.List<java.net.InetSocketAddress>getInitialHosts()RouterStubManagergetStubManager()voidhandleConnect()voidhandleDisconnect()voidinit()Called after a protocol has been created and before the protocol is started.java.lang.StringinitialHosts()booleanisDynamic()voidmembers(java.util.List<PingData> mbrs)java.lang.Stringprint()java.lang.StringprintReconnectList()java.lang.StringprintStubs()longreconnectInterval()TCPGOSSIPreconnectInterval(long r)booleanremoveInitialHost(java.lang.String hostname, int port)TCPGOSSIPsetInitialHosts(java.util.Collection<java.net.InetSocketAddress> hosts)TCPGOSSIPsetInitialHosts(java.util.List<java.net.InetSocketAddress> hosts)longsockConnTimeout()TCPGOSSIPsockConnTimeout(int t)voidstop()Called on aJChannel.disconnect(); stops work (e.g.-
Methods inherited from class org.jgroups.protocols.Discovery
addDiscoveryResponseToCaches, addResponse, addResponse, addressAsString, addToCache, breakOnCoordResponse, breakOnCoordResponse, callFindMembersInAllDiscoveryProtocols, clearRequestFutures, deserialize, discoveryRequestReceived, discoveryRspExpiryTime, disseminateDiscoveryInformation, down, dumpCache, findInitialMembersAsString, findMembers, findTopmostDiscoveryProtocol, getClusterName, getCurrentCoord, getNumberOfDiscoveryRequestsSent, getView, getViewId, handle, handleDiscoveryResponse, handleDiscoveryResponse, isCoord, isMergeRunning, marshal, marshal, marshal, print, providedUpServices, read, readPingData, resetStats, returnEntireCache, returnEntireCache, sendCacheInformation, sendCacheOnJoin, sendCacheOnJoin, sendDiscoveryResponse, sendDiscoveryResponse, serializeWithoutView, setClusterName, staggerTimeout, staggerTimeout, start, startCacheDissemination, up, up, up, useDiskCache, useDiskCache, weedOutCompletedDiscoveryResponses, write
-
Methods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, down, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jgroups.stack.RouterStub.MembersNotification
members
-
-
-
-
Field Detail
-
sock_conn_timeout
protected int sock_conn_timeout
-
reconnect_interval
protected long reconnect_interval
-
use_nio
protected boolean use_nio
-
stubManager
protected volatile RouterStubManager stubManager
-
-
Method Detail
-
setInitialHosts
public TCPGOSSIP setInitialHosts(java.util.List<java.net.InetSocketAddress> hosts)
-
setInitialHosts
public TCPGOSSIP setInitialHosts(java.util.Collection<java.net.InetSocketAddress> hosts)
-
getInitialHosts
public java.util.List<java.net.InetSocketAddress> getInitialHosts()
-
initialHosts
public java.lang.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 java.lang.ExceptionDescription copied from class:ProtocolCalled 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.
-
stop
public void stop()
Description copied from class:ProtocolCalled on aJChannel.disconnect(); stops work (e.g. by closing multicast socket). Will be called from top to bottom.
-
destroy
public void destroy()
Description copied from class:ProtocolThis method is called on aJChannel.close(). Does some cleanup; after the call, the VM will terminate
-
handleConnect
public void handleConnect()
- Overrides:
handleConnectin classDiscovery
-
print
public java.lang.String print()
-
printStubs
public java.lang.String printStubs()
-
printReconnectList
public java.lang.String printReconnectList()
-
handleDisconnect
public void handleDisconnect()
- Overrides:
handleDisconnectin classDiscovery
-
findMembers
public void findMembers(java.util.List<Address> members, boolean initial_discovery, Responses responses)
Description copied from class:DiscoveryFetches information (e.g. physical address, logical name) for the given member addresses. Needs to add responses to theResponsesobject. IfDiscovery.async_discoveryis true, this method will be called in a separate thread, otherwise the caller's thread will be used.- Specified by:
findMembersin classDiscovery- Parameters:
members- A list of logical addresses (typicallyUUIDs). If null, then information for all members is fetchedinitial_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(java.util.List<PingData> mbrs)
- Specified by:
membersin interfaceRouterStub.MembersNotification
-
addInitialHost
public void addInitialHost(java.lang.String hostname, int port)
-
removeInitialHost
public boolean removeInitialHost(java.lang.String hostname, int port)
-
-