|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.cliftonsnyder.clutch.Agent
public abstract class Agent
A mobile agent Object that will provide the basis for a Clutch network
Nested Class Summary | |
---|---|
static class |
Agent.State
|
Field Summary | |
---|---|
protected Agent.State |
agentState
a variable representing the current state of the Agent |
protected java.util.List<Agent> |
ancestorList
a list of all of the ancestors of the Agent (i.e., a List of all Agents in the path from this Agent to the "root" Agent) |
protected java.util.List<Agent> |
children
a List of the children of the Agent |
protected java.lang.String |
id
an identifier for the Agent |
protected int |
level
an integer to be used for tracking the position of the Agent |
protected int |
maxPeers
the maximum number of peers that the Agent will be allowed |
protected Agent |
parent
the parent of the Agent |
protected ClutchState |
state
contains state information about the Agent |
Constructor Summary | |
---|---|
Agent()
an empty, parameterless constructor; this is necessary if this class is going to "play nice" with ProActive |
|
Agent(ClutchState state)
constructs a new Agent object, with maxPeers maximum peers |
Method Summary | |
---|---|
void |
addChild(Agent child)
adds a child to the list of this Agent's children |
abstract Agent |
createAgent(Node newAgentNode,
Node newDataNode)
method to be implemented by subclasses of Agent; this is where the interesting organization of a Clutch network will take place |
Agent.State |
getAgentState()
|
java.util.List<Agent> |
getAncestorList()
|
java.util.List<Agent> |
getChildren()
getter for the children of this Agent |
java.lang.String |
getHostName()
retrieves the hostname of the Agent |
java.lang.String |
getID()
gets the ID of the Agent |
int |
getLevel()
gets the position of the Agent wrt the other Agents in the system |
Agent |
getParent()
getter for this Agent's parent |
Agent |
getRef()
gets a reference to the Agent; this method is needed when programming with ProActive, as it may be necessary to return a reference to a remote stub (as opposed to a pointed to this) |
abstract boolean |
isNew()
determines whether or not the Agent is newly created or is a current member of a Clutch network |
boolean |
isRoot()
|
static void |
main(java.lang.String[] args)
usage: java [jvm args] com.cliftonsnyder.clutch.Agent [config file] |
void |
removeChild(int childIndex)
|
void |
removeChild(java.lang.String id)
removes a child from this Agent's List of children |
void |
setAgentState(Agent.State agentState)
|
void |
setAncestorList(java.util.List<Agent> ancestorList)
|
void |
setID(java.lang.String id)
setter for the Agent's id |
void |
setLevel(int level)
setter for the Agent's level |
void |
setMaxPeers(int maxPeers)
sets the maximum number of peers that an Agent is allowed to have |
void |
setParent(Agent parent)
setter for the Agent's parent |
void |
setState(ClutchState state)
sets the state information for the Agent |
abstract void |
shutdown()
shut down the Agent |
abstract java.lang.String |
status()
gives a String representation of the current status of the Agent |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.lang.Runnable |
---|
run |
Field Detail |
---|
protected Agent.State agentState
protected java.util.List<Agent> ancestorList
protected java.util.List<Agent> children
protected java.lang.String id
protected int level
protected int maxPeers
protected Agent parent
protected ClutchState state
Constructor Detail |
---|
public Agent()
public Agent(ClutchState state)
maxPeers
- the maximum number of peers that the Agent will be allowedMethod Detail |
---|
public static void main(java.lang.String[] args)
args
- this method takes a single (optional) argument, which is the
path to a Clutch configuration filepublic void addChild(Agent child)
child
- the child to be addedpublic abstract Agent createAgent(Node newAgentNode, Node newDataNode)
agentInfo
- the ProActive Node to which the eventual Agent is to be
attached
public Agent.State getAgentState()
public java.util.List<Agent> getAncestorList()
public java.util.List<Agent> getChildren()
public java.lang.String getHostName()
public java.lang.String getID()
public int getLevel()
public Agent getParent()
public Agent getRef()
public abstract boolean isNew()
public boolean isRoot()
public void removeChild(java.lang.String id)
id
- the id of the child to removepublic void removeChild(int childIndex)
childIndex
- removes the child at the specified index from this Agent's
child Listpublic void setAgentState(Agent.State agentState)
agentState
- sets this Agent's state variable to agentState,
unless this Agent is already in the state SHUTDOWN
or ERRORpublic void setAncestorList(java.util.List<Agent> ancestorList)
ancestorList
- sets this Agent's list of ancestorspublic void setID(java.lang.String id)
id
- the new id for the agentpublic void setLevel(int level)
level
- the new level for the Agentpublic void setMaxPeers(int maxPeers)
maxPeers
- the maximum number of peers that an Agent is allowed to havepublic void setParent(Agent parent)
parent
- the new parent for the Agentpublic void setState(ClutchState state)
state
- a ClutchState object with local state information about the
Agentpublic abstract void shutdown()
public abstract java.lang.String status()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |