lime
Class LimeServer

java.lang.Object
  |
  +--lime.LimeServer
All Implemented Interfaces:
java.util.EventListener, GroupChangedListener, PropertyKeys, java.lang.Runnable

public class LimeServer
extends java.lang.Object
implements java.lang.Runnable, PropertyKeys, GroupChangedListener

The runtime support needed to run Lime on a given host.

There can be multiple Lime servers running on a single host, as long as they are started on separate ports at least 3 apart. This is because (port+1) is used for loading agents, and (port+2) is used for the group manager's SinglePhaseDisseminator. Note that other (future) detectors/disseminators could use more ports.

The server must be explicitly activated by calling the boot method.

The server also provides methods that allow an agent in it to engage the corresponding host in the Lime community. Engagement takes place as a distributed transaction that reconciles the state of the system by shuffling misplaced tuples and installing weak reaction operations among the engaging host and those already in the system. Similarly, disengagement removes a host from the community.

The server can be accessed from within a program, or started from command line using the Launcher.

Version:
7/10/2003
Author:
Amy L. Murphy, Gian Pietro Picco, Christine Julien, Chien-Liang Fok, Tom Elgin
See Also:
Launcher

Field Summary
protected static java.util.Properties defaultProperties
          The default server properties.
static java.util.Properties properties
          The server properties.
 
Fields inherited from interface lime.PropertyKeys
CONNECTkey, DEBUGkey, ENGAGEkey, ENGAGEMENT_MODEkey, ERRORSkey, GM_DETECTORkey, GM_DISSEMINATORkey, GM_MAX_SPEEDkey, GM_MCASTADDRkey, GM_MCASTPORTkey, GM_NETWORK_LATENCYkey, GM_PERIODkey, GM_RANGEkey, GPS_BAUDkey, GPS_PORTkey, LOADkey, MESSAGESkey, PORTkey, QUITkey, TSFACTORYkey
 
Method Summary
 void boot()
          Activate the runtime support.
 void disengage()
          Start the disengagement protocol needed to allow a host to depart from a community of mobile hosts.
 void engage()
          Start the engagement protocol necessary to make this host part of a community of mobile hosts.
 int getLoadPort()
          Returns the port used to load agents onto this LimeServer.
 LimeServerID getmcastServerID()
          Returns the ID of the multicast server.
 int getPort()
          Returns the port being used by this LIMEServer.
static LimeServer getServer()
          Return a handle to the Lime server.
 LimeServerID getServerID()
          Returns the ID of the local server.
 java.lang.String getTupleSpaceFactory()
          Returns the tuple space factory
 void groupChanged(GroupChangedEvent gce)
          The makeup of the group has changed.
 boolean isDebugOn()
          Returns true if debug messages should be printed.
 boolean isEngaged()
          Return true if the host is engaged, false otherwise
 boolean isErrorsOn()
          Returns true if error messages should be printed.
 boolean isMessagesOn()
          Returns true if messages should be printed.
 boolean isPermanentConnections()
          Returns true if TCP connections are maintained.
 boolean isShuttingDown()
          Returns whether shutdown has been called on this LimeServer.
 ILimeAgent loadAgent(java.lang.String classname, java.io.Serializable[] parameters)
          Load an agent into the Lime server.
 void run()
          Listens on the load port, when a client connects, it passes in the name of the agent that should be loaded into the LimeServer.
 void setProperty(java.lang.String key, java.lang.String value)
           
 void shutdown(boolean exit)
          Shuts down the LimeServer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultProperties

protected static java.util.Properties defaultProperties
The default server properties.

properties

public static java.util.Properties properties
The server properties.
Method Detail

groupChanged

public void groupChanged(GroupChangedEvent gce)
The makeup of the group has changed. This is the required method for completely implementing the GroupChangedListener. When the Group Manager has a new set of group members, it generates an event and passes it to this registered listener. This method then takes that event and processes it, calling the engage method if the new group is larger than the previous, and disengage if the new group is smaller.
Specified by:
groupChanged in interface GroupChangedListener
Parameters:
gce - the GroupChangedEvent

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)

getServer

public static LimeServer getServer()
Return a handle to the Lime server.

getTupleSpaceFactory

public java.lang.String getTupleSpaceFactory()
Returns the tuple space factory

getServerID

public LimeServerID getServerID()
Returns the ID of the local server.
Returns:
the ID of the local server.

getmcastServerID

public LimeServerID getmcastServerID()
Returns the ID of the multicast server.
Returns:
the ID of the multicast server.

getPort

public int getPort()
Returns the port being used by this LIMEServer.

getLoadPort

public int getLoadPort()
Returns the port used to load agents onto this LimeServer.

isPermanentConnections

public boolean isPermanentConnections()
Returns true if TCP connections are maintained.

isDebugOn

public boolean isDebugOn()
Returns true if debug messages should be printed.

isErrorsOn

public boolean isErrorsOn()
Returns true if error messages should be printed.

isMessagesOn

public boolean isMessagesOn()
Returns true if messages should be printed.

engage

public void engage()
Start the engagement protocol necessary to make this host part of a community of mobile hosts. If there are no other host to engage with, this method will block all the processing on the host until another host to engage with (a leader) is found. Host engagement is allowed only if there is at least one agent with a shared tuple space is present at that host. Engagement has no effect if the host is already engaged, i.e., no engagement protocol is run in this case.

disengage

public void disengage()
Start the disengagement protocol needed to allow a host to depart from a community of mobile hosts. If the host is already disengaged, this method has no effect, i.e., the disengagement protocol is not run.

isEngaged

public boolean isEngaged()
Return true if the host is engaged, false otherwise

loadAgent

public ILimeAgent loadAgent(java.lang.String classname,
                            java.io.Serializable[] parameters)
                     throws AgentCreationException
Load an agent into the Lime server. The agent's class is described by a fully specified class name. The bytecode (.class files) for this class and all the other classes needed by the agent must be in a directory in the same CLASSPATH available to the Lime server (and to the tuple space engine, if the latter employs user-defined classes). If the Agent subclass has a constructor with parameters, it is possible to create the agent by supplying parameters in the method call. The correct constructor is automatically retrieved by the system based on the signature.
Parameters:
classname - the fully specified name of the agent's class.
parameters - the parameters for instantiating the agent. Their type must match the type of a constructor of classname.
Returns:
a reference to the newly created ILimeAgent.
Throws:
AgentCreationException - if it is impossible to create the agent, e.g., because classname is not a subclass of ILimeAgent, or the corresponding classes cannot be found.

boot

public void boot()
Activate the runtime support.

shutdown

public void shutdown(boolean exit)
Shuts down the LimeServer.
Parameters:
exit - true if the method should system.exit

isShuttingDown

public boolean isShuttingDown()
Returns whether shutdown has been called on this LimeServer. This is used by the TransactionMgr after it has finished processing a host disengagement transaction.

run

public void run()
Listens on the load port, when a client connects, it passes in the name of the agent that should be loaded into the LimeServer. It continuously loads agents.
Specified by:
run in interface java.lang.Runnable