Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.base.stats
Class StatsTaskEngine

java.lang.Object
  extended by com.jivesoftware.base.stats.StatsTaskEngine

public class StatsTaskEngine
extends java.lang.Object

A class to manage the execution of tasks in the Jive system. A TaskEngine object accepts Runnable objects and queues them for execution by worker threads. Optionally, a priority may be assigned to each task. Tasks with a higher priority are taken from the queue first.


Field Summary
static int HIGH_PRIORITY
           
static int LOW_PRIORITY
           
static int MEDIUM_PRIORITY
           
 
Method Summary
static void addTask(int priority, java.lang.Runnable task)
          Adds a task to the task queue.
static void addTask(java.lang.Runnable task)
          Adds a task to the task queue.
static int getNumWorkers()
          Returns the number of worker threads.
static void restart()
          Restarts the task engine service.
static java.util.TimerTask scheduleTask(int priority, java.lang.Runnable task, java.util.Date date)
          Schedules a task to be run once after a specified delay.
static java.util.TimerTask scheduleTask(int priority, java.lang.Runnable task, long delay, long period)
          Schedules a task to periodically run.
static java.util.TimerTask scheduleTask(java.lang.Runnable task, java.util.Date date)
          Schedules a task to be run once after a specified delay.
static java.util.TimerTask scheduleTask(java.lang.Runnable task, long delay, long period)
          Schedules a task to periodically run.
static void shutdown()
          Shuts down the task engine service.
static int size()
          Returns the current size of the task queue, which is the number of work items waiting to be processed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIGH_PRIORITY

public static final int HIGH_PRIORITY
See Also:
Constant Field Values

MEDIUM_PRIORITY

public static final int MEDIUM_PRIORITY
See Also:
Constant Field Values

LOW_PRIORITY

public static final int LOW_PRIORITY
See Also:
Constant Field Values
Method Detail

size

public static int size()
Returns the current size of the task queue, which is the number of work items waiting to be processed.

Returns:
the current number of items on the queue.

getNumWorkers

public static int getNumWorkers()
Returns the number of worker threads.

Returns:
the number of worker threads.

addTask

public static void addTask(java.lang.Runnable task)
Adds a task to the task queue. The task will be executed immediately provided there is a free worker thread to execute it. Otherwise, it will execute as soon as a worker thread becomes available.

Parameters:
task - the task to execute

addTask

public static void addTask(int priority,
                           java.lang.Runnable task)
Adds a task to the task queue. The task will be executed immediately provided there is a free worker thread to execute it. Otherwise, it will execute as soon as a worker thread becomes available.

Parameters:
priority - the priority of the task in the queue.
task - the task to execute

scheduleTask

public static java.util.TimerTask scheduleTask(java.lang.Runnable task,
                                               java.util.Date date)
Schedules a task to be run once after a specified delay.

Parameters:
task - task to be scheduled.
date - the date in milliseconds at which the task is to be executed.
Returns:
a TimerTask object which can be used to track execution of the task.

scheduleTask

public static java.util.TimerTask scheduleTask(int priority,
                                               java.lang.Runnable task,
                                               java.util.Date date)
Schedules a task to be run once after a specified delay.

Parameters:
priority - the priority of the task in the queue.
task - task to be scheduled.
date - the date in milliseconds at which the task is to be executed.
Returns:
a TimerTask object which can be used to track execution of the task.

scheduleTask

public static java.util.TimerTask scheduleTask(java.lang.Runnable task,
                                               long delay,
                                               long period)
Schedules a task to periodically run. This is useful for tasks such as updating search indexes, deleting old data at periodic intervals, etc.

Parameters:
task - task to be scheduled.
delay - delay in milliseconds before task is to be executed.
period - time in milliseconds between successive task executions.
Returns:
a TimerTask object which can be used to track executions of the task and to cancel subsequent executions.

scheduleTask

public static java.util.TimerTask scheduleTask(int priority,
                                               java.lang.Runnable task,
                                               long delay,
                                               long period)
Schedules a task to periodically run. This is useful for tasks such as updating search indexes, deleting old data at periodic intervals, etc.

Parameters:
priority - the priority of the task in the queue.
task - task to be scheduled.
delay - delay in milliseconds before task is to be executed.
period - time in milliseconds between successive task executions.
Returns:
a TimerTask object which can be used to track executions of the task and to cancel subsequent executions.

shutdown

public static void shutdown()
Shuts down the task engine service. This method is for internal use only.


restart

public static void restart()
Restarts the task engine service. This method is for internal use only.


Jive Forums Project Page

Copyright © 1999-2006 Jive Software.