org.objectweb.jonas.discovery
Class DiscoveryGreetingResponder

java.lang.Object
  extended by org.objectweb.jonas.discovery.DiscoveryComm
      extended by org.objectweb.jonas.discovery.DiscoveryGreetingResponder
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
DiscoveryGreetingListener

public class DiscoveryGreetingResponder
extends DiscoveryComm

This class sends a multicast message stating the servername and the port at which it will listen for messages. It listens at the unicast port for a pre-determined time (greetingTimeOut) and if it receives a message indicating that a server with the same ID already exists in the domain then it terminates the discovery service.

Version:
1.0
Author:
Vivek Lakshmanan

Field Summary
protected  int greetingPort
          Port to listen to for greeting responses.
protected  int greetingTimeOut
          Time out period to listen to greetingPort for replies.
protected  java.net.DatagramSocket recvUnicastSocket
          Used to recieve responses to the initial greeting message sent out on the multicast port.
 
Fields inherited from class org.objectweb.jonas.discovery.DiscoveryComm
domainName, jonasName, multicastSocket, notStopped, RECEIVE_BUFFER_SIZE, serverId, unicastSocket, urls
 
Constructor Summary
DiscoveryGreetingResponder(DiscoveryManager dm)
          Constructs a DiscoveryGreetingResponder associated to the DiscoveryManager
 
Method Summary
protected  DiscGreeting createDiscGreeting(boolean startup)
          Create a discovery greeting message
 void handleGreeting()
          Creates a new thread to send the greeting message and listens for rejection messages in response.
 void run()
           
 void stop()
          Throw the run time exception to state that a server with the same name already exists.
 
Methods inherited from class org.objectweb.jonas.discovery.DiscoveryComm
createNotifMessage, getDatagram, getServerId, join, sendNotif, sendResponse, setDomainName, setJonasName, setServerId, setUrls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

recvUnicastSocket

protected java.net.DatagramSocket recvUnicastSocket
Used to recieve responses to the initial greeting message sent out on the multicast port.


greetingPort

protected int greetingPort
Port to listen to for greeting responses.


greetingTimeOut

protected int greetingTimeOut
Time out period to listen to greetingPort for replies.

Constructor Detail

DiscoveryGreetingResponder

public DiscoveryGreetingResponder(DiscoveryManager dm)
Constructs a DiscoveryGreetingResponder associated to the DiscoveryManager

Parameters:
dm - DiscoveryManager to which this instance is associated
Method Detail

createDiscGreeting

protected DiscGreeting createDiscGreeting(boolean startup)
Create a discovery greeting message

Parameters:
startup - - true: means that is a greeting message at the point of start up of the discovery service. false: means this is a reply to a previous greeting message.
Returns:
a Discovery Greeting message.

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class DiscoveryComm
See Also:
Runnable.run()

handleGreeting

public void handleGreeting()
                    throws DuplicateServerNameException
Creates a new thread to send the greeting message and listens for rejection messages in response.

Throws:
DuplicateServerNameException - - If a server with the same ID is found in the domain.

stop

public void stop()
Throw the run time exception to state that a server with the same name already exists.

Overrides:
stop in class DiscoveryComm