[
https://issues.apache.org/jira/browse/THRIFT-1954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14521039#comment-14521039
]
ASF GitHub Bot commented on THRIFT-1954:
----------------------------------------
GitHub user roshan opened a pull request:
https://github.com/apache/thrift/pull/472
[THRIFT-1954] Make it possible to use separate socket and connection
timeouts
I could have used this feature at work today. It would be useful to timeout
quickly when trying to connect but wait indefinitely on reads. This shouldn't
change the functionality of existing code since it sets both when you call the
old function, but allows you to set them separately if you want.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/roshan/thrift
THRIFT-1954_separate_socket_and_connect_timeout
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/472.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #472
----
commit 0548c01742d8fd3a55de1d516c7911720c08debc
Author: Roshan George <[email protected]>
Date: 2015-04-30T07:07:56Z
Make it possible to use separate socket and connection timeouts
----
> Allow for a separate connection timeout value
> ----------------------------------------------
>
> Key: THRIFT-1954
> URL: https://issues.apache.org/jira/browse/THRIFT-1954
> Project: Thrift
> Issue Type: Improvement
> Components: Java - Library
> Reporter: Ahmed Bashir
>
> In TSocket.java, the connect() logic uses the socket timeout value (for
> reads/writes) as the connection timeout, as well:
> {code}
> public void open() throws TTransportException {
> if (isOpen()) {
> throw new TTransportException(TTransportException.ALREADY_OPEN, "Socket
> already connected.");
> }
> if (host_.length() == 0) {
> throw new TTransportException(TTransportException.NOT_OPEN, "Cannot
> open null host.");
> }
> if (port_ <= 0) {
> throw new TTransportException(TTransportException.NOT_OPEN, "Cannot
> open without port.");
> }
> if (socket_ == null) {
> initSocket();
> }
> try {
> socket_.connect(new InetSocketAddress(host_, port_), timeout_); <---
> this value should be a separately defined
> inputStream_ = new BufferedInputStream(socket_.getInputStream(), 1024);
> {code}
> In many applications, the duration of time one is willing to wait before
> establishing a connection is not the same as the duration of time one is
> willing to wait before timing out on a read.
> For example, I may want to time out on establishing a connection after 1
> second but am willing to wait 10 seconds for long reads to complete.
> Please create a separate value that can be passed into the constructor, thanks
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)