springs.rns
Class RegionNameServer

java.lang.Object
  |
  +--springs.rns.RegionNameServer
Direct Known Subclasses:
RegionNameServer_RMIImpl

public abstract class RegionNameServer
extends java.lang.Object

The Region Name Server (RNS).

Author:
Raquel Trillo Lado

Nested Class Summary
(package private)  class RegionNameServer.ContextWatcher
           
 
Field Summary
private  java.util.Hashtable _agentLocationServers
           
private  java.util.Hashtable _contextInformations
          A table storing the addresses of contexts in the region and the contexts that track every agent created in the region.
private  RegionNameServer.ContextWatcher _cw
          The context watcher.
private  int _trackingFactor
          Number of contexts that should track the location of every agent.
 
Constructor Summary
RegionNameServer()
           
 
Method Summary
 java.util.Vector addAgent(java.lang.String agentName, springs.context.ContextAddress ca)
           
 java.util.Hashtable addContext(springs.context.ContextAddress ca)
           
private  java.util.Vector allocateLocationServers()
          Allocate locationServers to follow an agent.
private  void contextUnavailable(java.lang.String cn)
          Considers that the given context is not anymore available for tracking agents.
private  void contextUnavailable(java.lang.String cn, java.util.Collection unAvailableContext)
          Considers that the given context is not anymore available for tracking agents.
private  void contextUnavailableForTracking(java.lang.String cn)
          Considers that the given context is not anymore available for tracking agents.
private  java.lang.String getNamesRegisteredAgents()
           
 springs.rns.SearchingInformation getSearchingInformation(java.lang.String agentName, springs.context.ContextAddress ca)
           
protected  void initialize()
          Initializes the server.
private  void newContextAvailable(springs.context.ContextAddress ca)
          Considers that there is a new context available to assign the task of tracking agents.
 void printAgents()
           
 void printContexts()
           
 void printLocationServersFor(java.lang.String agentName)
           
 void removeAgent(java.lang.String agentName, springs.context.ContextAddress ca)
           
 void removeContext(java.lang.String cn, java.util.Collection ownedAgents)
           
protected abstract  void start()
          Starts the Region Name Server.
private  void watchContexts()
          Watchs if every context in the region is alive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_contextInformations

private java.util.Hashtable _contextInformations
A table storing the addresses of contexts in the region and the contexts that track every agent created in the region.


_agentLocationServers

private java.util.Hashtable _agentLocationServers

_cw

private transient RegionNameServer.ContextWatcher _cw
The context watcher.


_trackingFactor

private int _trackingFactor
Number of contexts that should track the location of every agent.

Constructor Detail

RegionNameServer

public RegionNameServer()
Method Detail

start

protected abstract void start()
                       throws RNSStartingException
Starts the Region Name Server.

Throws:
RNSStartingException - if error.
See Also:
RNSStartingException

initialize

protected void initialize()
Initializes the server. It must be called from the start() method.


addContext

public java.util.Hashtable addContext(springs.context.ContextAddress ca)
                               throws AlreadyExistingContextException
AlreadyExistingContextException

removeContext

public void removeContext(java.lang.String cn,
                          java.util.Collection ownedAgents)
                   throws PermissionException
PermissionException

getNamesRegisteredAgents

private java.lang.String getNamesRegisteredAgents()

addAgent

public java.util.Vector addAgent(java.lang.String agentName,
                                 springs.context.ContextAddress ca)
                          throws AlreadyExistingAgentException,
                                 PermissionException
AlreadyExistingAgentException
PermissionException

removeAgent

public void removeAgent(java.lang.String agentName,
                        springs.context.ContextAddress ca)
                 throws PermissionException
PermissionException

getSearchingInformation

public springs.rns.SearchingInformation getSearchingInformation(java.lang.String agentName,
                                                                springs.context.ContextAddress ca)
                                                         throws PermissionException,
                                                                AgentNotFoundException
PermissionException
AgentNotFoundException

printLocationServersFor

public void printLocationServersFor(java.lang.String agentName)

printAgents

public void printAgents()

printContexts

public void printContexts()

newContextAvailable

private void newContextAvailable(springs.context.ContextAddress ca)
Considers that there is a new context available to assign the task of tracking agents. The current implementation does nothing.

Parameters:
ca - the address of the context.
See Also:
ContextAddress

allocateLocationServers

private java.util.Vector allocateLocationServers()
Allocate locationServers to follow an agent.

Returns:
the vector of locationServers, with their context's addresses.
See Also:
Vector

contextUnavailable

private void contextUnavailable(java.lang.String cn)
Considers that the given context is not anymore available for tracking agents.

Parameters:
cn - the name of the context to remove. This context is not in Hashtable yet.
See Also:
String

contextUnavailable

private void contextUnavailable(java.lang.String cn,
                                java.util.Collection unAvailableContext)
Considers that the given context is not anymore available for tracking agents.

Parameters:
cn - the name of the context to remove. This context is still in Hashtable.
unAvailableContext - a list of context which can not be pinged.
See Also:
String, String

contextUnavailableForTracking

private void contextUnavailableForTracking(java.lang.String cn)
Considers that the given context is not anymore available for tracking agents.

Parameters:
cn - the name of the context to remove.
See Also:
String

watchContexts

private void watchContexts()
Watchs if every context in the region is alive.