hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xkro...@apache.org
Subject [hadoop] branch trunk updated: HDFS-14250. [SBN read]. msync should always direct to active NameNode to get latest stateID. Contributed by Chao Sun.
Date Wed, 06 Feb 2019 17:55:07 GMT
This is an automated email from the ASF dual-hosted git repository.

xkrogen 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 d3de8e1  HDFS-14250. [SBN read]. msync should always direct to active NameNode to
get latest stateID. Contributed by Chao Sun.
d3de8e1 is described below

commit d3de8e162be7933be496343db4a807b6b5ca04cd
Author: Erik Krogen <xkrogen@apache.org>
AuthorDate: Wed Feb 6 09:54:47 2019 -0800

    HDFS-14250. [SBN read]. msync should always direct to active NameNode to get latest stateID.
Contributed by Chao Sun.
---
 .../hadoop/hdfs/protocol/ClientProtocol.java       |  2 +-
 .../namenode/ha/TestConsistentReadsObserver.java   | 47 +++++++++++++++++++++-
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/ClientProtocol.java
b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/ClientProtocol.java
index 260d7a2..953e48a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/ClientProtocol.java
+++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/ClientProtocol.java
@@ -1808,7 +1808,7 @@ public interface ClientProtocol {
    * @throws IOException
    */
   @Idempotent
-  @ReadOnly(isCoordinated = true)
+  @ReadOnly(activeOnly = true)
   void msync() throws IOException;
 
   /**
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestConsistentReadsObserver.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestConsistentReadsObserver.java
index fe5345d..2845670 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestConsistentReadsObserver.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestConsistentReadsObserver.java
@@ -26,6 +26,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.CommonConfigurationKeys;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdfs.DistributedFileSystem;
@@ -150,7 +151,51 @@ public class TestConsistentReadsObserver {
     assertEquals(1, readStatus.get());
   }
 
-  // @Ignore("Move to another test file")
+  @Test
+  public void testMsync() throws Exception {
+    // 0 == not completed, 1 == succeeded, -1 == failed
+    AtomicInteger readStatus = new AtomicInteger(0);
+    Configuration conf2 = new Configuration(conf);
+
+    // Disable FS cache so two different DFS clients will be used.
+    conf2.setBoolean("fs.hdfs.impl.disable.cache", true);
+    DistributedFileSystem dfs2 = (DistributedFileSystem) FileSystem.get(conf2);
+
+    // Initialize the proxies for Observer Node.
+    dfs.getClient().getHAServiceState();
+    dfs2.getClient().getHAServiceState();
+
+    // Advance Observer's state ID so it is ahead of client's.
+    dfs.mkdir(new Path("/test"), FsPermission.getDefault());
+    dfsCluster.rollEditLogAndTail(0);
+
+    dfs.mkdir(testPath, FsPermission.getDefault());
+    assertSentTo(0);
+
+    Thread reader = new Thread(() -> {
+      try {
+        // After msync, client should have the latest state ID from active.
+        // Therefore, the subsequent getFileStatus call should succeed.
+        dfs2.getClient().msync();
+        dfs2.getFileStatus(testPath);
+        readStatus.set(1);
+      } catch (IOException e) {
+        e.printStackTrace();
+        readStatus.set(-1);
+      }
+    });
+
+    reader.start();
+
+    Thread.sleep(100);
+    assertEquals(0, readStatus.get());
+
+    dfsCluster.rollEditLogAndTail(0);
+
+    GenericTestUtils.waitFor(() -> readStatus.get() != 0, 100, 10000);
+    assertEquals(1, readStatus.get());
+  }
+
   @Test
   public void testUncoordinatedCall() throws Exception {
     // make a write call so that client will be ahead of


---------------------------------------------------------------------
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