org.apache.cassandra.concurrent
Interface IStage

All Known Implementing Classes:
MultiThreadedStage, SingleThreadedStage

public interface IStage

An abstraction for stages as described in the SEDA paper by Matt Welsh. For reference to the paper look over here SEDA: An Architecture for WellConditioned, Scalable Internet Services.


Method Summary
 java.util.concurrent.Future<java.lang.Object> execute(java.util.concurrent.Callable<java.lang.Object> callable)
          This method is used to execute a piece of code on this stage which returns a Future pointer.
 void execute(java.lang.Runnable runnable)
          This method is used to execute a piece of code on this stage.
 java.util.concurrent.ExecutorService getInternalThreadPool()
          Get the thread pool used by this stage internally.
 java.lang.String getName()
          Get the name of the associated stage.
 long getPendingTasks()
          This method returns the number of tasks that are pending on this stage to be executed.
 boolean isShutdown()
          Checks if the stage has been shutdown.
 java.util.concurrent.ScheduledFuture<?> schedule(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
          This method is used to submit tasks to this stage that execute periodically.
 java.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
          This method is used to submit tasks to this stage that execute periodically.
 java.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
          This method is used to submit tasks to this stage that execute periodically.
 void shutdown()
          Shutdown the stage.
 

Method Detail

getName

java.lang.String getName()
Get the name of the associated stage.

Returns:
name of the associated stage.

getInternalThreadPool

java.util.concurrent.ExecutorService getInternalThreadPool()
Get the thread pool used by this stage internally.


execute

void execute(java.lang.Runnable runnable)
This method is used to execute a piece of code on this stage. The idea is that the run() method of this Runnable instance is invoked on a thread from a thread pool that belongs to this stage.

Parameters:
runnable - instance whose run() method needs to be invoked.

execute

java.util.concurrent.Future<java.lang.Object> execute(java.util.concurrent.Callable<java.lang.Object> callable)
This method is used to execute a piece of code on this stage which returns a Future pointer. The idea is that the call() method of this Runnable instance is invoked on a thread from a thread pool that belongs to this stage.

Parameters:
callable - instance that needs to be invoked.
Returns:
the future return object from the callable.

schedule

java.util.concurrent.ScheduledFuture<?> schedule(java.lang.Runnable command,
                                                 long delay,
                                                 java.util.concurrent.TimeUnit unit)
This method is used to submit tasks to this stage that execute periodically.

Parameters:
command - the task to execute.
delay - the time to delay first execution
unit - the time unit of the initialDelay and period parameters
Returns:
the future return object from the runnable.

scheduleAtFixedRate

java.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable command,
                                                            long initialDelay,
                                                            long period,
                                                            java.util.concurrent.TimeUnit unit)
This method is used to submit tasks to this stage that execute periodically.

Parameters:
command - the task to execute.
initialDelay - the time to delay first execution
period - the period between successive executions
unit - the time unit of the initialDelay and period parameters
Returns:
the future return object from the runnable.

scheduleWithFixedDelay

java.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command,
                                                               long initialDelay,
                                                               long delay,
                                                               java.util.concurrent.TimeUnit unit)
This method is used to submit tasks to this stage that execute periodically.

Parameters:
command - the task to execute.
initialDelay - the time to delay first execution
delay - the delay between the termination of one execution and the commencement of the next.
unit - the time unit of the initialDelay and delay parameters
Returns:
the future return object from the runnable.

shutdown

void shutdown()
Shutdown the stage. All the threads of this stage are forcefully shutdown. Any pending tasks on this stage could be dropped or the stage could wait for these tasks to be completed. This is however an implementation detail.


isShutdown

boolean isShutdown()
Checks if the stage has been shutdown.

Returns:
true if shut down, otherwise false.

getPendingTasks

long getPendingTasks()
This method returns the number of tasks that are pending on this stage to be executed.

Returns:
task count.


Copyright © 2009 The Apache Software Foundation