org.apache.cassandra.concurrent
Class SingleThreadedStage

java.lang.Object
  extended by org.apache.cassandra.concurrent.SingleThreadedStage
All Implemented Interfaces:
IStage

public class SingleThreadedStage
extends java.lang.Object
implements IStage

This class is an implementation of the IStage interface. In particular it is for a stage that has a thread pool with a single thread. For details please refer to the IStage documentation.


Field Summary
protected  DebuggableThreadPoolExecutor executorService_
           
 
Constructor Summary
SingleThreadedStage(java.lang.String name)
           
 
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.
 long getCompletedTasks()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

executorService_

protected DebuggableThreadPoolExecutor executorService_
Constructor Detail

SingleThreadedStage

public SingleThreadedStage(java.lang.String name)
Method Detail

getName

public java.lang.String getName()
Description copied from interface: IStage
Get the name of the associated stage.

Specified by:
getName in interface IStage
Returns:
name of the associated stage.

getInternalThreadPool

public java.util.concurrent.ExecutorService getInternalThreadPool()
Description copied from interface: IStage
Get the thread pool used by this stage internally.

Specified by:
getInternalThreadPool in interface IStage

execute

public void execute(java.lang.Runnable runnable)
Description copied from interface: IStage
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.

Specified by:
execute in interface IStage
Parameters:
runnable - instance whose run() method needs to be invoked.

execute

public java.util.concurrent.Future<java.lang.Object> execute(java.util.concurrent.Callable<java.lang.Object> callable)
Description copied from interface: IStage
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.

Specified by:
execute in interface IStage
Parameters:
callable - instance that needs to be invoked.
Returns:
the future return object from the callable.

schedule

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

Specified by:
schedule in interface IStage
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

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

Specified by:
scheduleAtFixedRate in interface IStage
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

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

Specified by:
scheduleWithFixedDelay in interface IStage
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

public void shutdown()
Description copied from interface: IStage
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.

Specified by:
shutdown in interface IStage

isShutdown

public boolean isShutdown()
Description copied from interface: IStage
Checks if the stage has been shutdown.

Specified by:
isShutdown in interface IStage
Returns:
true if shut down, otherwise false.

getPendingTasks

public long getPendingTasks()
Description copied from interface: IStage
This method returns the number of tasks that are pending on this stage to be executed.

Specified by:
getPendingTasks in interface IStage
Returns:
task count.

getCompletedTasks

public long getCompletedTasks()
Specified by:
getCompletedTasks in interface IStage


Copyright © 2010 The Apache Software Foundation