[
https://issues.apache.org/jira/browse/THRIFT-3858?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
James E. King, III updated THRIFT-3858:
---------------------------------------
Component/s: Java - Library
> Tthreadpoolserver should throw exception when it gets
> RejectedExecutionException
> --------------------------------------------------------------------------------
>
> Key: THRIFT-3858
> URL: https://issues.apache.org/jira/browse/THRIFT-3858
> Project: Thrift
> Issue Type: Improvement
> Components: Java - Library
> Affects Versions: 0.9.3
> Reporter: Vihang Karajgaonkar
>
> In the TThreadpoolServer class when for any reason the executor server
> receives a RejectedExecutionException, it just logs it and closes the client
> connection. Client has no way to find out why its connection request was
> rejected. If TThreadpoolServer could return some error information back to
> client, it would be able to handle the exception gracefully.
> Eg: In Hive project the clients use Thrift library (0.9.3) for connections
> from client to hiveserver2. If for some reason the maximum threads (in this
> case concurrent client sessions) are reached, the next new session is unable
> to connect and the client code has no way to figure why the connection
> request failed. If client receives back an error saying that max threads have
> been reached, client could display useful error messages to the user so that
> corrective action can be taken.
> {code}
> try {
> executorService_.execute(wp);
> break;
> } catch(Throwable t) {
> if (t instanceof RejectedExecutionException) {
> retryCount++;
> try {
> if (remainTimeInMillis > 0) {
> //do a truncated 20 binary exponential backoff sleep
> long sleepTimeInMillis = ((long) (random.nextDouble() *
> (1L << Math.min(retryCount, 20)))) *
> beBackoffSlotInMillis;
> sleepTimeInMillis = Math.min(sleepTimeInMillis,
> remainTimeInMillis);
> TimeUnit.MILLISECONDS.sleep(sleepTimeInMillis);
> remainTimeInMillis = remainTimeInMillis - sleepTimeInMillis;
> } else {
> client.close();
> wp = null;
> LOGGER.warn("Task has been rejected by ExecutorService " +
> retryCount
> + " times till timedout, reason: " + t);
> break;
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)