agentland.resource.connect
Class ConnectionMakerAgent

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--metaglue.AgentAgent
                          |
                          +--agentland.util.GoodAgent
                                |
                                +--agentland.resource.connect.ConnectionMakerAgent
All Implemented Interfaces:
Agent, ConnectionMaker, Good, MetagluePrimitives, Remote, Serializable, Spy

public class ConnectionMakerAgent
extends GoodAgent
implements ConnectionMaker

Connect things together -- lots stolen from the old drug Pipeline agent. We use STRING REP of AgentID throughout. Be warned.

See Also:
Serialized Form

Inner classes inherited from class metaglue.AgentAgent
AgentAgent.Attribute
 
Field Summary
protected  ComputerIDResolver computerResolver
           
protected  SQLGraph graph
           
 
Fields inherited from class agentland.util.GoodAgent
alert, notifier
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface metaglue.Agent
ALIVE, DIED, NO_METAGLUE, NOT_RUNNING, STARTING
 
Constructor Summary
ConnectionMakerAgent()
           
 
Method Summary
 void addEdge(AgentID from, String outPort, AgentID to, String inPort)
           
 void addEdge(String from, String outPort, String to, String inPort)
           
 int connect(AgentID from, AgentID to)
          Connect "from" to "to".
protected  boolean connect(String in, String agtIDstr, String out)
          Call given agent and tell it to connect in and out.
 boolean connectable(AgentID startAID, AgentID stopAID)
          tells you whether there exists a connection between a pair of agents
 boolean connected(AgentID from, AgentID to)
          Returns whether in the current graph the two are connected
protected  void connectPath(Path p)
          Given a path, this method calls all intermediate agents and sets their inputs and outputs in such a way that the path is connected
 void disconnect(int id)
          kills (resets to 0 cost) the connection with a given id.
protected  AgentID fixNode(AgentID node)
          If the agent cannot be found anywhere in the graph, this method will try to replace the id of the agent with the agent id of the computer the agent is running on...
 Vector getConnections()
          Return list of all current connections.
 Vector getSinks()
          Returns all agentID's of agents that are sinks (i.e.
 Vector getSources()
          Returns all agentID's of agents that are sources (i.e.
 
Methods inherited from class agentland.util.GoodAgent
addSpy, addSpy, alert, alertString, beep, error, getAlert, getHistory, getHistoryElement, getPersistentMap, log, notify, removeSpy, removeSpy, resetHistory, safeRely, safeRely, safeRely, setNiceLogName, tell
 
Methods inherited from class metaglue.AgentAgent
addMonitor, alive, buildEHAFor, defrost, defrostAll, defrostBoolean, defrostInt, defrostString, fixAttribute, fixAttribute, freeze, freeze, freeze, freezeAll, freezeVar, getAgentID, getAttribute, getCatalog, getCatalogID, getDesignation, getFrozenVariables, getLogLevel, getMetaglueAgent, getMetaglueAgentID, getOccupation, getOldLogs, getProperties, getProxyHandlerClass, getSociety, installAPH, log, log, lookupClass, reliesOn, reliesOn, reliesOn, reliesOnSynch, removeAPHFromCatalog, removeFrozen, setFreezeName, setLogLevel, setLogName, shutdown, startAgent, startAgentOn, startAgentOn, startup, status, tiedTo, tiedTo, tiedTo, tiedTo, tieToDesignation, toString, 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, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface agentland.util.Good
getHistory, getHistoryElement, resetHistory
 
Methods inherited from interface metaglue.Agent
addMonitor, alive, getAgentID, getMetaglueAgentID, getOldLogs, shutdown, startup, whereAreYou
 
Methods inherited from interface agentland.util.Spy
tell
 

Field Detail

computerResolver

protected ComputerIDResolver computerResolver

graph

protected SQLGraph graph
Constructor Detail

ConnectionMakerAgent

public ConnectionMakerAgent()
                     throws RemoteException
Method Detail

connect

public int connect(AgentID from,
                   AgentID to)
            throws RemoteException
Connect "from" to "to". Will look for cheapest path.
Specified by:
connect in interface ConnectionMaker
Returns:
id for connection so it can be released. Use this id on any further calls. If connection cannot be made, returns -1. This ID is essentially the "owner" of the path.

connect

protected boolean connect(String in,
                          String agtIDstr,
                          String out)
Call given agent and tell it to connect in and out.

connectPath

protected void connectPath(Path p)
Given a path, this method calls all intermediate agents and sets their inputs and outputs in such a way that the path is connected

disconnect

public void disconnect(int id)
                throws RemoteException
kills (resets to 0 cost) the connection with a given id.
Specified by:
disconnect in interface ConnectionMaker

connectable

public boolean connectable(AgentID startAID,
                           AgentID stopAID)
                    throws RemoteException
tells you whether there exists a connection between a pair of agents
Specified by:
connectable in interface ConnectionMaker

connected

public boolean connected(AgentID from,
                         AgentID to)
                  throws RemoteException
Returns whether in the current graph the two are connected
Specified by:
connected in interface ConnectionMaker

addEdge

public void addEdge(String from,
                    String outPort,
                    String to,
                    String inPort)
Specified by:
addEdge in interface ConnectionMaker

addEdge

public void addEdge(AgentID from,
                    String outPort,
                    AgentID to,
                    String inPort)
Specified by:
addEdge in interface ConnectionMaker

getConnections

public Vector getConnections()
                      throws RemoteException
Return list of all current connections.
Specified by:
getConnections in interface ConnectionMaker

getSources

public Vector getSources()
                  throws RemoteException
Returns all agentID's of agents that are sources (i.e. have no edges going into them)
Specified by:
getSources in interface ConnectionMaker

getSinks

public Vector getSinks()
                throws RemoteException
Returns all agentID's of agents that are sinks (i.e. have no edges going out of them)
Specified by:
getSinks in interface ConnectionMaker

fixNode

protected AgentID fixNode(AgentID node)
If the agent cannot be found anywhere in the graph, this method will try to replace the id of the agent with the agent id of the computer the agent is running on...