HDFS-14858. [SBN read] Allow configurably enable/disable AlignmentContext on NameNode. Contributed by Chen Liang.

This commit is contained in:
Chen Liang 2019-10-02 16:38:20 -07:00
parent 559ee277f5
commit 1303255aee
8 changed files with 50 additions and 2 deletions

View File

@ -1357,6 +1357,10 @@ public class DFSConfigKeys extends CommonConfigurationKeys {
"dfs.namenode.send.qop.enabled";
public static final boolean DFS_NAMENODE_SEND_QOP_ENABLED_DEFAULT = false;
public static final String DFS_NAMENODE_STATE_CONTEXT_ENABLED_KEY =
"dfs.namenode.state.context.enabled";
public static final boolean DFS_NAMENODE_STATE_CONTEXT_ENABLED_DEFAULT = false;
// dfs.client.retry confs are moved to HdfsClientConfigKeys.Retry
@Deprecated
public static final String DFS_CLIENT_RETRY_POLICY_ENABLED_KEY

View File

@ -27,6 +27,8 @@
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_HANDLER_COUNT_DEFAULT;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_HANDLER_COUNT_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_AUXILIARY_KEY;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_STATE_CONTEXT_ENABLED_DEFAULT;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_STATE_CONTEXT_ENABLED_KEY;
import static org.apache.hadoop.hdfs.server.common.HdfsServerConstants.MAX_PATH_DEPTH;
import static org.apache.hadoop.hdfs.server.common.HdfsServerConstants.MAX_PATH_LENGTH;
import static org.apache.hadoop.util.Time.now;
@ -447,6 +449,16 @@ public NameNodeRpcServer(Configuration conf, NameNode nn)
}
LOG.info("RPC server is binding to " + bindHost + ":" + rpcAddr.getPort());
boolean enableStateContext = conf.getBoolean(
DFS_NAMENODE_STATE_CONTEXT_ENABLED_KEY,
DFS_NAMENODE_STATE_CONTEXT_ENABLED_DEFAULT);
LOG.info("Enable NameNode state context:" + enableStateContext);
GlobalStateIdContext stateIdContext = null;
if (enableStateContext) {
stateIdContext = new GlobalStateIdContext((namesystem));
}
clientRpcServer = new RPC.Builder(conf)
.setProtocol(
org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolPB.class)
@ -456,7 +468,7 @@ public NameNodeRpcServer(Configuration conf, NameNode nn)
.setNumHandlers(handlerCount)
.setVerbose(false)
.setSecretManager(namesystem.getDelegationTokenSecretManager())
.setAlignmentContext(new GlobalStateIdContext(namesystem))
.setAlignmentContext(stateIdContext)
.build();
// Add all the RPC protocols that the namenode implements

View File

@ -3302,6 +3302,17 @@
</description>
</property>
<property>
<name>dfs.namenode.state.context.enabled</name>
<value>false</value>
<description>
Whether enable namenode sending back its current txnid back to client.
Setting this to true is required by Consistent Read from Standby feature.
But for regular cases, this should be set to false to avoid the overhead
of updating and maintaining this state.
</description>
</property>
<property>
<name>dfs.namenode.ec.system.default.policy</name>
<value>RS-6-3-1024k</value>

View File

@ -120,6 +120,20 @@ Deployment
To enable consistent reads from Observer NameNode, you'll need to add a
few configurations to your **hdfs-site.xml**:
* **dfs.namenode.state.context.enabled** - to enable NameNode to maintain
and update server state and id.
This will lead to NameNode creating alignment context instance, which
keeps track of current server state id. Server state id will be carried
back to client. It is disabled by default to optimize performance of
Observer read cases. But this is **required to be turned on**
for the Observer NameNode feature.
<property>
<name>dfs.namenode.state.context.enabled</name>
<value>true</value>
</property>
* **dfs.ha.tail-edits.in-progress** - to enable fast tailing on
in-progress edit logs.

View File

@ -94,6 +94,7 @@ public static void startUpCluster() throws IOException {
CONF.setBoolean(String.format(
"fs.%s.impl.disable.cache", HdfsConstants.HDFS_URI_SCHEME), true);
CONF.setInt(DFSConfigKeys.DFS_REPLICATION_KEY, NUMDATANODES);
CONF.setBoolean(DFSConfigKeys.DFS_NAMENODE_STATE_CONTEXT_ENABLED_KEY, true);
qjmhaCluster = HATestUtil.setUpObserverCluster(CONF, 1, NUMDATANODES, true);
cluster = qjmhaCluster.getDfsCluster();

View File

@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hdfs.server.namenode.ha;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_STATE_CONTEXT_ENABLED_KEY;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -71,6 +72,7 @@ public class TestConsistentReadsObserver {
@BeforeClass
public static void startUpCluster() throws Exception {
conf = new Configuration();
conf.setBoolean(DFS_NAMENODE_STATE_CONTEXT_ENABLED_KEY, true);
// disable fast tailing here because this test's assertions are based on the
// timing of explicitly called rollEditLogAndTail. Although this means this
// test takes some time to run

View File

@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hdfs.server.namenode.ha;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_STATE_CONTEXT_ENABLED_KEY;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@ -46,6 +47,7 @@ public class TestMultiObserverNode {
@BeforeClass
public static void startUpCluster() throws Exception {
conf = new Configuration();
conf.setBoolean(DFS_NAMENODE_STATE_CONTEXT_ENABLED_KEY, true);
qjmhaCluster = HATestUtil.setUpObserverCluster(conf, 2, 0, true);
dfsCluster = qjmhaCluster.getDfsCluster();
dfs = HATestUtil.configureObserverReadFs(

View File

@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hdfs.server.namenode.ha;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_STATE_CONTEXT_ENABLED_KEY;
import static org.apache.hadoop.hdfs.server.namenode.NameNodeAdapter.getServiceState;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -77,6 +78,7 @@ public class TestObserverNode {
@BeforeClass
public static void startUpCluster() throws Exception {
conf = new Configuration();
conf.setBoolean(DFS_NAMENODE_STATE_CONTEXT_ENABLED_KEY, true);
qjmhaCluster = HATestUtil.setUpObserverCluster(conf, 1, 0, true);
dfsCluster = qjmhaCluster.getDfsCluster();
}