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).

Version:
$Id: MPING.java,v 1.12 2005/08/11 12:43:47 belaban Exp $
Author:
Bela Ban

Field Summary
 
Fields inherited from class org.jgroups.protocols.PING
name
 
Fields inherited from class org.jgroups.stack.Protocol
down_handler, down_prot, down_queue, down_thread, down_thread_prio, log, observer, props, stack, stats, trace, up_handler, up_prot, up_queue, up_thread, up_thread_prio, warn
 
Constructor Summary
MPING()
           
 
Method Summary
 java.net.InetAddress getBindAddr()
           
 java.net.InetAddress getMcastAddr()
           
 int getMcastPort()
           
 java.lang.String getName()
           
 int getTTL()
           
 boolean isBindToAllInterfaces()
           
 void run()
           
 void setBindAddr(java.net.InetAddress bind_addr)
           
 void setBindToAllInterfaces(boolean bind_to_all_interfaces)
           
 void setMcastAddr(java.net.InetAddress mcast_addr)
           
 void setMcastPort(int mcast_port)
           
 boolean setProperties(java.util.Properties props)
          sets the properties of the PING protocol.
 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().
 
Methods inherited from class org.jgroups.protocols.PING
handleConnect, handleDisconnect, localAddressSet, sendGetMembersRequest
 
Methods inherited from class org.jgroups.protocols.Discovery
down, findInitialMembers, findInitialMembersAsString, getNumberOfDiscoveryRequestsSent, getNumInitialMembers, getNumPingRequests, getTimeout, handleConnectOK, makeView, providedUpServices, resetStats, setNumInitialMembers, setNumPingRequests, setTimeout, up
 
Methods inherited from class org.jgroups.stack.Protocol
destroy, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, isTrace, isWarn, passDown, passUp, printStats, providedDownServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, setDownProtocol, setObserver, setPropertiesInternal, setProtocolStack, setTrace, setUpProtocol, setWarn, startDownHandler, startUpHandler, statsEnabled, stopInternal, upThreadEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MPING

public MPING()
Method Detail

getName

public java.lang.String getName()
Overrides:
getName in class PING

getBindAddr

public java.net.InetAddress getBindAddr()

setBindAddr

public void setBindAddr(java.net.InetAddress bind_addr)

isBindToAllInterfaces

public boolean isBindToAllInterfaces()

setBindToAllInterfaces

public void setBindToAllInterfaces(boolean bind_to_all_interfaces)

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)

getMcastPort

public int getMcastPort()

setMcastPort

public void setMcastPort(int mcast_port)

setProperties

public boolean setProperties(java.util.Properties props)
Description copied from class: PING
sets 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 GossipServer, default is null property: gossip_port - if you are using GOSSIP then this defines the port of the GossipServer, default is null

Overrides:
setProperties in class PING
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

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 PING

run

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


Copyright ? 1998-2005 Bela Ban. All Rights Reserved.