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 we...@apache.org on 2020/05/18 17:11:48 UTC
[hadoop] 01/02: HDFS-15356. Unify configuration
`dfs.ha.allow.stale.reads` to DFSConfigKeys. Contributed by Xiaoqiao He.
This is an automated email from the ASF dual-hosted git repository.
weichiu pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git
commit 3915d1afc7c2189b788f0e773949895d1ab0780b
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Sat May 16 16:35:06 2020 +0530
HDFS-15356. Unify configuration `dfs.ha.allow.stale.reads` to DFSConfigKeys. Contributed by Xiaoqiao He.
(cherry picked from commit 178336f8a8bb291eb355bede729082f2f0382216)
---
.../src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java | 3 +++
.../hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java | 7 +++++--
.../hadoop-hdfs/src/main/resources/hdfs-default.xml | 9 +++++++++
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java
index 2e2b7db..e4a710f 100755
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java
@@ -1168,6 +1168,9 @@ public class DFSConfigKeys extends CommonConfigurationKeys {
"dfs.ha.nn.not-become-active-in-safemode";
public static final boolean DFS_HA_NN_NOT_BECOME_ACTIVE_IN_SAFEMODE_DEFAULT =
false;
+ public static final String DFS_HA_ALLOW_STALE_READ_KEY =
+ "dfs.ha.allow.stale.reads";
+ public static final boolean DFS_HA_ALLOW_STALE_READ_DEFAULT = false;
// Security-related configs
public static final String DFS_ENCRYPT_DATA_TRANSFER_KEY = "dfs.encrypt.data.transfer";
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java
index aebc28a..43e76c7 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java
@@ -17,6 +17,8 @@
*/
package org.apache.hadoop.hdfs;
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HA_ALLOW_STALE_READ_DEFAULT;
+import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HA_ALLOW_STALE_READ_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HA_NAMENODE_ID_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HTTPS_ADDRESS_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HTTPS_BIND_HOST_KEY;
@@ -220,11 +222,12 @@ public class HAUtil {
* @return true if the NN should allow read operations while in standby mode.
*/
public static boolean shouldAllowStandbyReads(Configuration conf) {
- return conf.getBoolean("dfs.ha.allow.stale.reads", false);
+ return conf.getBoolean(DFS_HA_ALLOW_STALE_READ_KEY,
+ DFS_HA_ALLOW_STALE_READ_DEFAULT);
}
public static void setAllowStandbyReads(Configuration conf, boolean val) {
- conf.setBoolean("dfs.ha.allow.stale.reads", val);
+ conf.setBoolean(DFS_HA_ALLOW_STALE_READ_KEY, val);
}
/**
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml
index 7c42e0d..9c31c18 100755
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml
@@ -4623,6 +4623,15 @@
</property>
<property>
+ <name>dfs.ha.allow.stale.reads</name>
+ <value>false</value>
+ <description>
+ If true, a NameNode in Standby state can process read request and the result
+ could be stale.
+ </description>
+</property>
+
+<property>
<name>dfs.journalnode.edits.dir</name>
<value>/tmp/hadoop/dfs/journalnode/</value>
<description>
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org