ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From niti...@apache.org
Subject ambari git commit: AMBARI-21174 : Files View : properly copying the data to output stream when downloading multiple files. (nitirajrathore)
Date Mon, 05 Jun 2017 07:10:37 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 5fe4b5f32 -> 94055d25d


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/94055d25
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/94055d25
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/94055d25

Branch: refs/heads/branch-2.5
Commit: 94055d25db8b21cadec140d21da436e50d9c7cee
Parents: 5fe4b5f
Author: Nitiraj Singh Rathore <nitiraj.rathore@gmail.com>
Authored: Mon Jun 5 12:39:27 2017 +0530
Committer: Nitiraj Singh Rathore <nitiraj.rathore@gmail.com>
Committed: Mon Jun 5 12:39:27 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/94055d25/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 10b7c9e..7a1c7a1 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);


Mime
View raw message