From common-commits-return-93015-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Wed Feb 6 17:55:09 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 2D5AF180679 for ; Wed, 6 Feb 2019 18:55:09 +0100 (CET) Received: (qmail 938 invoked by uid 500); 6 Feb 2019 17:55:08 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 929 invoked by uid 99); 6 Feb 2019 17:55:08 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Feb 2019 17:55:08 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 7E10880671; Wed, 6 Feb 2019 17:55:07 +0000 (UTC) Date: Wed, 06 Feb 2019 17:55:07 +0000 To: "common-commits@hadoop.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. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154947570671.23863.1737505124581996307@gitbox.apache.org> From: xkrogen@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: hadoop X-Git-Refname: refs/heads/trunk X-Git-Reftype: branch X-Git-Oldrev: 711d22f166b4bb76005ae876a9d7ff7238991f90 X-Git-Newrev: d3de8e162be7933be496343db4a807b6b5ca04cd X-Git-Rev: d3de8e162be7933be496343db4a807b6b5ca04cd X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 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