org.objectweb.proactive.p2p.api.problem
Class Problem

java.lang.Object
  extended byorg.objectweb.proactive.p2p.api.problem.Problem
All Implemented Interfaces:
java.io.Serializable

public abstract class Problem
extends java.lang.Object
implements java.io.Serializable

Implement this class to solve a divide&conquer problem.

Author:
Alexandre di Costanzo
See Also:
Serialized Form

Field Summary
protected  Worker worker
           
 
Constructor Summary
Problem()
           
Problem(Worker worker)
           
 
Method Summary
abstract  Result execute(java.lang.Object[] params)
          Work of the task.
abstract  Result gather(Result[] results)
          To merge all results from daughters tasks when they finish their works.
 Result getCurrentResult()
           
 void setWorker(Worker worker)
           
abstract  int shouldSplit()
          If retun 1 split() is called also split(n) with n is the return is called.
abstract  Problem split()
          To split this task in a daughter task.
 Problem[] split(int n)
          To split this task in n daughters tasks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

worker

protected Worker worker
Constructor Detail

Problem

public Problem()

Problem

public Problem(Worker worker)
Method Detail

execute

public abstract Result execute(java.lang.Object[] params)
Work of the task. It's like the run method of a thread.

Parameters:
params -
Returns:
Return the result of this task.

split

public abstract Problem split()
To split this task in a daughter task.

Returns:
A second Problem.

split

public Problem[] split(int n)
To split this task in n daughters tasks.

Parameters:
n - Number of daughters tasks.
Returns:
Resturn n Tasks.

gather

public abstract Result gather(Result[] results)
To merge all results from daughters tasks when they finish their works.

Parameters:
results - All results.
Returns:
Return a merged result.

shouldSplit

public abstract int shouldSplit()
If retun 1 split() is called also split(n) with n is the return is called. To do nothing please return 0.

Returns:
Return the number of task you want to create.

getCurrentResult

public Result getCurrentResult()
Returns:
Returns the result.

setWorker

public void setWorker(Worker worker)
Parameters:
worker -


Copyright ? April 2005 INRIA All Rights Reserved.