summaryrefslogtreecommitdiff
path: root/lib/java
diff options
context:
space:
mode:
authorjfarrell <jfarrell@apache.org>2015-06-26 08:58:32 -0400
committerjfarrell <jfarrell@apache.org>2015-06-26 08:58:32 -0400
commit2238adabbc5317ab59ee1b13d4df4e1d4d889c73 (patch)
tree1409fac3be07a99988000bae135e3c7ad457200b /lib/java
parent94d0679f4562eec846667cfd69115feaa8bd53fa (diff)
downloadthrift-2238adabbc5317ab59ee1b13d4df4e1d4d889c73.tar.gz
THRIFT-3202: Allow HSHAServer to configure min and max worker threads separately.
Client: java Patch: Pankaj Kumar Allow HSHAServer to configure min and max worker thread separately
Diffstat (limited to 'lib/java')
-rw-r--r--lib/java/src/org/apache/thrift/server/THsHaServer.java27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/java/src/org/apache/thrift/server/THsHaServer.java b/lib/java/src/org/apache/thrift/server/THsHaServer.java
index 354115403..2ef4b8358 100644
--- a/lib/java/src/org/apache/thrift/server/THsHaServer.java
+++ b/lib/java/src/org/apache/thrift/server/THsHaServer.java
@@ -35,7 +35,8 @@ import org.apache.thrift.transport.TNonblockingServerTransport;
public class THsHaServer extends TNonblockingServer {
public static class Args extends AbstractNonblockingServerArgs<Args> {
- private int workerThreads = 5;
+ public int minWorkerThreads = 5;
+ public int maxWorkerThreads = Integer.MAX_VALUE;
private int stopTimeoutVal = 60;
private TimeUnit stopTimeoutUnit = TimeUnit.SECONDS;
private ExecutorService executorService = null;
@@ -44,13 +45,22 @@ public class THsHaServer extends TNonblockingServer {
super(transport);
}
- public Args workerThreads(int i) {
- workerThreads = i;
+ public Args minWorkerThreads(int n) {
+ minWorkerThreads = n;
return this;
}
- public int getWorkerThreads() {
- return workerThreads;
+ public Args maxWorkerThreads(int n) {
+ maxWorkerThreads = n;
+ return this;
+ }
+
+ public int getMinWorkerThreads() {
+ return minWorkerThreads;
+ }
+
+ public int getMaxWorkerThreads() {
+ return maxWorkerThreads;
}
public int getStopTimeoutVal() {
@@ -111,13 +121,14 @@ public class THsHaServer extends TNonblockingServer {
* Helper to create an invoker pool
*/
protected static ExecutorService createInvokerPool(Args options) {
- int workerThreads = options.workerThreads;
+ int minWorkerThreads = options.minWorkerThreads;
+ int maxWorkerThreads = options.maxWorkerThreads;
int stopTimeoutVal = options.stopTimeoutVal;
TimeUnit stopTimeoutUnit = options.stopTimeoutUnit;
LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>();
- ExecutorService invoker = new ThreadPoolExecutor(workerThreads,
- workerThreads, stopTimeoutVal, stopTimeoutUnit, queue);
+ ExecutorService invoker = new ThreadPoolExecutor(minWorkerThreads,
+ maxWorkerThreads, stopTimeoutVal, stopTimeoutUnit, queue);
return invoker;
}