You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2013/03/24 21:27:59 UTC
git commit: THRIFT-1869 TThreadPoolServer (java) dies when threadpool
is consumed Patch: Brock Noland
Updated Branches:
refs/heads/master 3661867fe -> ce6d1d709
THRIFT-1869 TThreadPoolServer (java) dies when threadpool is consumed
Patch: Brock Noland
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/ce6d1d70
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/ce6d1d70
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/ce6d1d70
Branch: refs/heads/master
Commit: ce6d1d709aaaf33d2cdfc7415a6e95b10faac2e5
Parents: 3661867
Author: Roger Meier <ro...@apache.org>
Authored: Sun Mar 24 21:26:17 2013 +0100
Committer: Roger Meier <ro...@apache.org>
Committed: Sun Mar 24 21:26:17 2013 +0100
----------------------------------------------------------------------
.../apache/thrift/server/TThreadPoolServer.java | 20 ++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/ce6d1d70/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
----------------------------------------------------------------------
diff --git a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
index 19e51af..38dfd58 100644
--- a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
+++ b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java
@@ -20,6 +20,7 @@
package org.apache.thrift.server;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -121,7 +122,24 @@ public class TThreadPoolServer extends TServer {
try {
TTransport client = serverTransport_.accept();
WorkerProcess wp = new WorkerProcess(client);
- executorService_.execute(wp);
+ while(true) {
+ int rejections = 0;
+ try {
+ executorService_.execute(wp);
+ break;
+ } catch(RejectedExecutionException ex) {
+ LOGGER.warn("ExecutorService rejected client " + (++rejections) +
+ " times(s)", ex);
+ try {
+ TimeUnit.SECONDS.sleep(1);
+ } catch (InterruptedException e) {
+ LOGGER.warn("Interrupted while waiting to place client on" +
+ " executor queue.");
+ Thread.currentThread().interrupt();
+ break;
+ }
+ }
+ }
} catch (TTransportException ttx) {
if (!stopped_) {
++failureCount;