You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cl...@apache.org on 2019/04/01 19:47:13 UTC
[hadoop] branch branch-2 updated: HDFS-14399. Backport HDFS-10536
to branch-2. Contributed by Chao Sun.
This is an automated email from the ASF dual-hosted git repository.
cliang pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new d6083e9 HDFS-14399. Backport HDFS-10536 to branch-2. Contributed by Chao Sun.
d6083e9 is described below
commit d6083e99209bbf7e2ae9b8a2e4dc1e4d1cb18cf1
Author: Chen Liang <cl...@apache.org>
AuthorDate: Mon Apr 1 12:47:02 2019 -0700
HDFS-14399. Backport HDFS-10536 to branch-2. Contributed by Chao Sun.
---
.../hdfs/server/namenode/ha/EditLogTailer.java | 4 +-
.../hdfs/server/namenode/ha/TestEditLogTailer.java | 45 ++++++++++++++++++++++
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/EditLogTailer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/EditLogTailer.java
index b981c00..e21833a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/EditLogTailer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/EditLogTailer.java
@@ -465,11 +465,11 @@ public class EditLogTailer {
protected abstract T doWork() throws IOException;
public T call() throws IOException {
+ // reset the loop count on success
+ nnLoopCount = 0;
while ((cachedActiveProxy = getActiveNodeProxy()) != null) {
try {
T ret = doWork();
- // reset the loop count on success
- nnLoopCount = 0;
return ret;
} catch (RemoteException e) {
Throwable cause = e.unwrapRemoteException(StandbyException.class);
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestEditLogTailer.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestEditLogTailer.java
index 3e69e9f..223e300 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestEditLogTailer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestEditLogTailer.java
@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.TimeoutException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.permission.FsPermission;
@@ -198,6 +199,50 @@ public class TestEditLogTailer {
cluster.shutdown();
}
}
+
+ /*
+ 1. when all NN become standby nn, standby NN execute to roll log,
+ it will be failed.
+ 2. when one NN become active, standby NN roll log success.
+ */
+ @Test
+ public void testTriggersLogRollsForAllStandbyNN() throws Exception {
+ Configuration conf = getConf();
+ // Roll every 1s
+ conf.setInt(DFSConfigKeys.DFS_HA_LOGROLL_PERIOD_KEY, 1);
+ conf.setInt(DFSConfigKeys.DFS_HA_TAILEDITS_PERIOD_KEY, 1);
+ conf.setInt(DFSConfigKeys.DFS_HA_TAILEDITS_ALL_NAMESNODES_RETRY_KEY, 100);
+
+ // Have to specify IPC ports so the NNs can talk to each other.
+ MiniDFSNNTopology topology = new MiniDFSNNTopology()
+ .addNameservice(new MiniDFSNNTopology.NSConf("ns1")
+ .addNN(new MiniDFSNNTopology.NNConf("nn1")
+ .setIpcPort(ServerSocketUtil.getPort(0, 100)))
+ .addNN(new MiniDFSNNTopology.NNConf("nn2")
+ .setIpcPort(ServerSocketUtil.getPort(0, 100)))
+ .addNN(new MiniDFSNNTopology.NNConf("nn3")
+ .setIpcPort(ServerSocketUtil.getPort(0, 100))));
+
+ MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
+ .nnTopology(topology)
+ .numDataNodes(0)
+ .build();
+ try {
+ cluster.transitionToStandby(0);
+ cluster.transitionToStandby(1);
+ cluster.transitionToStandby(2);
+ try {
+ waitForLogRollInSharedDir(cluster, 3);
+ fail("After all NN become Standby state, Standby NN should roll log, " +
+ "but it will be failed");
+ } catch (TimeoutException ignore) {
+ }
+ cluster.transitionToActive(0);
+ waitForLogRollInSharedDir(cluster, 3);
+ } finally {
+ cluster.shutdown();
+ }
+ }
private static String getDirPath(int suffix) {
return DIR_PREFIX + suffix;
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org