ajanta.pattern
Class SplitJoin

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

public abstract class SplitJoin
extends Split

This is a specialization of the Split pattern in which the child agents must report their results to some object (usually the parent). This object must implement the Joinable interface. To achieve this join , the parent appends to the child agents' itinerary, an entry to join with the specified object. Each child agent, having accomplished its task, co-locates with the specified object and invokes the join method on it. This is achieved using the colocateAndInvoke primitive with the join method as a parameter. It is an Abstarct class and need to be extended.

See Also:
Split, SplitJoinAll, SplitJoinAny, Serialized Form

Field Summary
 
Fields inherited from class ajanta.pattern.Split
childClassName, noOfChild
 
Fields inherited from class ajanta.pattern.PatternCollection
current, list
 
Fields inherited from class ajanta.pattern.Pattern
action, DONE, FAILED, NOTDONE, status
 
Constructor Summary
SplitJoin()
           
SplitJoin(java.lang.String childClass)
           
 
Method Summary
protected  void join()
          It calls decements of the Counter, which keeps track how many agents has to synchronize ( including parent).Counter is a Synchronizer object, which is a simple counter implementing a barrier.
protected  int next(ajanta.server.AgentEnv host)
          It creates child agents equal to the number of the Pattern in the list.
protected abstract  int setCounter()
          It sets counter value, which keeps track how many agents has to synchronize ( including parent).
 
Methods inherited from class ajanta.pattern.Split
createAgent, reset, scan, setAgentResource
 
Methods inherited from class ajanta.pattern.PatternCollection
currentEntry, firstEntry, insert, 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
 

Constructor Detail

SplitJoin

public SplitJoin()

SplitJoin

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

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 Itinerary which contain Pattern from the list of Patterns as the first entry and second entry indicate it to execute join method with the parent agent as a part of meet method. 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
Parent calls its own join method so that it can wait for child agents to join it.

Overrides:
next in class Split
Parameters:
host - AgentEnv of the current agent server

setCounter

protected abstract int setCounter()
It sets counter value, which keeps track how many agents has to synchronize ( including parent). Counter is a Synchronizer object, which is a simple counter implementing a barrier.


join

protected void join()
It calls decements of the Counter, which keeps track how many agents has to synchronize ( including parent).Counter is a Synchronizer object, which is a simple counter implementing a barrier.

Overrides:
join in class PatternCollection