ajanta.pattern
Class Split

java.lang.Object
  |
  +--ajanta.pattern.Pattern
        |
        +--ajanta.pattern.PatternCollection
              |
              +--ajanta.pattern.Split
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
SplitJoin

public class Split
extends PatternCollection

This pattern results in the creation of child agents for parallel traversal of contained patterns. This is conceptually similar to parallelizing a Set, where instead of one agent travelling along some path defined by the Set , each child agent is assigned one element of the Set for traversal. This pattern only controls creation and dispatch of agents. It is used when the child agents are not expected to report back to the parent.

See Also:
Serialized Form

Field Summary
protected  java.lang.String childClassName
          All the child agents created are of this class
protected  int noOfChild
          keep track of the number of child agents created
 
Fields inherited from class ajanta.pattern.PatternCollection
current, list
 
Fields inherited from class ajanta.pattern.Pattern
action, DONE, FAILED, NOTDONE, status
 
Constructor Summary
Split()
           
Split(java.lang.String childClass)
           
 
Method Summary
protected  ajanta.agent.ItinAgent createAgent(ajanta.server.AgentEnv host, java.lang.String agentType, ajanta.naming.URN childURN, ajanta.pattern.Itinerary itin)
          It creates a child agent of the class agentType.
protected  int next(ajanta.server.AgentEnv host)
          It creates child agents equal to the number of the Pattern in the list.
protected  void reset()
          It sets the status of Split Pattern to NOTDONE and resets the status of all the Patterns in the list by calling reset method of individual Patterns.
protected  void scan()
          An empty method ....can overridden in derived classes
 void setAgentResource(ajanta.agent.ItinAgent agent, ajanta.agent.ItinAgent parent)
          It is an empty method which will be overridden in derived class.
 
Methods inherited from class ajanta.pattern.PatternCollection
currentEntry, firstEntry, insert, join, print
 
Methods inherited from class ajanta.pattern.Pattern
getName, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

childClassName

protected java.lang.String childClassName
All the child agents created are of this class


noOfChild

protected int noOfChild
keep track of the number of child agents created

Constructor Detail

Split

public Split()

Split

public Split(java.lang.String childClass)
Parameters:
childClass - name of the class whose instances will be all the child agents created
Method Detail

setAgentResource

public void setAgentResource(ajanta.agent.ItinAgent agent,
                             ajanta.agent.ItinAgent parent)
It is an empty method which will be overridden in derived class. It is used pass certian resources from the parent agent to child agents.

Parameters:
agent - reference to the child agent
parent - reference to the parent agent

createAgent

protected ajanta.agent.ItinAgent createAgent(ajanta.server.AgentEnv host,
                                             java.lang.String agentType,
                                             ajanta.naming.URN childURN,
                                             ajanta.pattern.Itinerary itin)
It creates a child agent of the class agentType. If agentType is null then it creates as that of the parent class. The constructor of the class for child agent's class should take two parameters. First parameter is Credentials object and second is the Itinerary object. Credentials of child agent owner field set to that of the owner of the parent, gurdian is set to that of parent agent and creator is set to the current host

Parameters:
host - AgentEnv of the current server
agentType - class name for the child agents
childURN - URN for the child agents
itin - Itinerary for the child agents
Returns:
It returns reference of the child agent created

next

protected int next(ajanta.server.AgentEnv host)
It creates child agents equal to the number of the Pattern in the list. Each Child agent is assigned a Pattern from the list of Patterns. Child agents are signed by the creator's ( current server's) private key and launched by calling start method of the agent. Child agents are registered with the name registry before they are launched.URN of the child agent is of the form
parent URN + "/" + Name of parent + child number

Specified by:
next in class Pattern
Parameters:
host - AgentEnv of the current agent server

reset

protected void reset()
It sets the status of Split Pattern to NOTDONE and resets the status of all the Patterns in the list by calling reset method of individual Patterns.

Overrides:
reset in class PatternCollection

scan

protected void scan()
An empty method ....can overridden in derived classes

Specified by:
scan in class Pattern