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

Kihwal Lee commented on HDFS-941:
---------------------------------

One thing I noticed is, Socket.isConnected() cannot be used for checking the 
connection status in this case. It returns false until the connection is made 
and then stays true after that. It will never return false after the initial 
connection is successfully made. Socket.isClosed() or SocketChannel.isOpen() 
should be used instead, assuming someone is handling SocketException and does 
Socket.close() or SocketChannel.close().  It seems the op handlers in 
DataXceiver are diligently using IOUtils.closeStream(), which will invoke 
SocketChannel.close().


{code}
- } while (s.isConnected() && socketKeepaliveTimeout > 0);
+ } while (s.isConnected() && !s.isClosed() && socketKeepaliveTimeout > 0);
{code}


Sorry for spotting this late. I just realized it while looking at HDFS-2054.

> Datanode xceiver protocol should allow reuse of a connection
> ------------------------------------------------------------
>
>                 Key: HDFS-941
>                 URL: https://issues.apache.org/jira/browse/HDFS-941
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: data-node, hdfs client
>    Affects Versions: 0.22.0
>            Reporter: Todd Lipcon
>            Assignee: bc Wong
>         Attachments: 941.22.txt, 941.22.txt, HDFS-941-1.patch, 
> HDFS-941-2.patch, HDFS-941-3.patch, HDFS-941-3.patch, HDFS-941-4.patch, 
> HDFS-941-5.patch, HDFS-941-6.22.patch, HDFS-941-6.patch, HDFS-941-6.patch, 
> HDFS-941-6.patch, fix-close-delta.txt, hdfs-941.txt, hdfs-941.txt, 
> hdfs-941.txt, hdfs-941.txt, hdfs941-1.png
>
>
> Right now each connection into the datanode xceiver only processes one 
> operation.
> In the case that an operation leaves the stream in a well-defined state (eg a 
> client reads to the end of a block successfully) the same connection could be 
> reused for a second operation. This should improve random read performance 
> significantly.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to