compare with maxLength after getting all file status

This commit is contained in:
gaoyang 2017-07-06 11:22:31 +08:00
parent 1d93d3db81
commit dcb8648895
2 changed files with 9 additions and 13 deletions

View file

@ -18,6 +18,7 @@
package org.apache.zeppelin.file;
import java.io.IOException;
import java.net.URL;
import java.net.HttpURLConnection;
import java.io.BufferedReader;
@ -134,21 +135,14 @@ public class HDFSCommand {
int responseCode = con.getResponseCode();
logger.info("Sending 'GET' request to URL : " + hdfsUrl);
logger.info("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
int i = 0;
while ((inputLine = in.readLine()) != null) {
if (inputLine.length() < maxLength)
try (BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));) {
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
i++;
if (i >= maxLength)
break;
}
}
in.close();
return response.toString();
}
return null;

View file

@ -217,8 +217,10 @@ public class HDFSFileInterpreter extends FileInterpreter {
allFiles.FileStatuses != null &&
allFiles.FileStatuses.FileStatus != null)
{
for (OneFileStatus fs : allFiles.FileStatuses.FileStatus)
for (int index = 0; index < cmd.maxLength; index++) {
OneFileStatus fs = allFiles.FileStatuses.FileStatus[index];
all = all + listOne(path, fs) + '\n';
}
}
}
return all;