This is an automated email from the ASF dual-hosted git repository.

surendralilhore pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 21fe77e  HDFS-14184. [SPS] Add support for URI based path in 
satisfystoragepolicy command. Contributed by Ayush Saxena.
21fe77e is described below

commit 21fe77e3ab0d3951212ba64cf80f4904f789db66
Author: Surendra Singh Lilhore <surendralilh...@apache.org>
AuthorDate: Thu Jan 3 18:36:53 2019 +0530

    HDFS-14184. [SPS] Add support for URI based path in satisfystoragepolicy 
command. Contributed by Ayush Saxena.
---
 .../hadoop/hdfs/tools/StoragePolicyAdmin.java      |  7 +++----
 .../TestStoragePolicySatisfyAdminCommands.java     | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 4 deletions(-)

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 14b31e4..98b599b 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
@@ -23,7 +23,6 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.BlockStoragePolicySpi;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hdfs.DistributedFileSystem;
 import org.apache.hadoop.hdfs.protocol.BlockStoragePolicy;
 import org.apache.hadoop.hdfs.protocol.HdfsConstants;
 import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
@@ -278,10 +277,10 @@ public class StoragePolicyAdmin extends Configured 
implements Tool {
             "policy.\nUsage: " + getLongUsage());
         return 1;
       }
-
-      final DistributedFileSystem dfs = AdminHelper.getDFS(conf);
+      Path p = new Path(path);
+      final FileSystem fs = FileSystem.get(p.toUri(), conf);
       try {
-        dfs.satisfyStoragePolicy(new Path(path));
+        fs.satisfyStoragePolicy(p);
         System.out.println("Scheduled blocks to move based on the current"
             + " storage policy on " + path);
       } catch (Exception e) {
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestStoragePolicySatisfyAdminCommands.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestStoragePolicySatisfyAdminCommands.java
index 61fccfa..e517d43 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestStoragePolicySatisfyAdminCommands.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestStoragePolicySatisfyAdminCommands.java
@@ -109,4 +109,26 @@ public class TestStoragePolicySatisfyAdminCommands {
     DFSTestUtil.waitExpectedStorageType(file, StorageType.ARCHIVE, 1, 30000,
         dfs);
   }
+
+  @Test(timeout = 30000)
+  public void testStoragePolicySatisfierCommandWithURI() throws Exception {
+    final String file = "/testStoragePolicySatisfierCommandURI";
+    DFSTestUtil.createFile(dfs, new Path(file), SIZE, REPL, 0);
+
+    final StoragePolicyAdmin admin = new StoragePolicyAdmin(conf);
+    DFSTestUtil.toolRun(admin, "-getStoragePolicy -path " + file, 0,
+        "The storage policy of " + file + " is unspecified");
+
+    DFSTestUtil.toolRun(admin,
+        "-setStoragePolicy -path " + file + " -policy COLD", 0,
+        "Set storage policy COLD on " + file.toString());
+
+    DFSTestUtil.toolRun(admin,
+        "-satisfyStoragePolicy -path " + dfs.getUri() + file, 0,
+        "Scheduled blocks to move based on the current storage policy on "
+            + dfs.getUri() + file.toString());
+
+    DFSTestUtil.waitExpectedStorageType(file, StorageType.ARCHIVE, 1, 30000,
+        dfs);
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to