HDFS-16287. Support to make dfs.namenode.avoid.read.slow.datanode reconfigurable (#3596)
This commit is contained in:
parent
3d692c0936
commit
db89a9411e
|
@ -18,8 +18,6 @@
|
|||
package org.apache.hadoop.hdfs.server.blockmanagement;
|
||||
|
||||
import static org.apache.hadoop.hdfs.server.protocol.DatanodeProtocol.DNA_ERASURE_CODING_RECONSTRUCTION;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_BLOCKPLACEMENTPOLICY_EXCLUDE_SLOW_NODES_ENABLED_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_BLOCKPLACEMENTPOLICY_EXCLUDE_SLOW_NODES_ENABLED_DEFAULT;
|
||||
import static org.apache.hadoop.util.Time.monotonicNow;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -141,7 +139,7 @@ public class DatanodeManager {
|
|||
private final boolean avoidStaleDataNodesForRead;
|
||||
|
||||
/** Whether or not to avoid using slow DataNodes for reading. */
|
||||
private final boolean avoidSlowDataNodesForRead;
|
||||
private volatile boolean avoidSlowDataNodesForRead;
|
||||
|
||||
/** Whether or not to consider lad for reading. */
|
||||
private final boolean readConsiderLoad;
|
||||
|
@ -217,7 +215,6 @@ public class DatanodeManager {
|
|||
private Daemon slowPeerCollectorDaemon;
|
||||
private final long slowPeerCollectionInterval;
|
||||
private final int maxSlowPeerReportNodes;
|
||||
private boolean excludeSlowNodesEnabled;
|
||||
|
||||
@Nullable
|
||||
private final SlowDiskTracker slowDiskTracker;
|
||||
|
@ -260,9 +257,6 @@ public class DatanodeManager {
|
|||
final Timer timer = new Timer();
|
||||
this.slowPeerTracker = dataNodePeerStatsEnabled ?
|
||||
new SlowPeerTracker(conf, timer) : null;
|
||||
this.excludeSlowNodesEnabled = conf.getBoolean(
|
||||
DFS_NAMENODE_BLOCKPLACEMENTPOLICY_EXCLUDE_SLOW_NODES_ENABLED_KEY,
|
||||
DFS_NAMENODE_BLOCKPLACEMENTPOLICY_EXCLUDE_SLOW_NODES_ENABLED_DEFAULT);
|
||||
this.maxSlowPeerReportNodes = conf.getInt(
|
||||
DFSConfigKeys.DFS_NAMENODE_MAX_SLOWPEER_COLLECT_NODES_KEY,
|
||||
DFSConfigKeys.DFS_NAMENODE_MAX_SLOWPEER_COLLECT_NODES_DEFAULT);
|
||||
|
@ -270,7 +264,7 @@ public class DatanodeManager {
|
|||
DFSConfigKeys.DFS_NAMENODE_SLOWPEER_COLLECT_INTERVAL_KEY,
|
||||
DFSConfigKeys.DFS_NAMENODE_SLOWPEER_COLLECT_INTERVAL_DEFAULT,
|
||||
TimeUnit.MILLISECONDS);
|
||||
if (slowPeerTracker != null && excludeSlowNodesEnabled) {
|
||||
if (slowPeerTracker != null) {
|
||||
startSlowPeerCollector();
|
||||
}
|
||||
this.slowDiskTracker = dataNodeDiskStatsEnabled ?
|
||||
|
@ -511,7 +505,16 @@ public class DatanodeManager {
|
|||
private boolean isSlowNode(String dnUuid) {
|
||||
return avoidSlowDataNodesForRead && slowNodesUuidSet.contains(dnUuid);
|
||||
}
|
||||
|
||||
|
||||
public void setAvoidSlowDataNodesForReadEnabled(boolean enable) {
|
||||
this.avoidSlowDataNodesForRead = enable;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public boolean getEnableAvoidSlowDataNodesForRead() {
|
||||
return this.avoidSlowDataNodesForRead;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the non-striped located blocks by the distance to the target host.
|
||||
*
|
||||
|
|
|
@ -187,6 +187,8 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_GC_TIME_MONITOR_
|
|||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_GC_TIME_MONITOR_ENABLE_DEFAULT;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCK_REPLICATOR_CLASSNAME_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCK_PLACEMENT_EC_CLASSNAME_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVOID_SLOW_DATANODE_FOR_READ_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVOID_SLOW_DATANODE_FOR_READ_DEFAULT;
|
||||
|
||||
import static org.apache.hadoop.util.ExitUtil.terminate;
|
||||
import static org.apache.hadoop.util.ToolRunner.confirmPrompt;
|
||||
|
@ -328,7 +330,8 @@ public class NameNode extends ReconfigurableBase implements
|
|||
DFS_NAMENODE_REPLICATION_WORK_MULTIPLIER_PER_ITERATION,
|
||||
DFS_BLOCK_REPLICATOR_CLASSNAME_KEY,
|
||||
DFS_BLOCK_PLACEMENT_EC_CLASSNAME_KEY,
|
||||
DFS_IMAGE_PARALLEL_LOAD_KEY));
|
||||
DFS_IMAGE_PARALLEL_LOAD_KEY,
|
||||
DFS_NAMENODE_AVOID_SLOW_DATANODE_FOR_READ_KEY));
|
||||
|
||||
private static final String USAGE = "Usage: hdfs namenode ["
|
||||
+ StartupOption.BACKUP.getName() + "] | \n\t["
|
||||
|
@ -2197,6 +2200,8 @@ public class NameNode extends ReconfigurableBase implements
|
|||
return newVal;
|
||||
} else if (property.equals(DFS_IMAGE_PARALLEL_LOAD_KEY)) {
|
||||
return reconfigureParallelLoad(newVal);
|
||||
} else if (property.equals(DFS_NAMENODE_AVOID_SLOW_DATANODE_FOR_READ_KEY)) {
|
||||
return reconfigureSlowNodesParameters(datanodeManager, property, newVal);
|
||||
} else {
|
||||
throw new ReconfigurationException(property, newVal, getConf().get(
|
||||
property));
|
||||
|
@ -2383,6 +2388,27 @@ public class NameNode extends ReconfigurableBase implements
|
|||
return Boolean.toString(enableParallelLoad);
|
||||
}
|
||||
|
||||
String reconfigureSlowNodesParameters(final DatanodeManager datanodeManager,
|
||||
final String property, final String newVal) throws ReconfigurationException {
|
||||
namesystem.writeLock();
|
||||
boolean enable;
|
||||
try {
|
||||
if (newVal == null) {
|
||||
enable = DFS_NAMENODE_AVOID_SLOW_DATANODE_FOR_READ_DEFAULT;
|
||||
} else {
|
||||
enable = Boolean.parseBoolean(newVal);
|
||||
}
|
||||
datanodeManager.setAvoidSlowDataNodesForReadEnabled(enable);
|
||||
LOG.info("RECONFIGURE* changed {} to {}", property, newVal);
|
||||
return Boolean.toString(enable);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ReconfigurationException(property, newVal, getConf().get(
|
||||
property), e);
|
||||
} finally {
|
||||
namesystem.writeUnlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // ReconfigurableBase
|
||||
protected Configuration getNewConf() {
|
||||
return new HdfsConfiguration();
|
||||
|
|
|
@ -51,6 +51,7 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HEARTBEAT_RECHEC
|
|||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_STORAGE_POLICY_SATISFIER_MODE_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_STORAGE_POLICY_SATISFIER_MODE_DEFAULT;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCK_INVALIDATE_LIMIT_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVOID_SLOW_DATANODE_FOR_READ_KEY;
|
||||
import static org.apache.hadoop.fs.CommonConfigurationKeys.IPC_BACKOFF_ENABLE_DEFAULT;
|
||||
|
||||
public class TestNameNodeReconfigure {
|
||||
|
@ -394,6 +395,23 @@ public class TestNameNodeReconfigure {
|
|||
assertEquals(true, FSImageFormatProtobuf.getEnableParallelLoad());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnableSlowNodesParametersAfterReconfigured()
|
||||
throws ReconfigurationException {
|
||||
final NameNode nameNode = cluster.getNameNode();
|
||||
final DatanodeManager datanodeManager = nameNode.namesystem
|
||||
.getBlockManager().getDatanodeManager();
|
||||
|
||||
// By default, avoidSlowDataNodesForRead is false.
|
||||
assertEquals(false, datanodeManager.getEnableAvoidSlowDataNodesForRead());
|
||||
|
||||
nameNode.reconfigureProperty(
|
||||
DFS_NAMENODE_AVOID_SLOW_DATANODE_FOR_READ_KEY, Boolean.toString(true));
|
||||
|
||||
// After reconfigured, avoidSlowDataNodesForRead is true.
|
||||
assertEquals(true, datanodeManager.getEnableAvoidSlowDataNodesForRead());
|
||||
}
|
||||
|
||||
@After
|
||||
public void shutDown() throws IOException {
|
||||
if (cluster != null) {
|
||||
|
|
|
@ -38,6 +38,7 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_IMAGE_PARALLEL_LOAD_KEY;
|
|||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCK_PLACEMENT_EC_CLASSNAME_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCK_REPLICATOR_CLASSNAME_KEY;
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_AVOID_SLOW_DATANODE_FOR_READ_KEY;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.text.TextStringBuilder;
|
||||
|
@ -430,12 +431,13 @@ public class TestDFSAdmin {
|
|||
final List<String> outs = Lists.newArrayList();
|
||||
final List<String> errs = Lists.newArrayList();
|
||||
getReconfigurableProperties("namenode", address, outs, errs);
|
||||
assertEquals(13, outs.size());
|
||||
assertEquals(14, outs.size());
|
||||
assertEquals(DFS_BLOCK_PLACEMENT_EC_CLASSNAME_KEY, outs.get(1));
|
||||
assertEquals(DFS_BLOCK_REPLICATOR_CLASSNAME_KEY, outs.get(2));
|
||||
assertEquals(DFS_HEARTBEAT_INTERVAL_KEY, outs.get(3));
|
||||
assertEquals(DFS_IMAGE_PARALLEL_LOAD_KEY, outs.get(4));
|
||||
assertEquals(DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY, outs.get(5));
|
||||
assertEquals(DFS_NAMENODE_AVOID_SLOW_DATANODE_FOR_READ_KEY, outs.get(5));
|
||||
assertEquals(DFS_NAMENODE_HEARTBEAT_RECHECK_INTERVAL_KEY, outs.get(6));
|
||||
assertEquals(errs.size(), 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue