org.n52.wps.server.handler
Class RequestExecutor

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ThreadPoolExecutor
          extended by org.n52.wps.server.handler.RequestExecutor
All Implemented Interfaces:
java.util.concurrent.Executor, java.util.concurrent.ExecutorService

public class RequestExecutor
extends java.util.concurrent.ThreadPoolExecutor

After the client Request is accepted, it should be executed. To prevent resource-exhaustion, this ThreadPoolExecutor stores the Requests in a queue, and handles only a couple of them at a time. To tune the performance one can alter the parameters of this pool. Proper pool size estimation: N = Number of processors WT = Average waiting time of a task ST = Average service time of a task #Threads = N * (1 + WT/ST)

Author:
Timon ter Braak

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 int KEEP_ALIVE_SECONDS
           
static int MAX_POOL_SIZE
           
static int MAX_QUEUED_TASKS
           
static int MIN_POOL_SIZE
           
 
Constructor Summary
RequestExecutor()
          Create a RequestExecutor.
 
Method Summary
protected  void afterExecute(java.lang.Runnable r, java.lang.Throwable t)
          After Execution of the Request this method is called.
protected  void beforeExecute(java.lang.Thread t, java.lang.Runnable r)
          Before Executing the Request this method is called.
 
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, 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

MIN_POOL_SIZE

public static final int MIN_POOL_SIZE
See Also:
Constant Field Values

MAX_POOL_SIZE

public static final int MAX_POOL_SIZE
See Also:
Constant Field Values

KEEP_ALIVE_SECONDS

public static final int KEEP_ALIVE_SECONDS
See Also:
Constant Field Values

MAX_QUEUED_TASKS

public static final int MAX_QUEUED_TASKS
See Also:
Constant Field Values
Constructor Detail

RequestExecutor

public RequestExecutor()
Create a RequestExecutor.

Method Detail

beforeExecute

protected void beforeExecute(java.lang.Thread t,
                             java.lang.Runnable r)
Before Executing the Request this method is called.

Overrides:
beforeExecute in class java.util.concurrent.ThreadPoolExecutor
Parameters:
t - The Thread which executes the Request.
r - The Request.
See Also:
ThreadPoolExecutor.beforeExecute(java.lang.Thread, java.lang.Runnable)

afterExecute

protected void afterExecute(java.lang.Runnable r,
                            java.lang.Throwable t)
After Execution of the Request this method is called.

Overrides:
afterExecute in class java.util.concurrent.ThreadPoolExecutor
Parameters:
r - The Request.
t - The Exception that was thrown (if one exists, otherwise null).
See Also:
ThreadPoolExecutor.afterExecute(java.lang.Runnable, java.lang.Throwable)


Copyright © 2007-2011 52north.org. All Rights Reserved.