Class ibm.aglets.patterns.Slave
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ibm.aglets.patterns.Slave

java.lang.Object
   |
   +----aglet.Aglet
           |
           +----aglet.a4compatibility.OldAglet
                   |
                   +----ibm.aglets.patterns.Slave

public class Slave
extends OldAglet
Create a slave by calling the static method create. The slave will get dispatched automatically.
Given an itinerary, the slave is travelled from one destination to another while performing local computation in every destination. The results of these local computations are accumulated and finally submitted to the slave's Master (the creator of the slave). During its tour the slave skips destinations which are not available (i.e. it cannot be dispatched to).
When a slave:
1) completes its tour.
2) encounters an error during a local computation.
3) cannot be dispatched to yet unvisited destinations.
it immediately returns to its origin host and submits the intermediate result.

Variable Index

 o ARGUMENT
The protected variable that carries an argument for the local task that the slave performs in every destination.
 o RESULT
The protected variable that accumulates the results of the local tasks that this slave performs in every destination.

Constructor Index

 o Slave()

Method Index

 o create(URL, String, AgletContext, Aglet, Itinerary, Object)
Creates a slave.
 o doJob()
This method should be overridden to specify the local task of the slave.
 o getMaster()
Gets the Aglet Idedntifier of the lave's master.
 o getOrigin()
Gets the URL of the Origin of the aglet.
 o initializeJob()
This method should be overridden to specify initialization part for the job of the slave.
 o onCreation(Object)
Initializes the slave.
 o onReturn()
Called when the slave returns to its origin.
 o returnHome()
Dispatch to the Origin
 o run()
Universal entry point for the slave's execution thread.
 o setDefferedReturn(boolean)
Define whether to defer the return of the slave to its origin.

Variables

 o RESULT
  protected Object RESULT
The protected variable that accumulates the results of the local tasks that this slave performs in every destination.
 o ARGUMENT
  protected Object ARGUMENT
The protected variable that carries an argument for the local task that the slave performs in every destination.

Constructors

 o Slave
  public Slave()

Methods

 o initializeJob
  protected abstract void initializeJob() throws Exception
This method should be overridden to specify initialization part for the job of the slave.
Throws: AgletException
if fails to complete.
 o doJob
  protected abstract void doJob() throws Exception
This method should be overridden to specify the local task of the slave.
Throws: AgletException
if fails to complete.
 o getMaster
  protected AgletIdentifier getMaster()
Gets the Aglet Idedntifier of the lave's master.
 o getOrigin
  protected URL getOrigin()
Gets the URL of the Origin of the aglet.
 o returnHome
  protected void returnHome() throws IOException, AgletException
Dispatch to the Origin
 o onReturn
  protected void onReturn()
Called when the slave returns to its origin.
 o create
  public static AgletProxy create(URL url,
                                  String name,
                                  AgletContext context,
                                  Aglet master,
                                  Itinerary itinerary,
                                  Object argument) throws IOException, AgletException
Creates a slave.
Parameters:
url - the url of the aglet class.
name - the name of the aglet class.
context - the aglet context in which the slave should be created.
master - the master aglet.
itinerary - the itinerary object.
argument - the
 argument 
object.
Returns:
an aglet proxy for the slave.
Throws: AgletException
if initialization fails.
 o onCreation
  public synchronized void onCreation(Object object)
Initializes the slave. Only called the very first time this slave is created. The initialization argument includes four elements: the first is the master aglet, the second is the Slave's itinerary, the third is the initial value of the protected
 result 
variable and the fourth is the value of protected
 argument 
variable.
Parameters:
obj - the argument vector.
Throws: AgletException
if the initialization fails.
Overrides:
onCreation in class OldAglet
 o setDefferedReturn
  public void setDefferedReturn(boolean b)
Define whether to defer the return of the slave to its origin.
 o run
  public void run()
Universal entry point for the slave's execution thread.
Overrides:
run in class Aglet

All Packages  Class Hierarchy  This Package  Previous  Next  Index