knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From su...@apache.org
Subject knox git commit: KNOX-813 Added rename in HDFS for ClientDSL (Vincent Devillers/Khanh Maudoux via Sumit Gupta)
Date Thu, 05 Jan 2017 20:23:28 GMT
Repository: knox
Updated Branches:
  refs/heads/master fb0dc061f -> 978826a6f


KNOX-813 Added rename in HDFS for ClientDSL (Vincent Devillers/Khanh Maudoux via Sumit Gupta)


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/978826a6
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/978826a6
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/978826a6

Branch: refs/heads/master
Commit: 978826a6f7746ee0531e10ff257fd89720b8cc16
Parents: fb0dc06
Author: Sumit Gupta <sumit@apache.org>
Authored: Thu Jan 5 15:21:40 2017 -0500
Committer: Sumit Gupta <sumit@apache.org>
Committed: Thu Jan 5 15:21:40 2017 -0500

----------------------------------------------------------------------
 .../apache/hadoop/gateway/shell/hdfs/Hdfs.java  |  4 ++
 .../hadoop/gateway/shell/hdfs/Rename.java       | 69 ++++++++++++++++++++
 2 files changed, 73 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/978826a6/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Hdfs.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Hdfs.java b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Hdfs.java
index b5b8bf3..ffbf22c 100644
--- a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Hdfs.java
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Hdfs.java
@@ -23,6 +23,10 @@ public class Hdfs {
 
   static String SERVICE_PATH = "/webhdfs/v1";
 
+  public static Rename.Request rename( Hadoop session ) {
+    return new Rename.Request( session );
+  }
+
   public static Ls.Request ls( Hadoop session ) {
     return new Ls.Request( session );
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/978826a6/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Rename.java
----------------------------------------------------------------------
diff --git a/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Rename.java
b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Rename.java
new file mode 100644
index 0000000..18a6f02
--- /dev/null
+++ b/gateway-shell/src/main/java/org/apache/hadoop/gateway/shell/hdfs/Rename.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.shell.hdfs;
+
+import org.apache.hadoop.gateway.shell.AbstractRequest;
+import org.apache.hadoop.gateway.shell.EmptyResponse;
+import org.apache.hadoop.gateway.shell.Hadoop;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.utils.URIBuilder;
+
+import java.util.concurrent.Callable;
+
+public class Rename {
+
+  public static class Request extends AbstractRequest<Rename.Response> {
+
+    private String file;
+    private String to;
+
+    Request(Hadoop session) {
+      super(session);
+    }
+
+    public Rename.Request file(String file) {
+      this.file = file;
+      return this;
+    }
+
+    public Rename.Request to(String file) {
+      this.to = file;
+      return this;
+    }
+
+    protected Callable<Rename.Response> callable() {
+      return new Callable<Rename.Response>() {
+        @Override
+        public Rename.Response call() throws Exception {
+          URIBuilder uri = uri(Hdfs.SERVICE_PATH, file);
+          addQueryParam(uri, "op", "RENAME");
+          addQueryParam(uri, "destination", to);
+          HttpPut request = new HttpPut(uri.build());
+          return new Rename.Response(execute(request));
+        }
+      };
+    }
+  }
+
+  public static class Response extends EmptyResponse {
+    Response(HttpResponse response) {
+      super(response);
+    }
+  }
+}
\ No newline at end of file


Mime
View raw message