Class MPING
java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.Discovery
org.jgroups.protocols.PING
org.jgroups.protocols.MPING
- All Implemented Interfaces:
Runnable
Uses its own IP multicast socket to send and receive discovery requests/responses. Can be used in
conjuntion with a non-UDP transport, e.g. TCP.
The discovery is assymetric: discovery requests are broadcast via the multicast socket, and received via the multicast socket by everyone in the group. However, the discovery responses are sent back via the regular transport (e.g. TCP) to the sender (discovery request contained sender's regular address, e.g. 192.168.0.2:7800).
- Version:
- $Id: MPING.java,v 1.29.2.7 2009/02/05 08:17:36 belaban Exp $
- Author:
- Bela Ban
-
Field Summary
Fields inherited from class PING
discovery_reception, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetName()intgetTTL()booleanbooleanvoidrun()voidsetBindAddr(InetAddress bind_addr) voidsetMcastAddr(InetAddress mcast_addr) voidsetMcastPort(int mcast_port) booleansetProperties(Properties props) sets the properties of the PING protocol.voidsetTTL(int ip_ttl) voidstart()This method is called on aChannel.connect(String).voidstop()This method is called on aChannel.disconnect().An event was received from the layer below.Methods inherited from class PING
getGossipPort, getGossipRefresh, handleConnect, handleDisconnect, init, localAddressSet, sendGetMembersRequest, setGossipPort, setGossipRefresh, waitForDiscoveryRequestReceptionMethods inherited from class Discovery
down, findInitialMembers, findInitialMembersAsString, getNumberOfDiscoveryRequestsSent, getNumInitialMembers, getNumPingRequests, getTimeout, makeView, providedUpServices, resetStats, setNumInitialMembers, setNumPingRequests, setTimeoutMethods inherited from class Protocol
destroy, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getProperties, getProtocolStack, getThreadFactory, getTransport, getUpProtocol, printStats, providedDownServices, requiredDownServices, requiredUpServices, setDownProtocol, setPropertiesInternal, setProtocolStack, setUpProtocol, statsEnabled, upThreadEnabled
-
Constructor Details
-
MPING
public MPING()
-
-
Method Details
-
getName
-
getBindAddr
-
setBindAddr
-
getReceiveInterfaces
-
getSendInterfaces
-
isReceiveOnAllInterfaces
public boolean isReceiveOnAllInterfaces() -
isSendOnAllInterfaces
public boolean isSendOnAllInterfaces() -
getTTL
public int getTTL() -
setTTL
public void setTTL(int ip_ttl) -
getMcastAddr
-
setMcastAddr
-
getMcastPort
public int getMcastPort() -
setMcastPort
public void setMcastPort(int mcast_port) -
setProperties
Description copied from class:PINGsets the properties of the PING protocol. The following properties are available property: timeout - the timeout (ms) to wait for the initial members, default is 3000=3 secs property: num_initial_members - the minimum number of initial members for a FIND_INITAL_MBRS, default is 2 property: gossip_host - if you are using GOSSIP then this defines the host of the GossipRouter, default is null property: gossip_port - if you are using GOSSIP then this defines the port of the GossipRouter, default is null- Overrides:
setPropertiesin classPING- Parameters:
props- - a property set containing only PING properties- Returns:
- returns true if all properties were parsed properly returns false if there are unrecnogized properties in the property set
-
up
Description copied from class:DiscoveryAn event was received from the layer below. Usually the current layer will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally the event is either a) discarded, or b) an event is sent down the stack usingPassDownor c) the event (or another event) is sent up the stack usingPassUp. For the PING protocol, the Up operation does the following things. 1. If the event is a Event.MSG then PING will inspect the message header. If the header is null, PING simply passes up the event If the header is PingHeader.GET_MBRS_REQ then the PING protocol will PassDown a PingRequest message If the header is PingHeader.GET_MBRS_RSP we will add the message to the initial members vector and wake up any waiting threads. 2. If the event is Event.SET_LOCAL_ADDR we will simple set the local address of this protocol 3. For all other messages we simple pass it up to the protocol above -
start
Description copied from class:ProtocolThis method is called on aChannel.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:
startin classDiscovery- Throws:
Exception- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, soChannel.connect(String)will throw an exception
-
stop
public void stop()Description copied from class:ProtocolThis method is called on aChannel.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 -
run
-