|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.kernel.TransactionSchedulerImpl
final class TransactionSchedulerImpl
Package-private implementation of TransactionScheduler that is
used by the system for scheduling and running all transactional tasks.
This class supports the following configuration properties:
"com.sun.sgs.impl.kernel.transaction.threads"
"4"
"com.sun.sgs.impl.kernel.scheduler.queue"
"com.sun.sgs.impl.kernel.schedule.FIFOSchedulerQueue"
SchedulerQueue interface, and that provides a public
constructor with the parameters Properties
"com.sun.sgs.impl.kernel.scheduler.retry"
"com.sun.sgs.impl.kernel.schedule.ImmediateRetryPolicy"
SchedulerRetryPolicy interface, and that provides a public
constructor with the parameters Properties
| Field Summary | |
|---|---|
static String |
CONSUMER_THREADS_PROPERTY
The property used to define the default number of initial consumer threads. |
static String |
DEFAULT_CONSUMER_THREADS
The default number of initial consumer threads. |
static String |
DEFAULT_SCHEDULER_QUEUE
The default scheduler. |
static String |
DEFAULT_SCHEDULER_RETRY
The default retry policy |
static String |
SCHEDULER_QUEUE_PROPERTY
The property used to define which queue implementation should back this scheduler. |
static String |
SCHEDULER_RETRY_PROPERTY
The property used to define which retry policy should be used in this scheduler |
| Fields inherited from interface com.sun.sgs.profile.ProfileListener |
|---|
WINDOW_SIZE_PROPERTY |
| Constructor Summary | |
|---|---|
TransactionSchedulerImpl(Properties properties,
TransactionCoordinator transactionCoordinator,
ProfileCollectorHandle profileCollectorHandle,
AccessCoordinatorHandle accessCoordinator)
Creates an instance of TransactionSchedulerImpl. |
|
| Method Summary | |
|---|---|
TaskQueue |
createTaskQueue()
Creates a new TaskQueue to use in scheduling dependent
tasks. |
void |
propertyChange(PropertyChangeEvent event)
Notifies this listener of a new change in the system properties. |
void |
report(ProfileReport profileReport)
Reports a completed task that has been run through the scheduler. |
TaskReservation |
reserveTask(KernelRunnable task,
Identity owner)
Reserves the ability to run the given task. |
TaskReservation |
reserveTask(KernelRunnable task,
Identity owner,
long startTime)
Reserves the ability to run the given task at a specified point in the future. |
TaskReservation |
reserveTask(KernelRunnable task,
Identity owner,
Priority priority)
Reserves the ability to run the given task. |
void |
runTask(KernelRunnable task,
Identity owner)
Runs the given task synchronously, returning when the task has completed or throwing an exception if the task fails. |
(package private) void |
runUnboundedTask(KernelRunnable task,
Identity owner)
Package-private method that runs the given task in a transaction that is not bound by any timeout value (i.e., is bound only by the com.sun.sgs.txn.timeout.unbounded property value). |
RecurringTaskHandle |
scheduleRecurringTask(KernelRunnable task,
Identity owner,
long startTime,
long period)
Schedules a task to start running at a specified point in the future, and continuing running on a regular period starting from that initial point. |
void |
scheduleTask(KernelRunnable task,
Identity owner)
Schedules a task to run as soon as possible based on the specific scheduler implementation. |
void |
scheduleTask(KernelRunnable task,
Identity owner,
long startTime)
Schedules a task to run at a specified point in the future. |
void |
scheduleTask(KernelRunnable task,
Identity owner,
Priority priority)
Schedules a task to run as soon as possible based on the specific scheduler implementation. |
(package private) void |
setContext(KernelContext kernelContext)
Package-private method used to set the context being used by the kernel. |
void |
shutdown()
Tells this listener that the system is shutting down. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String SCHEDULER_QUEUE_PROPERTY
public static final String DEFAULT_SCHEDULER_QUEUE
public static final String SCHEDULER_RETRY_PROPERTY
public static final String DEFAULT_SCHEDULER_RETRY
public static final String CONSUMER_THREADS_PROPERTY
public static final String DEFAULT_CONSUMER_THREADS
| Constructor Detail |
|---|
TransactionSchedulerImpl(Properties properties,
TransactionCoordinator transactionCoordinator,
ProfileCollectorHandle profileCollectorHandle,
AccessCoordinatorHandle accessCoordinator)
throws Exception
TransactionSchedulerImpl.
properties - the Properties for the systemtransactionCoordinator - the TransactionCoordinator used
by the system to manage transactionsprofileCollectorHandle - the ProfileCollectorHandler used to
manage collection of per-task profiling dataaccessCoordinator - the AccessCoordinator used by
the system to managed shared data
InvocationTargetException - if there is a failure initializing
the SchedulerQueue
Exception - if there is any failure creating the scheduler| Method Detail |
|---|
void setContext(KernelContext kernelContext)
kernelContext - the KernelContext for this scheduler
public TaskReservation reserveTask(KernelRunnable task,
Identity owner)
reserveTask in interface TransactionSchedulertask - the KernelRunnable to executeowner - the entity on who's behalf this task is run
TaskReservation for the task
public TaskReservation reserveTask(KernelRunnable task,
Identity owner,
long startTime)
startTime is a value in milliseconds
measured from 1/1/1970.
reserveTask in interface TransactionSchedulertask - the KernelRunnable to executeowner - the entity on who's behalf this task is runstartTime - the time at which to start the task
TaskReservation for the task
public void scheduleTask(KernelRunnable task,
Identity owner)
scheduleTask in interface TransactionSchedulertask - the KernelRunnable to executeowner - the entity on who's behalf this task is run
public void scheduleTask(KernelRunnable task,
Identity owner,
long startTime)
startTime is a value in milliseconds measured from
1/1/1970. If the starting time has already passed, then the task is
run immediately.
scheduleTask in interface TransactionSchedulertask - the KernelRunnable to executeowner - the entity on who's behalf this task is runstartTime - the time at which to start the task
public RecurringTaskHandle scheduleRecurringTask(KernelRunnable task,
Identity owner,
long startTime,
long period)
scheduleTask methods, this
method will never fail to accept to the task so there is no need for
a reservation. Note, however, that the task will not actually start
executing until start is called on the returned
RecurringTaskHandle.
At each execution point the scheduler will make a best effort to run the task, but based on available resources scheduling the task may fail. Regardless, the scheduler will always try again at the next execution time.
scheduleRecurringTask in interface TransactionSchedulertask - the KernelRunnable to executeowner - the entity on who's behalf this task is runstartTime - the time at which to start the taskperiod - the length of time in milliseconds between each
recurring task execution
RecurringTaskHandle used to manage the
recurring taskpublic TaskQueue createTaskQueue()
TaskQueue to use in scheduling dependent
tasks. Each task added to the queue will be run in a separate
transaction. Re-try is applied to each transaction, and the next
task in the queue is run only after the current task either
completes successfully or fails permanently.
createTaskQueue in interface TransactionSchedulerTaskQueue
public void runTask(KernelRunnable task,
Identity owner)
throws Exception
TransactionScheduler implementation to decide when to run this
task, so the task may be run immediately or it might be queued behind
waiting tasks. The task may be handed off to another thread of control
for execution. In all cases, the caller will block until the task
completes or fails permanently.
As with all methods of TransactionScheduler, tasks run with
runTask will be run transactionally. If the caller is not
in an active transaction, then a transaction is created to run the
task. If the caller is already part of an active transaction, then
the task is run as part of that transaction, and the owner
paramater is ignored.
When the caller is not part of an active transaction, then when the
given task completes it will also attempt to commit. If committing
the transaction fails, normal re-try behavior is applied. If the
task requests to be re-tried, then it will be re-run according to the
scheduler implementation's policy. In this case, runTask
will not return until the task finally succeeds, or is no longer
re-tried.
In the event that the caller is part of an active transaction, then there is no re-try applied in the case of a failure, and the transaction is not committed if the task completes successfully. This is because the system does not support nested transactions, and so the decision to commit or re-try is left to the active transaction.
runTask in interface TransactionSchedulertask - the KernelRunnable to executeowner - the entity on who's behalf this task is run
TaskRejectedException - if the given task is not accepted
InterruptedException - if the calling thread is interrupted and
the associated task does not complete
Exception - if the task fails and is not re-tried
public TaskReservation reserveTask(KernelRunnable task,
Identity owner,
Priority priority)
reserveTask in interface PrioritySchedulertask - the KernelRunnable to executeowner - the entity on who's behalf this task is runpriority - the requested Priority
TaskReservation for the task
public void scheduleTask(KernelRunnable task,
Identity owner,
Priority priority)
scheduleTask in interface PrioritySchedulertask - the KernelRunnable to executeowner - the entity on who's behalf this task is runpriority - the requested Prioritypublic void propertyChange(PropertyChangeEvent event)
The current list of supported property names is as follows:
| name | description | new value | old value |
com.sun.sgs.profile.newop |
a new operation is registered with the system. | the new operation :
ProfileOperation |
null |
com.sun.sgs.profile.threadcount |
the number of threads in the system has changed. | the current number of threads : Integer |
the previous number of threads : Integer |
com.sun.sgs.profile.nodeid |
the local node has been assigned a unique identifier | the identifier for the local node: Long |
null |
propertyChange in interface ProfileListenerevent - A PropertyChangeEvent object
describing the name of the property, its old and new
values and the source of the change.public void report(ProfileReport profileReport)
scheduledStartTime will remain constant but the
actualStartTime will change for each re-try of the
same task.
report in interface ProfileListenerprofileReport - the ProfileReport for the taskpublic void shutdown()
shutdown in interface ProfileListener
void runUnboundedTask(KernelRunnable task,
Identity owner)
throws Exception
com.sun.sgs.txn.timeout.unbounded property value).
task - the KernelRunnable to run transactionallyowner - the Identity that owns the task
IllegalStateException - if this method is called from an
actively running transaction
Exception - if there is any failure that does not result in
re-trying the task
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||