hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject [32/50] [abbrv] hadoop git commit: HDFS-13490. RBF: Fix setSafeMode in the Router. Contributed by Inigo Goiri.
Date Wed, 02 May 2018 19:22:07 GMT
HDFS-13490. RBF: Fix setSafeMode in the Router. Contributed by Inigo Goiri.

(cherry picked from commit b06601acce38ed60b726b99e2830f38a1ee3d2b5)


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

Branch: refs/heads/YARN-8200
Commit: cc5416d94aa73bd3fb550a6f0df8e795f34fc5ab
Parents: db9da43
Author: Yiqun Lin <yqlin@apache.org>
Authored: Tue Apr 24 11:25:23 2018 +0800
Committer: Yiqun Lin <yqlin@apache.org>
Committed: Tue Apr 24 11:29:06 2018 +0800

----------------------------------------------------------------------
 .../federation/router/RouterRpcServer.java      |  3 +-
 .../server/federation/router/TestRouterRpc.java | 17 ++++
 .../server/federation/router/TestSafeMode.java  | 82 ++++++++++++++++++++
 3 files changed, 101 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/cc5416d9/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java
index 8a0cf27..2897823 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java
@@ -1356,7 +1356,8 @@ public class RouterRpcServer extends AbstractService
         action, isChecked);
     Set<FederationNamespaceInfo> nss = namenodeResolver.getNamespaces();
     Map<FederationNamespaceInfo, Boolean> results =
-        rpcClient.invokeConcurrent(nss, method, true, true, Boolean.class);
+        rpcClient.invokeConcurrent(
+            nss, method, true, !isChecked, Boolean.class);
 
     // We only report true if all the name space are in safe mode
     int numSafemode = 0;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/cc5416d9/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
index d25f806..d689b4c 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestRouterRpc.java
@@ -1034,6 +1034,23 @@ public class TestRouterRpc {
     boolean nnSafemode =
         nnProtocol.setSafeMode(SafeModeAction.SAFEMODE_GET, false);
     assertEquals(nnSafemode, routerSafemode);
+
+    routerSafemode =
+        routerProtocol.setSafeMode(SafeModeAction.SAFEMODE_GET, true);
+    nnSafemode =
+        nnProtocol.setSafeMode(SafeModeAction.SAFEMODE_GET, true);
+    assertEquals(nnSafemode, routerSafemode);
+
+    assertFalse(routerProtocol.setSafeMode(
+        SafeModeAction.SAFEMODE_GET, false));
+    assertTrue(routerProtocol.setSafeMode(
+        SafeModeAction.SAFEMODE_ENTER, false));
+    assertTrue(routerProtocol.setSafeMode(
+        SafeModeAction.SAFEMODE_GET, false));
+    assertFalse(routerProtocol.setSafeMode(
+        SafeModeAction.SAFEMODE_LEAVE, false));
+    assertFalse(routerProtocol.setSafeMode(
+        SafeModeAction.SAFEMODE_GET, false));
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/hadoop/blob/cc5416d9/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestSafeMode.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestSafeMode.java
b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestSafeMode.java
new file mode 100644
index 0000000..d040b7a
--- /dev/null
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/TestSafeMode.java
@@ -0,0 +1,82 @@
+/**
+ * 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.hdfs.server.federation.router;
+
+import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.NAMENODES;
+
+import java.io.IOException;
+
+import org.apache.hadoop.hdfs.protocol.ClientProtocol;
+import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
+import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster;
+import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.RouterContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test the SafeMode.
+ */
+public class TestSafeMode {
+
+  /** Federated HDFS cluster. */
+  private MiniRouterDFSCluster cluster;
+
+  @Before
+  public  void setup() throws Exception {
+    cluster = new MiniRouterDFSCluster(true, 2);
+
+    // Start NNs and DNs and wait until ready
+    cluster.startCluster();
+
+    // Start routers with only an RPC service
+    cluster.startRouters();
+
+    // Register and verify all NNs with all routers
+    cluster.registerNamenodes();
+    cluster.waitNamenodeRegistration();
+
+    // Setup the mount table
+    cluster.installMockLocations();
+
+    // Making one Namenodes active per nameservice
+    if (cluster.isHighAvailability()) {
+      for (String ns : cluster.getNameservices()) {
+        cluster.switchToActive(ns, NAMENODES[0]);
+        cluster.switchToStandby(ns, NAMENODES[1]);
+      }
+    }
+    cluster.waitActiveNamespaces();
+  }
+
+  @After
+  public void teardown() throws IOException {
+    if (cluster != null) {
+      cluster.shutdown();
+      cluster = null;
+    }
+  }
+
+  @Test
+  public void testProxySetSafemode() throws Exception {
+    RouterContext routerContext = cluster.getRandomRouter();
+    ClientProtocol routerProtocol = routerContext.getClient().getNamenode();
+    routerProtocol.setSafeMode(SafeModeAction.SAFEMODE_GET, true);
+    routerProtocol.setSafeMode(SafeModeAction.SAFEMODE_GET, false);
+  }
+}


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


Mime
View raw message