metaglue
Class MetaglueAgent

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--metaglue.AgentAgent
                          |
                          +--metaglue.MetaglueAgent

public class MetaglueAgent
extends AgentAgent
implements Metaglue

A Metaglue Agent starts agents on the VM that it is running on. A Metaglue Agent belongs to a single society, but it can manipulate agents from any society on the VM. A Metaglue Agent uses a particular Catalog Agent to get its information about agents. Multiple Metaglue Agents can exist on a single VM. A Metaglue Agent is made unique in a particular society by its designation which includes: the host of its VM. and the Catalog Agent ID of the Catalog Agent that this Metaglue Agent gets information about agents from.

See Also:
Serialized Form

Inner classes inherited from class metaglue.AgentAgent
AgentAgent.Attribute
 
Field Summary
static String defaultSociety
          all the Metaglue Agents on the VM this list must be kept on the VM and not in a Catalog because the Metaglue Agents on the VM may all have different Catalog Agents that do not know about each other also this list provides an efficiency for having direct access to a Metaglue Agent from other agents this makes sense for Metaglue Agents because an agent's starting Metaglue Agent is always local.
static MetaglueAgent meto
          This is, when main() is called, the agent that main() produces.
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface metaglue.Agent
ALIVE, DIED, NO_METAGLUE, NOT_RUNNING, STARTING
 
Constructor Summary
MetaglueAgent(AgentID agentID, AgentLoader agentLoader)
          This is main constructor, since we normally grab catalog.
MetaglueAgent(AgentID agentID, AgentLoader agentLoader, Catalog cat)
          Creates a Metaglue Agent.
 
Method Summary
static void clearStartLock()
          Clears the lock for this Metaglue Agent starting an agent Called by the process reading the start info
 Agent findAgent(AgentID agentID)
          Finds an agent with agent ID
 Agent findAgentBlocking(AgentID agentID)
           
 boolean getAcceptAgents()
          Get the value of acceptAgents.
 AgentLoader getAgentLoader()
          Gets the Agent Loader that loaded this Metaglue Agent and that this Metaglue Agent uses
 Catalog getCatalog()
          Gets the Catalog that this Metaglue Agent uses
 ManagedConnection getDatabaseConnection()
          Gets the current db connection.
static MetaglueAgent getMetaglueAgent(AgentID agentID)
          Gets a non-remote copy of a Metaglue Agent on the VM for fast access
static StartInfo getStartInfo()
          Gets the start info for a starting agent
protected  void getStartLock()
          Sets the lock for this Metaglue Agent starting an agent It should be cleared by the process reading the start info
static Agent loadAgent(String argString)
           
static void loadAgents(String[] args)
          Load the agents listed in the argument list.
static void main(String[] args)
          Establishes a Metalgue VM with Metaglue Agent to maintain it which in turn starts any listed agents.
 boolean pingMVM(String society, String host)
           
 void setAcceptAgents(boolean v)
          Set the value of acceptAgents.
 void setDatabase(boolean local_db, String dbname)
          Sets the database connection parameters.
static String[] setup(String[] args)
           
static String[] setup(String[] args, boolean acceptAgents)
           
 void shutdownAgent(AgentID agentID)
          Shuts down the agent by removing it from the Catalog
 void startAgent(AgentID agentID, Object[] parameters)
          Starts an agent on the VM maintained by this Metaglue Agent
static void startLocalLogManager(String society, InetAddress localHost)
           
 
Methods inherited from class metaglue.AgentAgent
addMonitor, alive, defrost, defrostAll, defrostBoolean, defrostInt, defrostString, fixAttribute, fixAttribute, freeze, freeze, freeze, freezeAll, freezeVar, getAgentID, getAttribute, getCatalogID, getDesignation, getFrozenVariables, getLogLevel, getMetaglueAgent, getMetaglueAgentID, getOccupation, getProperties, getSociety, log, log, log, obtainMetaglueAgent, obtainMetaglueAgent, obtainMetaglueAgentByName, reliesOn, reliesOn, reliesOn, reliesOnSynch, removeFrozen, replaceExceptionHandler, setFreezeName, setLogLevel, setLogName, shutdown, startAgent, startAgentOn, startAgentOn, startup, status, tiedTo, tiedTo, tiedTo, tiedTo, tieToDesignation, whereAreYou
 
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

meto

public static MetaglueAgent meto
This is, when main() is called, the agent that main() produces. This allows for writing wrapper startup programs that do things like take arguments in a different way or something.

defaultSociety

public static String defaultSociety
all the Metaglue Agents on the VM this list must be kept on the VM and not in a Catalog because the Metaglue Agents on the VM may all have different Catalog Agents that do not know about each other also this list provides an efficiency for having direct access to a Metaglue Agent from other agents this makes sense for Metaglue Agents because an agent's starting Metaglue Agent is always local.
Constructor Detail

MetaglueAgent

public MetaglueAgent(AgentID agentID,
                     AgentLoader agentLoader,
                     Catalog cat)
              throws RemoteException,
                     AgentAlreadyStartedException,
                     FindAgentException,
                     MissingCatalogException
Creates a Metaglue Agent. There may be multiple Metaglue Agents on a single VM. For bootstrapping purposes, Metaglue Agents must be given their Agent IDs. Ensures that even if such a Metaglue Agent already exists on the VM, that the existing Metaglue Agent is registered with the Catalog Agent
Parameters:
agentID - agent ID of this Metaglue Agent
agentLoader - agent loader that started this Metaglue Agent and will be used in turn by this Metaglue Agent to start other agents
Throws:
AgentAlreadyStartedException - living Metaglue agent already exists on this VM or agent with same agent ID appears in Catalog
FindAgentException - problem finding Catalog Agent (entry found but not actually Catalog Agent, named host for Catalog Agent missing, remote problems connecting with Catalog Agent)
AgentNotFoundException - Catalog Agent not found
MissingCatalogException - Catalog Agent found but inacccessible
MetaglueSystemError - the URL created to find the Catalog Agent is bad
NullPointerException - (runtime) agentID is null
IllegalArgumentException - (runtime) agentID does not have designation of type MetaglueAgentID

MetaglueAgent

public MetaglueAgent(AgentID agentID,
                     AgentLoader agentLoader)
              throws RemoteException,
                     AgentAlreadyStartedException,
                     FindAgentException,
                     MissingCatalogException
This is main constructor, since we normally grab catalog.
Method Detail

getMetaglueAgent

public static MetaglueAgent getMetaglueAgent(AgentID agentID)
Gets a non-remote copy of a Metaglue Agent on the VM for fast access
Parameters:
agentID - agentID of Metaglue Agent to get from local VM
Returns:
the Metaglue Agent with agent ID on the local VM; null if the requested Metaglue Agent is not on the local VM
Throws:
NullPointerException - (runtime) agentID is null

getAgentLoader

public AgentLoader getAgentLoader()
Gets the Agent Loader that loaded this Metaglue Agent and that this Metaglue Agent uses
Returns:
Agent Loader that loaded this Metaglue Agent

getCatalog

public Catalog getCatalog()
Gets the Catalog that this Metaglue Agent uses
Overrides:
getCatalog in class AgentAgent
Returns:
Catalog that this Metaglue Agent uses

findAgent

public Agent findAgent(AgentID agentID)
                throws AgentNotFoundException,
                       FindAgentException,
                       RemoteException
Finds an agent with agent ID
Parameters:
agentID - agent ID of agent to find
Returns:
agent stub for agent with agent ID
Throws:
AgentNotFoundException - Agent with agent ID not found in Catalog
FindAgentException - problem finding Agent (remote problems finding Agent in Catalog)

findAgentBlocking

public Agent findAgentBlocking(AgentID agentID)
                        throws FindAgentException,
                               RemoteException

pingMVM

public boolean pingMVM(String society,
                       String host)

startAgent

public void startAgent(AgentID agentID,
                       Object[] parameters)
                throws AgentNotDefinedException,
                       NativityException,
                       AgentAlreadyStartedException,
                       SpreadException,
                       StartAgentException,
                       RemoteException
Starts an agent on the VM maintained by this Metaglue Agent
Specified by:
startAgent in interface Metaglue
Parameters:
agentID - agent ID of agent to start
parameters - list of arguments to constructor of agent
Throws:
AgentNotDefinedException - no such agent with required constructor or its stub/skel files has not been created
StartAgentException - null agentID or remote problems talking to Catalog
NativityException - problem instantiating agent
AgentAlreadyStartedException - a living agent with agentID found in Catalog
SpreadException - agent could not spread

clearStartLock

public static void clearStartLock()
Clears the lock for this Metaglue Agent starting an agent Called by the process reading the start info

getStartLock

protected void getStartLock()
Sets the lock for this Metaglue Agent starting an agent It should be cleared by the process reading the start info

getStartInfo

public static StartInfo getStartInfo()
Gets the start info for a starting agent
Returns:
current start info

shutdownAgent

public void shutdownAgent(AgentID agentID)
                   throws RemoteException
Shuts down the agent by removing it from the Catalog
Specified by:
shutdownAgent in interface Metaglue
Parameters:
agentID - Agent ID of the agent to shut down

setDatabase

public void setDatabase(boolean local_db,
                        String dbname)
Sets the database connection parameters. This also creates the ManagedConnection, although MetaglueAgent doesn't currently use it.
Parameters:
local_db - Specifies whether to use a local database
dbname - Specifies a different local database name, if given. Uses the default name `metaglue' if null.

getDatabaseConnection

public ManagedConnection getDatabaseConnection()
Gets the current db connection. If the connection was closed, it reopens it.

main

public static void main(String[] args)
Establishes a Metalgue VM with Metaglue Agent to maintain it which in turn starts any listed agents. A Catalog Agent is started if necessary.
Parameters:
args - {society catalog-host [agents...]}

setup

public static String[] setup(String[] args)

setup

public static String[] setup(String[] args,
                             boolean acceptAgents)
Parameters:
acceptAgents - does this metaglue agent start other agents?
Returns:
the args list with all used arguments removed.

startLocalLogManager

public static void startLocalLogManager(String society,
                                        InetAddress localHost)

loadAgents

public static void loadAgents(String[] args)
Load the agents listed in the argument list. NOTE that arg 0 and arg 1 are assumed to be catalog and society and thus skipped.

loadAgent

public static Agent loadAgent(String argString)

getAcceptAgents

public boolean getAcceptAgents()
Get the value of acceptAgents.
Returns:
Value of acceptAgents.

setAcceptAgents

public void setAcceptAgents(boolean v)
Set the value of acceptAgents.
Parameters:
v - Value to assign to acceptAgents.