org.objectweb.proactive.branchnbound.core.queue
Class TaskQueue

java.lang.Object
  extended by org.objectweb.proactive.branchnbound.core.queue.TaskQueue
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BasicQueueImpl, LargerQueueImpl

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

This class must be extended by all task queues.

It contains and describes all methods needed by the API for handling task allocation, managing results, and backuping / restoring computation.

Author:
Alexandre di Costanzo Created on Nov 3, 2005
See Also:
Serialized Form

Field Summary
static org.apache.log4j.Logger logger
          The logger.
 
Constructor Summary
TaskQueue()
           
 
Method Summary
abstract  void addAll(java.util.Collection tasks)
          Adding a set of tasks in the queue.
abstract  void addResult(Result result)
          Add a found result for the final gather.
abstract  void addTask(Task t)
          Add a task for computing in the queue.
abstract  void backupResults(java.io.OutputStream backupResultFile)
          Backuping in a stream all current found results.
abstract  void backupTasks(Task rootTask, java.util.Vector pendingTasks, java.io.OutputStream backupOutputStream)
          Write all tasks for backuping.
abstract  void flushAll()
          Empty the queue for a new computation.
abstract  java.util.Collection getAllResults()
           
 Result getBestCurrentResult()
           
abstract  Task getRootTaskFromBackup()
          Restore the root task.
abstract  BooleanMutableWrapper hasNext()
           
abstract  IntMutableWrapper howManyResults()
           
 void informNewBestResult(Result newBest)
          ***FOR INTERNAL USE ONLY*** Inform the queue of the best current solution.
abstract  BooleanWrapper isHungry()
           
abstract  void loadResults(java.io.InputStream backupResultFile)
          Restoring results from a backup.
abstract  void loadTasks(java.io.InputStream taskFile)
          Restoring all tasks from a previous backup.
abstract  Task next()
          Return the next task to be computed, and remove it from the queue.
abstract  void setHungryLevel(int level)
          Set the hungry level for this queue.
abstract  IntMutableWrapper size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static final org.apache.log4j.Logger logger
The logger.

Constructor Detail

TaskQueue

public TaskQueue()
Method Detail

addAll

public abstract void addAll(java.util.Collection tasks)
Adding a set of tasks in the queue. Usually a set of sub-tasks from a task which is computing.

Parameters:
tasks - a Collection of Task classes.

size

public abstract IntMutableWrapper size()
Returns:
the number of tasks not yet computed.

hasNext

public abstract BooleanMutableWrapper hasNext()
Returns:
true if the queue has more tasks not computed.

next

public abstract Task next()
Return the next task to be computed, and remove it from the queue.

Returns:
the next task to be computed.

flushAll

public abstract void flushAll()
Empty the queue for a new computation.


isHungry

public abstract BooleanWrapper isHungry()
Returns:
true if the queue has reached the hungry level.
See Also:
setHungryLevel(int)

setHungryLevel

public abstract void setHungryLevel(int level)
Set the hungry level for this queue.

Parameters:
level - the starving task level.
See Also:
isHungry()

backupTasks

public abstract void backupTasks(Task rootTask,
                                 java.util.Vector pendingTasks,
                                 java.io.OutputStream backupOutputStream)
Write all tasks for backuping.

Parameters:
rootTask - the root task.
pendingTasks - the pending tasks.
backupOutputStream - the stream for backuping.

loadTasks

public abstract void loadTasks(java.io.InputStream taskFile)
Restoring all tasks from a previous backup.

Parameters:
taskFile - the stream for restoring.

getRootTaskFromBackup

public abstract Task getRootTaskFromBackup()
Restore the root task. The loadTasks(InputStream) must be called before.

Returns:
the root task from a restore.
See Also:
loadTasks(InputStream)

addResult

public abstract void addResult(Result result)
Add a found result for the final gather.

Parameters:
result - the found result.

howManyResults

public abstract IntMutableWrapper howManyResults()
Returns:
the current total of result found.

getAllResults

public abstract java.util.Collection getAllResults()
Returns:
a Collection with all current found results.

backupResults

public abstract void backupResults(java.io.OutputStream backupResultFile)
Backuping in a stream all current found results.

Parameters:
backupResultFile - the stream for backuping.

loadResults

public abstract void loadResults(java.io.InputStream backupResultFile)
Restoring results from a backup.

Parameters:
backupResultFile - the stream for restoring.

addTask

public abstract void addTask(Task t)
Add a task for computing in the queue.

Parameters:
t - the task to be computed.

informNewBestResult

public void informNewBestResult(Result newBest)

***FOR INTERNAL USE ONLY***

Inform the queue of the best current solution.

Parameters:
newBest - the best current solution.

getBestCurrentResult

public Result getBestCurrentResult()
Returns:
the best current solution.


Copyright 2001-2007 INRIA All Rights Reserved.