lime
Class LimeServer

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

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

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. 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:
1.0 alpha
Author:
Amy L. Murphy, Gian Pietro Picco

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, ERRORSkey, LOADkey, MAFACTORYkey, MCASTADDRkey, MCASTkey, MCASTPORTkey, MESSAGESkey, PORTkey, QUITkey, TSFACTORYkey
 
Method Summary
 void boot()
          Activate the runtime support.
 boolean declareLeader()
          Needed to bootstrap the system by introducing the first host, willing to accept connections from others hosts that want to join the system.
 boolean disengage()
          Start the disengagement protocol needed to allow a host to depart from a community of mobile hosts.
 boolean engage()
          Start the engagement protocol necessary to make this host part of a community of mobile hosts.
 java.lang.String getAgentFactory()
           
 int getLoadPort()
           
 java.lang.String getMulticastAddr()
           
 int getMulticastPort()
           
 int getPort()
          Return the value of the socket port this server is using for unicast messages.
static LimeServer getServer()
          Return a handle to the Lime server.
static LimeServerID getServerID()
          Return the identity of this server.
 java.lang.String getTupleSpaceFactory()
           
 boolean isDebugOn()
           
 boolean isEngaged()
          Return true if the host is engaged, false otherwise
 boolean isErrorsOn()
           
 boolean isMessagesOn()
           
 boolean isMulticastOn()
           
 boolean isPermanentConnections()
           
 ILimeAgent loadAgent(java.lang.String classname, java.io.Serializable[] parameters)
          Load an agent into the Lime server.
 void run()
          The server's behavior.
 void setProperty(java.lang.String key, java.lang.String value)
           
 void shutDown()
          Terminates this Lime server.
 
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

setProperty

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

getServer

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

getServerID

public static LimeServerID getServerID()
Return the identity of this server. Useful to define a HostLocation when issuing a rd/in over the local host's tuple space.
Returns:
a LimeServerID value

getPort

public int getPort()
Return the value of the socket port this server is using for unicast messages.

getLoadPort

public int getLoadPort()

getMulticastPort

public int getMulticastPort()

getMulticastAddr

public java.lang.String getMulticastAddr()

getTupleSpaceFactory

public java.lang.String getTupleSpaceFactory()

getAgentFactory

public java.lang.String getAgentFactory()

isPermanentConnections

public boolean isPermanentConnections()

isMulticastOn

public boolean isMulticastOn()

isDebugOn

public boolean isDebugOn()

isErrorsOn

public boolean isErrorsOn()

isMessagesOn

public boolean isMessagesOn()

declareLeader

public boolean declareLeader()
Needed to bootstrap the system by introducing the first host, willing to accept connections from others hosts that want to join the system.
Returns:
false if the host was already engaged, true otherwise.

engage

public boolean 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.
Returns:
true if the host is engaged, false if the host was already engaged, or did not have any agents with a shared tuple space.

disengage

public boolean 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.
Returns:
true if the host is successfully disengaged, false if it was not engaged when the call was made.

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()
Terminates this Lime server. Before shutting down the server, a disengagement is run, to make other hosts in the system aware of the departure of this host. Note: Not implemented yet.

run

public void run()
The server's behavior.
Specified by:
run in interface java.lang.Runnable