You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jf...@apache.org on 2015/06/26 14:59:37 UTC
thrift git commit: THRIFT-3202: Allow HSHAServer to configure min and
max worker threads separately. Client: java Patch: Pankaj Kumar
Repository: thrift
Updated Branches:
refs/heads/master 94d0679f4 -> 2238adabb
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
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/2238adab
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/2238adab
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/2238adab
Branch: refs/heads/master
Commit: 2238adabbc5317ab59ee1b13d4df4e1d4d889c73
Parents: 94d0679
Author: jfarrell <jf...@apache.org>
Authored: Fri Jun 26 08:58:32 2015 -0400
Committer: jfarrell <jf...@apache.org>
Committed: Fri Jun 26 08:58:32 2015 -0400
----------------------------------------------------------------------
.../org/apache/thrift/server/THsHaServer.java | 27 ++++++++++++++------
1 file changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/2238adab/lib/java/src/org/apache/thrift/server/THsHaServer.java
----------------------------------------------------------------------
diff --git a/lib/java/src/org/apache/thrift/server/THsHaServer.java b/lib/java/src/org/apache/thrift/server/THsHaServer.java
index 3541154..2ef4b83 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;
}