HDFS-15356. Unify configuration dfs.ha.allow.stale.reads to DFSConfigKeys. Contributed by Xiaoqiao He.

(cherry picked from commit 178336f8a8bb291eb355bede729082f2f0382216)
This commit is contained in:
Ayush Saxena 2020-05-16 16:35:06 +05:30 committed by Wei-Chiu Chuang
parent 240cba7e6d
commit 3915d1afc7
3 changed files with 17 additions and 2 deletions

View File

@ -1168,6 +1168,9 @@ public class DFSConfigKeys extends CommonConfigurationKeys {
"dfs.ha.nn.not-become-active-in-safemode"; "dfs.ha.nn.not-become-active-in-safemode";
public static final boolean DFS_HA_NN_NOT_BECOME_ACTIVE_IN_SAFEMODE_DEFAULT = public static final boolean DFS_HA_NN_NOT_BECOME_ACTIVE_IN_SAFEMODE_DEFAULT =
false; 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 // Security-related configs
public static final String DFS_ENCRYPT_DATA_TRANSFER_KEY = "dfs.encrypt.data.transfer"; public static final String DFS_ENCRYPT_DATA_TRANSFER_KEY = "dfs.encrypt.data.transfer";

View File

@ -17,6 +17,8 @@
*/ */
package org.apache.hadoop.hdfs; 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_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_ADDRESS_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HTTPS_BIND_HOST_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. * @return true if the NN should allow read operations while in standby mode.
*/ */
public static boolean shouldAllowStandbyReads(Configuration conf) { 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) { 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);
} }
/** /**

View File

@ -4622,6 +4622,15 @@
</description> </description>
</property> </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> <property>
<name>dfs.journalnode.edits.dir</name> <name>dfs.journalnode.edits.dir</name>
<value>/tmp/hadoop/dfs/journalnode/</value> <value>/tmp/hadoop/dfs/journalnode/</value>