darx
Class NameServerImpl

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by darx.NameServerImpl
All Implemented Interfaces:
NameServer, java.io.Serializable, java.rmi.Remote

 class NameServerImpl
extends java.rmi.server.UnicastRemoteObject
implements NameServer

This is the name server implementation which provides the means for locating replication group leaders.


Field Summary
protected static int PORT_NB
          The port number of the location of the centralized name server.
protected static java.lang.String URL
          The URL of the location of the centralized name server.
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface darx.NameServer
DEFAULT_PORT_NB, DEFAULT_URL, SERVICE_NAME
 
Constructor Summary
NameServerImpl()
          Constructor...
 
Method Summary
(package private) static void analyseCommandLine(java.lang.String[] params)
          Analyses the command line in order to fill in specific runtime info: the port number of the name server if the default value is not used, and whether the name server is in debug (verbose) mode or not.
 ReplicantInfo getLeaderOfTask(java.lang.String task_name)
          Returns the information necessary for obtaining the handle of the current leader of the given replication group.
static void main(java.lang.String[] p)
           
 void register(ReplicantInfo new_replicant)
          Registers the info concerning a new replicant for a given task.
 ReplicantInfo selectAnotherLeader(ReplicantInfo old_leader)
          Sets a replicant as the new leader within its replication group info.
 void setLeaderOfTask(ReplicantInfo rep_info)
          Selects a replicant as the new leader within its replication group info.
 ReplicantInfo setLeaderOfTask(java.lang.String url, int port_nb, java.lang.String task_name)
          Selects a replicant as the new leader within its replication group info.
(package private) static void setPortNumber(java.lang.String port_number)
          Modifier for the PORT_NUMBER of the name server.
(package private) static void setURL(java.lang.String url)
          Modifier for the URL of the name server.
 ReplicantInfo unregister(java.lang.String task_name, java.lang.String url, int port_nb)
          Removes the info concerning a replicant for a given task.
 ReplicationGroupInfo unregisterGroup(java.lang.String task_name)
          Removes the info concerning a whole replication group for a given task.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

URL

protected static java.lang.String URL
The URL of the location of the centralized name server.


PORT_NB

protected static int PORT_NB
The port number of the location of the centralized name server.

Constructor Detail

NameServerImpl

NameServerImpl()
         throws java.rmi.RemoteException
Constructor...

Throws:
java.rmi.RemoteException
Method Detail

setURL

static void setURL(java.lang.String url)
Modifier for the URL of the name server.


setPortNumber

static void setPortNumber(java.lang.String port_number)
Modifier for the PORT_NUMBER of the name server.


getLeaderOfTask

public ReplicantInfo getLeaderOfTask(java.lang.String task_name)
                              throws java.rmi.RemoteException,
                                     NoMoreReplicantsException,
                                     InexistentNameException
Returns the information necessary for obtaining the handle of the current leader of the given replication group.

Specified by:
getLeaderOfTask in interface NameServer
Parameters:
task_name - the generic task name
Returns:
the info concerning the current replication group leader
Throws:
java.rmi.RemoteException
NoMoreReplicantsException
InexistentNameException

selectAnotherLeader

public ReplicantInfo selectAnotherLeader(ReplicantInfo old_leader)
                                  throws java.rmi.RemoteException,
                                         NoMoreReplicantsException,
                                         InexistentNameException
Sets a replicant as the new leader within its replication group info. NB: this method implicitly understands that the current leader is faulty; its information will consequently be removed from the group info.

Specified by:
selectAnotherLeader in interface NameServer
Parameters:
old_leader - the info defining the leader to be replaced
Returns:
the info concerning the new replication group leader
Throws:
java.rmi.RemoteException
NoMoreReplicantsException
InexistentNameException

setLeaderOfTask

public void setLeaderOfTask(ReplicantInfo rep_info)
                     throws InexistentNameException,
                            java.rmi.RemoteException,
                            UnknownReplicantException
Selects a replicant as the new leader within its replication group info. NB: no failure is assumed when using this method; the change in the leadership here is an explicit decision from the developer.

Specified by:
setLeaderOfTask in interface NameServer
Parameters:
rep_info - the info about the replicant to be set as the new leader
Throws:
InexistentNameException - No replication group corresponds to the task the replicant info claims to represent.
java.rmi.RemoteException - RMI general problem
UnknownReplicantException - The given replicant info hasn't been registered before.

setLeaderOfTask

public ReplicantInfo setLeaderOfTask(java.lang.String url,
                                     int port_nb,
                                     java.lang.String task_name)
                              throws InexistentNameException,
                                     java.rmi.RemoteException,
                                     UnknownReplicantException
Selects a replicant as the new leader within its replication group info. NB: no failure is assumed when using this method; the change in the leadership here is an explicit decision from the developer.

Specified by:
setLeaderOfTask in interface NameServer
Parameters:
url - the URL of the replicant to be set as new leader
port_nb - the port nb of the replicant to be set as new leader
task_name - the generic name of the concerned task
Returns:
the info concerning the group whose hierarchy is altered.
Throws:
InexistentNameException - No replication group corresponds to the task the replicant info claims to represent.
java.rmi.RemoteException - RMI general problem
UnknownReplicantException - The given replicant info hasn't been registered before.

register

public void register(ReplicantInfo new_replicant)
              throws java.rmi.RemoteException
Registers the info concerning a new replicant for a given task. If no replicant was previously registered, that is if there is no entry corresponding to the given task_name, the replication group info is created.

Specified by:
register in interface NameServer
Parameters:
new_replicant - the replicant info to register
Throws:
java.rmi.RemoteException

unregister

public ReplicantInfo unregister(java.lang.String task_name,
                                java.lang.String url,
                                int port_nb)
                         throws java.rmi.RemoteException,
                                UnknownReplicantException,
                                InexistentNameException
Removes the info concerning a replicant for a given task.
The killed replicant MUST NOT be a leader; killing a task is implemented differently (see method pointer)

Specified by:
unregister in interface NameServer
Parameters:
task_name - the name of the task to which the replicant belongs
url - the url of the server hosting the doomed replica
port_nb - the port nb of the server hosting the doomed replica
Throws:
java.rmi.RemoteException
UnknownReplicantException
InexistentNameException

unregisterGroup

public ReplicationGroupInfo unregisterGroup(java.lang.String task_name)
                                     throws java.rmi.RemoteException,
                                            InexistentNameException
Removes the info concerning a whole replication group for a given task.

Specified by:
unregisterGroup in interface NameServer
Parameters:
task_name - the name of the task being stopped
Returns:
the replication group information for the task being stopped
Throws:
java.rmi.RemoteException
InexistentNameException

main

public static void main(java.lang.String[] p)

analyseCommandLine

static void analyseCommandLine(java.lang.String[] params)
Analyses the command line in order to fill in specific runtime info: the port number of the name server if the default value is not used, and whether the name server is in debug (verbose) mode or not.

Parameters:
params - the String array containing the parameters, can be void if default values are used and debug mode is off