DebuggableThreadPoolExecutor (apache-cassandra API)
Date: 2012-05-04

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cassandra.concurrent
Class DebuggableThreadPoolExecutor

    java.lang.Object
      java.util.concurrent.AbstractExecutorService
          java.util.concurrent.ThreadPoolExecutor
              org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor

All Implemented Interfaces:
  java.util.concurrent.Executor, java.util.concurrent.ExecutorService

Direct Known Subclasses:
  JMXEnabledThreadPoolExecutor

    public class DebuggableThreadPoolExecutor

extends java.util.concurrent.ThreadPoolExecutor

This class encorporates some Executor best practices for Cassandra. Most of the executors in the system should use or extend this. There are two main improvements over a vanilla TPE: - If a task throws an exception, the default uncaught exception handler will be invoked; if there is no such handler, the exception will be logged. - MaximumPoolSize is not supported. Here is what that means (quoting TPE javadoc): If fewer than corePoolSize threads are running, the Executor always prefers adding a new thread rather than queuing. If corePoolSize or more threads are running, the Executor always prefers queuing a request rather than adding a new thread. If a request cannot be queued, a new thread is created unless this would exceed maximumPoolSize, in which case, the task will be rejected. We don't want this last stage of creating new threads if the queue is full; it makes it needlessly difficult to reason about the system's behavior. In other words, if DebuggableTPE has allocated our maximum number of (core) threads and the queue is full, we want the enqueuer to block. But to allow the number of threads to drop if a stage is less busy, core thread timeout is enabled.

Nested Class Summary

Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
`java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy`

Field Summary
`static java.util.concurrent.RejectedExecutionHandler` | `blockingExecutionHandler`
`protected static org.slf4j.Logger` | `logger`

Constructor Summary
`protected` | `DebuggableThreadPoolExecutor(int corePoolSize, int maxPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, java.util.concurrent.ThreadFactory threadFactory)`
`` | `DebuggableThreadPoolExecutor(int corePoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> queue, java.util.concurrent.ThreadFactory factory)`
`` | `DebuggableThreadPoolExecutor(java.lang.String threadPoolName, int priority)`

Method Summary
`protected void` | `afterExecute(java.lang.Runnable r, java.lang.Throwable t)`
`static DebuggableThreadPoolExecutor` | `createWithPoolSize(java.lang.String threadPoolName, int size)`
`static void` | `logExceptionsAfterExecute(java.lang.Runnable r, java.lang.Throwable t)`
`protected void` | `onFinalAccept(java.lang.Runnable task)`
`protected void` | `onFinalRejection(java.lang.Runnable task)`
`protected void` | `onInitialRejection(java.lang.Runnable task)`

Methods inherited from class java.util.concurrent.ThreadPoolExecutor
`allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated`

Methods inherited from class java.util.concurrent.AbstractExecutorService
`invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### logger

    protected static org.slf4j.Logger logger

### blockingExecutionHandler

    public static final java.util.concurrent.RejectedExecutionHandler blockingExecutionHandler

Constructor Detail

### DebuggableThreadPoolExecutor

    public DebuggableThreadPoolExecutor(java.lang.String threadPoolName,
                                        int priority)

### DebuggableThreadPoolExecutor

    public DebuggableThreadPoolExecutor(int corePoolSize,
                                        long keepAliveTime,
                                        java.util.concurrent.TimeUnit unit,
                                        java.util.concurrent.BlockingQueue<java.lang.Runnable> queue,
                                        java.util.concurrent.ThreadFactory factory)

### DebuggableThreadPoolExecutor

    protected DebuggableThreadPoolExecutor(int corePoolSize,
                                           int maxPoolSize,
                                           long keepAliveTime,
                                           java.util.concurrent.TimeUnit unit,
                                           java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
                                           java.util.concurrent.ThreadFactory threadFactory)

Method Detail

### createWithPoolSize

    public static DebuggableThreadPoolExecutor createWithPoolSize(java.lang.String threadPoolName,
                                                                  int size)

### onInitialRejection

    protected void onInitialRejection(java.lang.Runnable task)

### onFinalAccept

    protected void onFinalAccept(java.lang.Runnable task)

### onFinalRejection

    protected void onFinalRejection(java.lang.Runnable task)

### afterExecute

    protected void afterExecute(java.lang.Runnable r,
                                java.lang.Throwable t)

  Overrides:
    `afterExecute` in class `java.util.concurrent.ThreadPoolExecutor`

### logExceptionsAfterExecute

    public static void logExceptionsAfterExecute(java.lang.Runnable r,
                                                 java.lang.Throwable t)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012 The Apache Software Foundation