You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "James E. King, III (JIRA)" <ji...@apache.org> on 2016/06/22 02:30:58 UTC

[jira] [Commented] (THRIFT-3858) Tthreadpoolserver should throw exception when it gets RejectedExecutionException

    [ https://issues.apache.org/jira/browse/THRIFT-3858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15343216#comment-15343216 ] 

James E. King, III commented on THRIFT-3858:
--------------------------------------------

I assigned this to Java Library as a component - is that accurate?

> 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
>            Priority: Minor
>
> 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)