com.sun.sgs.kernel.schedule
Interface ScheduledTask


public interface ScheduledTask

This interface represents a single task that has been accepted by a scheduler. It is used by implementations of SchedulerQueue to manage the tasks in the queue.


Field Summary
static int NON_RECURRING
          Identifier that represents a non-recurring task.
static int UNBOUNDED
          Identifier that represents an unbounded timeout.
 
Method Summary
 boolean cancel(boolean block)
          Cancel this ScheduledTask.
 Throwable getLastFailure()
          Returns the Throwable that was the last failure of this task or null if it has never been run or never failed.
 Identity getOwner()
          Returns the owner.
 long getPeriod()
          Returns the period for the task if it's recurring, or NON_RECURRING if this is not a recurring task.
 Priority getPriority()
          Returns the priority.
 RecurringTaskHandle getRecurringTaskHandle()
          Returns the RecurringTaskHandle associated with this task if this task is recurring, or null if this is not recurring.
 long getStartTime()
          Returns the time at which this task is scheduled to start.
 KernelRunnable getTask()
          Returns the task.
 long getTimeout()
          Returns the transaction timeout.
 int getTryCount()
          Returns the try count (the number of times that this task has been attempted).
 boolean isCancelled()
          Returns whether this task has been cancelled.
 boolean isRecurring()
          Returns whether this is a recurring task.
 void setPriority(Priority priority)
          Sets the priority for this task.
 void setTimeout(long timeout)
          Sets the transaction timeout for this task.
 

Field Detail

NON_RECURRING

static final int NON_RECURRING
Identifier that represents a non-recurring task.

See Also:
Constant Field Values

UNBOUNDED

static final int UNBOUNDED
Identifier that represents an unbounded timeout.

See Also:
Constant Field Values
Method Detail

getTask

KernelRunnable getTask()
Returns the task.

Returns:
the KernelRunnable to run

getOwner

Identity getOwner()
Returns the owner.

Returns:
the Identity that owns the task

getPriority

Priority getPriority()
Returns the priority.

Returns:
the Priority

getStartTime

long getStartTime()
Returns the time at which this task is scheduled to start.

Returns:
the scheduled run time for the task

getPeriod

long getPeriod()
Returns the period for the task if it's recurring, or NON_RECURRING if this is not a recurring task.

Returns:
the period between recurring executions.

getTryCount

int getTryCount()
Returns the try count (the number of times that this task has been attempted).

Returns:
the total number of times this task has been retried

getTimeout

long getTimeout()
Returns the transaction timeout. A Scheduler may or may not choose to use this timeout value.

Returns:
the transaction timeout to use for this task.

getLastFailure

Throwable getLastFailure()
Returns the Throwable that was the last failure of this task or null if it has never been run or never failed.

Returns:
the Throwable that was the cause of the last failure

setPriority

void setPriority(Priority priority)
Sets the priority for this task.

Parameters:
priority - the new priority for this task

setTimeout

void setTimeout(long timeout)
Sets the transaction timeout for this task.

Parameters:
timeout - the new transaction timeout for this task

isRecurring

boolean isRecurring()
Returns whether this is a recurring task. If this is not a recurring task then getPeriod should always return NON_RECURRING.

Returns:
true if this task is a recurring task, false otherwise.

getRecurringTaskHandle

RecurringTaskHandle getRecurringTaskHandle()
Returns the RecurringTaskHandle associated with this task if this task is recurring, or null if this is not recurring.

Returns:
the associated RecurringTaskHandle or null

isCancelled

boolean isCancelled()
Returns whether this task has been cancelled.

Returns:
true if this ScheduledTask has been cancelled, false otherwise

cancel

boolean cancel(boolean block)
Cancel this ScheduledTask. Note that if the task is already running then calling this method may not have any affect. Also note that this method should never be called with a value of true for the block parameter if the calling thread is also currently running this ScheduledTask.

Parameters:
block - if true, this call will block until the task is cancelled or has completed, if false, it will not block
Returns:
true if the task was cancelled by this call, false otherwise

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