org.opennms.netmgt.provision.service.tasks
Class Task

java.lang.Object
  extended by org.opennms.netmgt.provision.service.tasks.Task
Direct Known Subclasses:
AsyncTask, ContainerTask, SyncTask

public abstract class Task
extends Object

BaseTask

Author:
brozow

Constructor Summary
Task(DefaultTaskCoordinator coordinator, ContainerTask parent)
           
 
Method Summary
 void addDependent(Task dependent)
          Adds dependent as a dependent of this task.
 void addPrerequisite(Task prereq)
          Add's prereq as a Prerequisite of this task.
protected  void completeSubmit()
          This method exists to allow a task to have no processing
protected  void debug(String format, Object... args)
           
protected  void doSubmit()
          This method submits a task to be executed and is called when all dependencies are completed for that task This method should place a runnable on an executor or submit the task in some other way so that it will run as soon as possible.
 DefaultTaskCoordinator getCoordinator()
           
 TaskMonitor getMonitor()
           
protected  void info(String format, Object... args)
           
 boolean isFinished()
          This task's run method has completed
 boolean isScheduled()
          This task has be sent to the TaskCoordinator to be run
protected  Category log()
           
protected  void markTaskAsCompleted()
           
protected  void postSchedule()
           
protected  void preSchedule()
           
 void schedule()
          This is called to add the task to the queue of tasks that can be considered to be runnable
protected  void submitRunnable(Runnable runnable, String preferredExecutor)
           
 String toString()
           
 void waitFor()
          Wait for this task to complete.
 void waitFor(long timeout, TimeUnit unit)
          Wait for this task to complete or until a timeout occurs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Task

public Task(DefaultTaskCoordinator coordinator,
            ContainerTask parent)
Method Detail

getCoordinator

public DefaultTaskCoordinator getCoordinator()

getMonitor

public TaskMonitor getMonitor()

doSubmit

protected void doSubmit()
This method submits a task to be executed and is called when all dependencies are completed for that task This method should place a runnable on an executor or submit the task in some other way so that it will run as soon as possible. Tasks that have no processing to be done may override completeSubmit to notify the Task coordinator that the task is done.


completeSubmit

protected void completeSubmit()
This method exists to allow a task to have no processing


schedule

public void schedule()
This is called to add the task to the queue of tasks that can be considered to be runnable


preSchedule

protected void preSchedule()

postSchedule

protected void postSchedule()

isFinished

public boolean isFinished()
This task's run method has completed


isScheduled

public boolean isScheduled()
This task has be sent to the TaskCoordinator to be run


addPrerequisite

public void addPrerequisite(Task prereq)
Add's prereq as a Prerequisite of this task. In other words... this taks cannot run until prereq was been complted.


addDependent

public void addDependent(Task dependent)
Adds dependent as a dependent of this task. So dependent will not be able to run until this task has been completed.


waitFor

public void waitFor()
             throws InterruptedException,
                    ExecutionException
Wait for this task to complete. The current thread will block until this task has been completed.

Throws:
InterruptedException
ExecutionException

waitFor

public void waitFor(long timeout,
                    TimeUnit unit)
             throws InterruptedException
Wait for this task to complete or until a timeout occurs

Throws:
InterruptedException

markTaskAsCompleted

protected void markTaskAsCompleted()

submitRunnable

protected void submitRunnable(Runnable runnable,
                              String preferredExecutor)

toString

public String toString()
Overrides:
toString in class Object

info

protected void info(String format,
                    Object... args)

debug

protected void debug(String format,
                     Object... args)

log

protected Category log()


Copyright © 2009. All Rights Reserved.