Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 229DD19DA9 for ; Tue, 5 Apr 2016 19:30:54 +0000 (UTC) Received: (qmail 68068 invoked by uid 500); 5 Apr 2016 19:30:40 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 65360 invoked by uid 500); 5 Apr 2016 19:30:38 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 60285 invoked by uid 99); 5 Apr 2016 19:30:35 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Apr 2016 19:30:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 47ECFE78B1; Tue, 5 Apr 2016 19:30:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aengineer@apache.org To: common-commits@hadoop.apache.org Date: Tue, 05 Apr 2016 19:31:04 -0000 Message-Id: <841d11b971134b738cb585d376616ac7@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [31/50] [abbrv] hadoop git commit: HADOOP-12967. Remove FileUtil#copyMerge. Contributed by Brahma Reddy Battula. HADOOP-12967. Remove FileUtil#copyMerge. Contributed by Brahma Reddy Battula. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/da614ca5 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/da614ca5 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/da614ca5 Branch: refs/heads/HDFS-1312 Commit: da614ca5dc26562d7ecd5d7c5743fa52c3c17342 Parents: 1e6f929 Author: Akira Ajisaka Authored: Mon Apr 4 17:46:56 2016 +0900 Committer: Akira Ajisaka Committed: Mon Apr 4 17:48:08 2016 +0900 ---------------------------------------------------------------------- .../java/org/apache/hadoop/fs/FileUtil.java | 42 -------------- .../java/org/apache/hadoop/fs/TestFileUtil.java | 58 -------------------- 2 files changed, 100 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/da614ca5/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java index b855c48..e2d6ecd 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java @@ -23,7 +23,6 @@ import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Enumeration; import java.util.List; import java.util.Map; @@ -381,47 +380,6 @@ public class FileUtil { } - @Deprecated - /** Copy all files in a directory to one output file (merge). */ - public static boolean copyMerge(FileSystem srcFS, Path srcDir, - FileSystem dstFS, Path dstFile, - boolean deleteSource, - Configuration conf, String addString) throws IOException { - dstFile = checkDest(srcDir.getName(), dstFS, dstFile, false); - - if (!srcFS.getFileStatus(srcDir).isDirectory()) - return false; - - OutputStream out = dstFS.create(dstFile); - - try { - FileStatus contents[] = srcFS.listStatus(srcDir); - Arrays.sort(contents); - for (int i = 0; i < contents.length; i++) { - if (contents[i].isFile()) { - InputStream in = srcFS.open(contents[i].getPath()); - try { - IOUtils.copyBytes(in, out, conf, false); - if (addString!=null) - out.write(addString.getBytes("UTF-8")); - - } finally { - in.close(); - } - } - } - } finally { - out.close(); - } - - - if (deleteSource) { - return srcFS.delete(srcDir, true); - } else { - return true; - } - } - /** Copy local files to a FileSystem. */ public static boolean copy(File src, FileSystem dstFS, Path dst, http://git-wip-us.apache.org/repos/asf/hadoop/blob/da614ca5/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java index f7464b7..a9ef5c0 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileUtil.java @@ -19,11 +19,9 @@ package org.apache.hadoop.fs; import org.junit.*; -import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; import java.net.InetAddress; @@ -49,7 +47,6 @@ import org.apache.hadoop.util.StringUtils; import org.apache.tools.tar.TarEntry; import org.apache.tools.tar.TarOutputStream; -import javax.print.attribute.URISyntax; import static org.junit.Assert.*; import static org.mockito.Mockito.mock; @@ -526,61 +523,6 @@ public class TestFileUtil { validateAndSetWritablePermissions(false, ret); } - @Test (timeout = 30000) - public void testCopyMergeSingleDirectory() throws IOException { - setupDirs(); - boolean copyMergeResult = copyMerge("partitioned", "tmp/merged"); - Assert.assertTrue("Expected successful copyMerge result.", copyMergeResult); - File merged = new File(TEST_DIR, "tmp/merged"); - Assert.assertTrue("File tmp/merged must exist after copyMerge.", - merged.exists()); - BufferedReader rdr = new BufferedReader(new FileReader(merged)); - - try { - Assert.assertEquals("Line 1 of merged file must contain \"foo\".", - "foo", rdr.readLine()); - Assert.assertEquals("Line 2 of merged file must contain \"bar\".", - "bar", rdr.readLine()); - Assert.assertNull("Expected end of file reading merged file.", - rdr.readLine()); - } - finally { - rdr.close(); - } - } - - /** - * Calls FileUtil.copyMerge using the specified source and destination paths. - * Both source and destination are assumed to be on the local file system. - * The call will not delete source on completion and will not add an - * additional string between files. - * @param src String non-null source path. - * @param dst String non-null destination path. - * @return boolean true if the call to FileUtil.copyMerge was successful. - * @throws IOException if an I/O error occurs. - */ - @SuppressWarnings("deprecation") - private boolean copyMerge(String src, String dst) - throws IOException { - Configuration conf = new Configuration(); - FileSystem fs = FileSystem.getLocal(conf); - final boolean result; - - try { - Path srcPath = new Path(TEST_ROOT_DIR, src); - Path dstPath = new Path(TEST_ROOT_DIR, dst); - boolean deleteSource = false; - String addString = null; - result = FileUtil.copyMerge(fs, srcPath, fs, dstPath, deleteSource, conf, - addString); - } - finally { - fs.close(); - } - - return result; - } - /** * Test that getDU is able to handle cycles caused due to symbolic links * and that directory sizes are not added to the final calculated size