[
https://issues.apache.org/jira/browse/HDFS-7881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14366774#comment-14366774
]
Akira AJISAKA commented on HDFS-7881:
-------------------------------------
Thanks [~brahmareddy] for creating the patch! Two high-level comments:
* Would you create a method to get the stream length for improving readability
for {{#openInputStream}}? I'd like to make the code as follows:
{code}
} else {
long streamLength = getStreamLength(connection);
fileLength = startPos + streamLength;
// Java has a bug...
in = ...
}
(snip)
}
private static long getStreamLength(HttpURLConnection connection)
throws IOException {
...
}
{code}
* The code for parsing the range can throw {{NumberFormatException}} and
{{ArrayIndexOutOfBoundsException}}, which are unchecked. I'd like to catch
these unchecked exception and throw checked {{IOException}} to notify "failed
to get content length by parsing the content range".
Other comments:
{code}
if (connection.getResponseCode() == 206) {
{code}
* 206 should be {{HttpStatus.SC_PARTIAL_CONTENT}}.
* It would be better to add a comment "why we parse the content range". The
example is:
{code}
// Try to get the content length by parsing the content range
// because HftpFileSystem does not return the content length
// if the content is partial.
{code}
{code}
String[] str = range.substring(6).split("[-/]");
return Long.parseLong(str[1]) - Long.parseLong(str[0]) + 1;
{code}
* It would be better to comment what input is expected and how it is parsed.
(Hint: The input is expected to be created by
{{org.mortbay.jetty.InclusiveByteRange#toHeaderRangeString}}.)
> TestHftpFileSystem#testSeek fails in branch-2
> ---------------------------------------------
>
> Key: HDFS-7881
> URL: https://issues.apache.org/jira/browse/HDFS-7881
> Project: Hadoop HDFS
> Issue Type: Bug
> Affects Versions: 2.7.0
> Reporter: Akira AJISAKA
> Assignee: Brahma Reddy Battula
> Priority: Blocker
> Attachments: HDFS-7881.patch
>
>
> TestHftpFileSystem#testSeek fails in branch-2.
> {code}
> -------------------------------------------------------
> T E S T S
> -------------------------------------------------------
> Running org.apache.hadoop.hdfs.web.TestHftpFileSystem
> Tests run: 14, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 6.201 sec
> <<< FAILURE! - in org.apache.hadoop.hdfs.web.TestHftpFileSystem
> testSeek(org.apache.hadoop.hdfs.web.TestHftpFileSystem) Time elapsed: 0.054
> sec <<< ERROR!
> java.io.IOException: Content-Length is missing: {null=[HTTP/1.1 206 Partial
> Content], Date=[Wed, 04 Mar 2015 05:32:30 GMT, Wed, 04 Mar 2015 05:32:30
> GMT], Expires=[Wed, 04 Mar 2015 05:32:30 GMT, Wed, 04 Mar 2015 05:32:30 GMT],
> Connection=[close], Content-Type=[text/plain; charset=utf-8],
> Server=[Jetty(6.1.26)], Content-Range=[bytes 7-9/10], Pragma=[no-cache,
> no-cache], Cache-Control=[no-cache]}
> at
> org.apache.hadoop.hdfs.web.ByteRangeInputStream.openInputStream(ByteRangeInputStream.java:132)
> at
> org.apache.hadoop.hdfs.web.ByteRangeInputStream.getInputStream(ByteRangeInputStream.java:104)
> at
> org.apache.hadoop.hdfs.web.ByteRangeInputStream.read(ByteRangeInputStream.java:181)
> at java.io.FilterInputStream.read(FilterInputStream.java:83)
> at
> org.apache.hadoop.hdfs.web.TestHftpFileSystem.testSeek(TestHftpFileSystem.java:253)
> Results :
> Tests in error:
> TestHftpFileSystem.testSeek:253 ยป IO Content-Length is missing:
> {null=[HTTP/1....
> Tests run: 14, Failures: 0, Errors: 1, Skipped: 0
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)