org.jgroups.protocols
Class MPING

java.lang.Object
  extended by org.jgroups.stack.Protocol
      extended by org.jgroups.protocols.Discovery
          extended by org.jgroups.protocols.PING
              extended by org.jgroups.protocols.MPING
All Implemented Interfaces:
java.lang.Runnable

public class MPING
extends PING
implements java.lang.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).

Author:
Bela Ban

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jgroups.protocols.Discovery
Discovery.Responses
 
Field Summary
protected  java.lang.String bind_interface_str
           
 
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
MPING()
           
 
Method Summary
 java.net.InetAddress getBindAddr()
           
 java.net.InetAddress getMcastAddr()
           
 int getMcastPort()
           
 java.util.List<java.net.NetworkInterface> getReceiveInterfaces()
           
 java.util.List<java.net.NetworkInterface> getSendInterfaces()
           
 int getTTL()
           
 void init()
          Called after instance has been created (null constructor) and before protocol is started.
 boolean isReceiveOnAllInterfaces()
           
 boolean isSendOnAllInterfaces()
           
 void run()
           
protected  void sendMcastDiscoveryRequest(Message msg)
           
 void setBindAddr(java.net.InetAddress bind_addr)
           
 void setMcastAddr(java.net.InetAddress mcast_addr)
           
 void setMcastPort(int mcast_port)
           
 void setMulticastAddress(java.lang.String addr)
           
 void setTTL(int ip_ttl)
           
 void start()
          This method is called on a Channel.connect(String).
 void stop()
          This method is called on a Channel.disconnect().
 java.lang.Object up(Event evt)
          An event was received from the layer below.
 
Methods inherited from class org.jgroups.protocols.PING
fetchClusterMembers, isDynamic, sendDiscoveryRequestsInParallel
 
Methods inherited from class org.jgroups.protocols.Discovery
deserialize, discoveryRequestReceived, down, findAllViews, findAllViewsAsString, findInitialMembers, findInitialMembersAsString, findMembers, getCurrentCoord, getNumberOfDiscoveryRequestsSent, getNumInitialMembers, getTimeout, getView, getViewId, handleConnect, handleDisconnect, isMergeRunning, providedUpServices, resetStats, sendDiscoveryRequest, sendDiscoveryResponse, serializeWithoutView, setForceSendingDiscoveryRsps, setNumInitialMembers, setTimeout
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, 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
 

Field Detail

bind_interface_str

protected java.lang.String bind_interface_str
Constructor Detail

MPING

public MPING()
Method Detail

getBindAddr

public java.net.InetAddress getBindAddr()

setBindAddr

public void setBindAddr(java.net.InetAddress bind_addr)

getReceiveInterfaces

public java.util.List<java.net.NetworkInterface> getReceiveInterfaces()

getSendInterfaces

public java.util.List<java.net.NetworkInterface> getSendInterfaces()

isReceiveOnAllInterfaces

public boolean isReceiveOnAllInterfaces()

isSendOnAllInterfaces

public boolean isSendOnAllInterfaces()

getTTL

public int getTTL()

setTTL

public void setTTL(int ip_ttl)

getMcastAddr

public java.net.InetAddress getMcastAddr()

setMcastAddr

public void setMcastAddr(java.net.InetAddress mcast_addr)

setMulticastAddress

public void setMulticastAddress(java.lang.String addr)
                         throws java.net.UnknownHostException
Throws:
java.net.UnknownHostException

getMcastPort

public int getMcastPort()

setMcastPort

public void setMcastPort(int mcast_port)

up

public java.lang.Object up(Event evt)
Description copied from class: Discovery
An 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 using PassDown or c) the event (or another event) is sent up the stack using PassUp.

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

Overrides:
up in class Discovery
Parameters:
evt - - the event that has been sent from the layer below

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

sendMcastDiscoveryRequest

protected void sendMcastDiscoveryRequest(Message msg)
Overrides:
sendMcastDiscoveryRequest in class Discovery

run

public void run()
Specified by:
run in interface java.lang.Runnable


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