knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject git commit: KNOX-450: WebHDFS HA retry should also handle RetriableException scenarios
Date Wed, 22 Oct 2014 15:42:46 GMT
Repository: knox
Updated Branches:
  refs/heads/v0.5.0 f04a0e177 -> 2154d2d8c


KNOX-450: WebHDFS HA retry should also handle RetriableException scenarios

(cherry picked from commit a63961b2015fe9b3466bd530a260d263c2c0bdb1)


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

Branch: refs/heads/v0.5.0
Commit: 2154d2d8c9fb8e6e3b65cd76231992d15284d232
Parents: f04a0e1
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Wed Oct 22 11:38:06 2014 -0400
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Wed Oct 22 11:38:42 2014 -0400

----------------------------------------------------------------------
 .../dispatch/WebHdfsHaHttpClientDispatch.java   |  2 +-
 .../hadoop/gateway/WebHdfsHaFuncTest.java       | 35 ++++++++++++++++++++
 .../webhdfs-mkdirs-safemode.json                |  5 +++
 3 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/2154d2d8/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
b/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
index c3c4916..cfa5081 100644
--- a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
+++ b/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
@@ -110,7 +110,7 @@ public class WebHdfsHaHttpClientDispatch extends HdfsDispatch {
          if (body.contains("StandbyException")) {
             throw new StandbyException();
          }
-         if (body.contains("SafeModeException")) {
+         if (body.contains("SafeModeException") || body.contains("RetriableException")) {
             throw new SafeModeException();
          }
       }

http://git-wip-us.apache.org/repos/asf/knox/blob/2154d2d8/gateway-test/src/test/java/org/apache/hadoop/gateway/WebHdfsHaFuncTest.java
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/java/org/apache/hadoop/gateway/WebHdfsHaFuncTest.java b/gateway-test/src/test/java/org/apache/hadoop/gateway/WebHdfsHaFuncTest.java
index 26456d4..6c36bb9 100644
--- a/gateway-test/src/test/java/org/apache/hadoop/gateway/WebHdfsHaFuncTest.java
+++ b/gateway-test/src/test/java/org/apache/hadoop/gateway/WebHdfsHaFuncTest.java
@@ -361,6 +361,41 @@ public class WebHdfsHaFuncTest {
    }
 
    @Test
+   public void testServerInSafeModeRetriableException() throws IOException {
+      String username = "hdfs";
+      String password = "hdfs-password";
+      //master is in safe mode
+      masterServer.expect()
+            .method("POST")
+            .pathInfo("/webhdfs/v1/user/hdfs/new")
+            .queryParam("op", "MKDIRS")
+            .queryParam("user.name", username)
+            .respond()
+            .status(HttpStatus.SC_FORBIDDEN)
+            .content(driver.getResourceBytes("webhdfs-mkdirs-safemode.json"))
+            .contentType("application/json");
+      masterServer.expect()
+            .method("POST")
+            .pathInfo("/webhdfs/v1/user/hdfs/new")
+            .queryParam("op", "MKDIRS")
+            .queryParam("user.name", username)
+            .respond()
+            .status(HttpStatus.SC_OK)
+            .content(driver.getResourceBytes("webhdfs-rename-safemode-off.json"))
+            .contentType("application/json");
+      given()
+            .auth().preemptive().basic(username, password)
+            .header("X-XSRF-Header", "jksdhfkhdsf")
+            .queryParam("op", "MKDIRS")
+            .expect()
+            .log().ifError()
+            .statusCode(HttpStatus.SC_OK)
+            .content("boolean", is(true))
+            .when().post(driver.getUrl("WEBHDFS") + "/v1/user/hdfs/new");
+      masterServer.isEmpty();
+   }
+
+   @Test
    public void testServerInSafeModeRetryLimit() throws IOException {
       String username = "hdfs";
       String password = "hdfs-password";

http://git-wip-us.apache.org/repos/asf/knox/blob/2154d2d8/gateway-test/src/test/resources/org/apache/hadoop/gateway/WebHdfsHaFuncTest/webhdfs-mkdirs-safemode.json
----------------------------------------------------------------------
diff --git a/gateway-test/src/test/resources/org/apache/hadoop/gateway/WebHdfsHaFuncTest/webhdfs-mkdirs-safemode.json
b/gateway-test/src/test/resources/org/apache/hadoop/gateway/WebHdfsHaFuncTest/webhdfs-mkdirs-safemode.json
new file mode 100644
index 0000000..bd669ef
--- /dev/null
+++ b/gateway-test/src/test/resources/org/apache/hadoop/gateway/WebHdfsHaFuncTest/webhdfs-mkdirs-safemode.json
@@ -0,0 +1,5 @@
+{"RemoteException": {
+    "exception": "RetriableException",
+    "javaClassName": "org.apache.hadoop.ipc.RetriableException",
+    "message": "org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create directory
/user/root/knox-ha/test_dir_27_0. Name node is in safe mode.\nThe reported blocks 0 needs
additional 565 blocks to reach the threshold 1.0000 of total blocks 564.\nThe number of live
datanodes 1 has reached the minimum number 0. Safe mode will be turned off automatically once
the thresholds have been reache."
+}}


Mime
View raw message