You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2017/06/08 19:22:32 UTC
[18/50] [abbrv] ambari git commit: AMBARI-21174 : Files View :
properly copying the data to output stream when downloading multiple files.
(nitirajrathore)
AMBARI-21174 : Files View : properly copying the data to output stream when downloading multiple files. (nitirajrathore)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/601a7cdc
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/601a7cdc
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/601a7cdc
Branch: refs/heads/branch-feature-AMBARI-20859
Commit: 601a7cdcf5a9a8c524565c54a9a36826776ab1f6
Parents: 3b5f07f
Author: Nitiraj Singh Rathore <ni...@gmail.com>
Authored: Mon Jun 5 12:39:27 2017 +0530
Committer: Nitiraj Singh Rathore <ni...@gmail.com>
Committed: Mon Jun 5 12:40:02 2017 +0530
----------------------------------------------------------------------
.../org/apache/ambari/view/filebrowser/DownloadService.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/601a7cdc/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
----------------------------------------------------------------------
diff --git a/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java b/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
index 1334c06..81ac40d 100644
--- a/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
+++ b/contrib/views/files/src/main/java/org/apache/ambari/view/filebrowser/DownloadService.java
@@ -27,6 +27,7 @@ import org.apache.ambari.view.commons.hdfs.HdfsService;
import org.apache.ambari.view.utils.hdfs.HdfsApi;
import org.apache.ambari.view.utils.hdfs.HdfsApiException;
import org.apache.ambari.view.utils.hdfs.HdfsUtil;
+import org.apache.commons.io.IOUtils;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.security.AccessControlException;
@@ -261,11 +262,9 @@ public class DownloadService extends HdfsService {
LOG.error("Error in opening file {}. Ignoring concat of this files.", path.substring(1), ex);
continue;
}
- byte[] chunk = new byte[1024];
- while (in.read(chunk) != -1) {
- output.write(chunk);
- }
- LOG.info("concated file : {}", path);
+
+ long bytesCopied = IOUtils.copyLarge(in, output);
+ LOG.info("concated file : {}, total bytes added = {}", path, bytesCopied);
} catch (Exception ex) {
LOG.error("Error occurred : ", ex);
throw new ServiceFormattedException(ex.getMessage(), ex);