@InterfaceAudience.Private public class TBoundedThreadPoolServer extends org.apache.thrift.server.TServer
Modifier and Type | Class and Description |
---|---|
static class |
TBoundedThreadPoolServer.Args |
private class |
TBoundedThreadPoolServer.ClientConnnection |
Modifier and Type | Field and Description |
---|---|
private CallQueue |
callQueue |
static int |
DEFAULT_MAX_QUEUED_REQUESTS |
static int |
DEFAULT_MAX_WORKER_THREADS |
static int |
DEFAULT_MIN_WORKER_THREADS
This default core pool size should be enough for many test scenarios.
|
private static int |
DEFAULT_THREAD_KEEP_ALIVE_TIME_SEC |
private ThreadPoolExecutor |
executorService
Executor service for handling client connections
|
private static org.slf4j.Logger |
LOG |
static String |
MAX_QUEUED_REQUESTS_CONF_KEY
The maximum number of pending connections waiting in the queue.
|
static String |
MAX_WORKER_THREADS_CONF_KEY
The maximum size of the thread pool.
|
static String |
MIN_WORKER_THREADS_CONF_KEY
The "core size" of the thread pool.
|
private static String |
QUEUE_FULL_MSG |
private TBoundedThreadPoolServer.Args |
serverOptions |
private boolean |
stopped
Flag for stopping the server
|
static String |
THREAD_KEEP_ALIVE_TIME_SEC_CONF_KEY
Default amount of time in seconds to keep a thread alive.
|
static int |
TIME_TO_WAIT_AFTER_SHUTDOWN_MS
Time to wait after interrupting all worker threads.
|
Constructor and Description |
---|
TBoundedThreadPoolServer(TBoundedThreadPoolServer.Args options,
ThriftMetrics metrics) |
Modifier and Type | Method and Description |
---|---|
void |
serve() |
private void |
shutdownServer()
Loop until
ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit) finally does return
without an interrupted exception. |
void |
stop() |
private static final String QUEUE_FULL_MSG
public static final String MIN_WORKER_THREADS_CONF_KEY
public static final int DEFAULT_MIN_WORKER_THREADS
public static final String MAX_WORKER_THREADS_CONF_KEY
public static final int DEFAULT_MAX_WORKER_THREADS
public static final String MAX_QUEUED_REQUESTS_CONF_KEY
public static final int DEFAULT_MAX_QUEUED_REQUESTS
public static final String THREAD_KEEP_ALIVE_TIME_SEC_CONF_KEY
private static final int DEFAULT_THREAD_KEEP_ALIVE_TIME_SEC
public static final int TIME_TO_WAIT_AFTER_SHUTDOWN_MS
private static final org.slf4j.Logger LOG
private ThreadPoolExecutor executorService
private volatile boolean stopped
private TBoundedThreadPoolServer.Args serverOptions
public TBoundedThreadPoolServer(TBoundedThreadPoolServer.Args options, ThriftMetrics metrics)
public void serve()
serve
in class org.apache.thrift.server.TServer
private void shutdownServer()
ExecutorService.awaitTermination(long, java.util.concurrent.TimeUnit)
finally does return
without an interrupted exception. If we don't do this, then we'll shut
down prematurely. We want to let the executor service clear its task
queue, closing client sockets appropriately.public void stop()
stop
in class org.apache.thrift.server.TServer
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.