com.sun.sgs.impl.app.profile
Class ProfileTaskManager

java.lang.Object
  extended by com.sun.sgs.impl.app.profile.ProfileTaskManager
All Implemented Interfaces:
TaskManager

public class ProfileTaskManager
extends Object
implements TaskManager

This is implementation of TaskManager simply calls its backing manager for each manager method.


Constructor Summary
ProfileTaskManager(TaskManager backingManager)
          Creates an instance of ProfileTaskManager.
 
Method Summary
 PeriodicTaskHandle schedulePeriodicTask(Task task, long delay, long period)
          Schedules a task to run periodically after a delay.
 void scheduleTask(Task task)
          Schedules a task to run now.
 void scheduleTask(Task task, long delay)
          Schedules a task to run after a delay.
 boolean shouldContinue()
          Returns true if the currently running task should do more work if it is available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProfileTaskManager

public ProfileTaskManager(TaskManager backingManager)
Creates an instance of ProfileTaskManager.

Parameters:
backingManager - the TaskManager to call through to
Method Detail

scheduleTask

public void scheduleTask(Task task)
Schedules a task to run now. The TaskManager will call the task's run method as soon as possible after the completion of the task in which this method is called, according to its scheduling algorithm.

If the call to the run method throws an exception, that exception implements ExceptionRetryStatus, and its shouldRetry method returns true, then the TaskManager will make further attempts to run the task. It will continue those attempts until either an attempt succeeds or it notices an exception is thrown that is not retryable. The TaskManager is permitted to treat a non-retryable exception as a hint. In particular, a task that throws a non-retryable exception may be retried if the node running the task crashes.

Specified by:
scheduleTask in interface TaskManager
Parameters:
task - the task to run

scheduleTask

public void scheduleTask(Task task,
                         long delay)
Schedules a task to run after a delay. The TaskManager will wait for the specified number of milliseconds, and then call the task's run method as soon as possible after the completion of the task in which this method is called, according to its scheduling algorithm.

If the call to the run method throws an exception, that exception implements ExceptionRetryStatus, and its shouldRetry method returns true, then the TaskManager will make further attempts to run the task. It will continue those attempts until either an attempt succeeds or it notices an exception is thrown that is not retryable. The TaskManager is permitted to treat a non-retryable exception as a hint. In particular, a task that throws a non-retryable exception may be retried if the node running the task crashes.

Specified by:
scheduleTask in interface TaskManager
Parameters:
task - the task to run
delay - the number of milliseconds to delay before running the task

schedulePeriodicTask

public PeriodicTaskHandle schedulePeriodicTask(Task task,
                                               long delay,
                                               long period)
Schedules a task to run periodically after a delay. The TaskManager will wait for the specified number of milliseconds, and then call the task's run method as soon as possible after the completion of the task in which this method is called, according to its scheduling algorithm. It will also arrange to run the task periodically at the specified interval following the delay until the PeriodicTaskHandle.cancel method is called on the associated handle. At the start of each period, which occurs period milliseconds after the scheduled start of the previous period, a new task will be scheduled to run. The TaskManager will make a best effort to run a new task in each period, but even if the task cannot be run in one period, a new task will always be scheduled for the following period. The TaskManager will wait until the current attempt to run the task has ended before making another attempt to run it, regardless of whether the attempts are for the same or different periods.

If the call to the run method throws an exception, that exception implements ExceptionRetryStatus, and its shouldRetry method returns true, then the TaskManager will make further attempts to run the task. It will continue those attempts until either an attempt succeeds or it notices an exception is thrown that is not retryable. Note that calls to PeriodicTaskHandle.cancel have no effect on attempts to retry a task after the first attempt. The TaskManager is permitted to treat a non-retryable exception as a hint. In particular, a task that throws a non-retryable exception may be retried if the node running the task crashes.

Specified by:
schedulePeriodicTask in interface TaskManager
Parameters:
task - the task to run
delay - the number of milliseconds to delay before running the task
period - the number of milliseconds that should elapse between the starts of periodic attempts to run the task
Returns:
a handle for managing the scheduling of the task

shouldContinue

public boolean shouldContinue()
Returns true if the currently running task should do more work if it is available. Otherwise, returns false. This method should always return true until the current task has done enough work such that the work required to reschedule the task is negligible in comparison to the work already done.

Specified by:
shouldContinue in interface TaskManager
Returns:
true if the currently running task should do more work if possible; otherwise false

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved