Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3E9B8200D4A for ; Tue, 28 Nov 2017 19:42:29 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 3CEEC160C07; Tue, 28 Nov 2017 18:42:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5B71D160BE7 for ; Tue, 28 Nov 2017 19:42:28 +0100 (CET) Received: (qmail 91268 invoked by uid 500); 28 Nov 2017 18:42:27 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 91259 invoked by uid 99); 28 Nov 2017 18:42:27 -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, 28 Nov 2017 18:42:27 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5FE98E0206; Tue, 28 Nov 2017 18:42:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: surendralilhore@apache.org To: common-commits@hadoop.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: hadoop git commit: HDFS-12857. StoragePolicyAdmin should support schema based path. Contributed by Surendra Singh Lilhore. Date: Tue, 28 Nov 2017 18:42:27 +0000 (UTC) archived-at: Tue, 28 Nov 2017 18:42:29 -0000 Repository: hadoop Updated Branches: refs/heads/trunk a2c7a73e3 -> 30941d99c HDFS-12857. StoragePolicyAdmin should support schema based path. Contributed by Surendra Singh Lilhore. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/30941d99 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/30941d99 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/30941d99 Branch: refs/heads/trunk Commit: 30941d99c9014431981eeb09ab24e90bef629fee Parents: a2c7a73 Author: Surendra Singh Lilhore Authored: Tue Nov 28 23:57:03 2017 +0530 Committer: Surendra Singh Lilhore Committed: Tue Nov 28 23:57:03 2017 +0530 ---------------------------------------------------------------------- .../hadoop/hdfs/tools/StoragePolicyAdmin.java | 6 ++-- .../tools/TestViewFSStoragePolicyCommands.java | 37 ++++++++++++++++++-- 2 files changed, 38 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/30941d99/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/StoragePolicyAdmin.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/StoragePolicyAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/StoragePolicyAdmin.java index d5e5b4d..aeb10d9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/StoragePolicyAdmin.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/StoragePolicyAdmin.java @@ -153,7 +153,7 @@ public class StoragePolicyAdmin extends Configured implements Tool { } Path p = new Path(path); - final FileSystem fs = FileSystem.get(conf); + final FileSystem fs = FileSystem.get(p.toUri(), conf); try { FileStatus status; try { @@ -233,7 +233,7 @@ public class StoragePolicyAdmin extends Configured implements Tool { return 1; } Path p = new Path(path); - final FileSystem fs = FileSystem.get(conf); + final FileSystem fs = FileSystem.get(p.toUri(), conf); try { fs.setStoragePolicy(p, policyName); System.out.println("Set storage policy " + policyName + " on " + path); @@ -279,7 +279,7 @@ public class StoragePolicyAdmin extends Configured implements Tool { } Path p = new Path(path); - final FileSystem fs = FileSystem.get(conf); + final FileSystem fs = FileSystem.get(p.toUri(), conf); try { fs.unsetStoragePolicy(p); System.out.println("Unset storage policy from " + path); http://git-wip-us.apache.org/repos/asf/hadoop/blob/30941d99/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestViewFSStoragePolicyCommands.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestViewFSStoragePolicyCommands.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestViewFSStoragePolicyCommands.java index b3bb3c4..3a94959 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestViewFSStoragePolicyCommands.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestViewFSStoragePolicyCommands.java @@ -21,18 +21,19 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.fs.FsConstants; - import org.apache.hadoop.fs.viewfs.ConfigUtil; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.HdfsConfiguration; import org.apache.hadoop.hdfs.DFSTestUtil; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.MiniDFSNNTopology; - +import org.apache.hadoop.hdfs.protocol.BlockStoragePolicy; +import org.apache.hadoop.hdfs.server.blockmanagement.BlockStoragePolicySuite; import org.junit.Before; import org.junit.Test; import java.io.IOException; +import java.net.InetSocketAddress; /** * Test StoragePolicyAdmin commands with ViewFileSystem. @@ -77,4 +78,36 @@ public class TestViewFSStoragePolicyCommands extends TestStoragePolicyCommands { DFSTestUtil.toolRun(admin, "-getStoragePolicy -path /", 2, "is not supported for filesystem viewfs on path /"); } + + @Test + public void testStoragePolicyCommandPathWithSchema() throws Exception { + Path base1 = new Path("/user1"); + final Path bar = new Path(base1, "bar"); + DFSTestUtil.createFile(cluster.getFileSystem(0), bar, 1024, (short) 1, 0); + + // Test with hdfs:// schema + String pathHdfsSchema = "hdfs://" + + cluster.getNameNode(0).getClientNamenodeAddress() + "/" + + bar.toString(); + checkCommandsWithUriPath(pathHdfsSchema); + + // Test with webhdfs:// schema + InetSocketAddress httpAddress = cluster.getNameNode(0).getHttpAddress(); + String pathWebhdfsSchema = "webhdfs://" + httpAddress.getHostName() + ":" + + httpAddress.getPort() + "/" + bar.toString(); + checkCommandsWithUriPath(pathWebhdfsSchema); + } + + private void checkCommandsWithUriPath(String pathWithSchema) throws Exception{ + final StoragePolicyAdmin admin = new StoragePolicyAdmin(conf); + DFSTestUtil.toolRun(admin, "-setStoragePolicy -path " + pathWithSchema + + " -policy WARM", 0, "Set storage policy WARM on " + pathWithSchema); + final BlockStoragePolicySuite suite = BlockStoragePolicySuite + .createDefaultSuite(); + final BlockStoragePolicy warm = suite.getPolicy("WARM"); + DFSTestUtil.toolRun(admin, "-getStoragePolicy -path " + pathWithSchema, 0, + "The storage policy of " + pathWithSchema + ":\n" + warm); + DFSTestUtil.toolRun(admin, "-unsetStoragePolicy -path " + pathWithSchema, 0, + "Unset storage policy from " + pathWithSchema); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org