Skip to content

Commit 6a0de4f

Browse files
jianghuazhuhotcodemacha
authored andcommitted
HDFS-16386. Reduce DataNode load when FsDatasetAsyncDiskService is working. (#3806)
1 parent b4c7e1b commit 6a0de4f

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSConfigKeys.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ public class DFSConfigKeys extends CommonConfigurationKeys {
143143
public static final long DFS_DATANODE_MAX_LOCKED_MEMORY_DEFAULT = 0;
144144
public static final String DFS_DATANODE_FSDATASETCACHE_MAX_THREADS_PER_VOLUME_KEY = "dfs.datanode.fsdatasetcache.max.threads.per.volume";
145145
public static final int DFS_DATANODE_FSDATASETCACHE_MAX_THREADS_PER_VOLUME_DEFAULT = 4;
146+
public static final String DFS_DATANODE_FSDATASETASYNCDISK_MAX_THREADS_PER_VOLUME_KEY =
147+
"dfs.datanode.fsdatasetasyncdisk.max.threads.per.volume";
148+
public static final int DFS_DATANODE_FSDATASETASYNCDISK_MAX_THREADS_PER_VOLUME_DEFAULT = 4;
146149
public static final String DFS_DATANODE_LAZY_WRITER_INTERVAL_SEC = "dfs.datanode.lazywriter.interval.sec";
147150
public static final int DFS_DATANODE_LAZY_WRITER_INTERVAL_DEFAULT_SEC = 60;
148151
public static final String DFS_DATANODE_RAM_DISK_REPLICA_TRACKER_KEY = "dfs.datanode.ram.disk.replica.tracker";

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetAsyncDiskService.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import java.util.concurrent.ThreadPoolExecutor;
3131
import java.util.concurrent.TimeUnit;
3232

33+
import org.apache.hadoop.hdfs.DFSConfigKeys;
34+
import org.apache.hadoop.util.Preconditions;
3335
import org.slf4j.Logger;
3436
import org.slf4j.LoggerFactory;
3537
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
@@ -65,7 +67,7 @@ class FsDatasetAsyncDiskService {
6567
// ThreadPool core pool size
6668
private static final int CORE_THREADS_PER_VOLUME = 1;
6769
// ThreadPool maximum pool size
68-
private static final int MAXIMUM_THREADS_PER_VOLUME = 4;
70+
private final int maxNumThreadsPerVolume;
6971
// ThreadPool keep-alive time for threads over core pool size
7072
private static final long THREADS_KEEP_ALIVE_SECONDS = 60;
7173

@@ -90,6 +92,12 @@ class FsDatasetAsyncDiskService {
9092
this.datanode = datanode;
9193
this.fsdatasetImpl = fsdatasetImpl;
9294
this.threadGroup = new ThreadGroup(getClass().getSimpleName());
95+
maxNumThreadsPerVolume = datanode.getConf().getInt(
96+
DFSConfigKeys.DFS_DATANODE_FSDATASETASYNCDISK_MAX_THREADS_PER_VOLUME_KEY,
97+
DFSConfigKeys.DFS_DATANODE_FSDATASETASYNCDISK_MAX_THREADS_PER_VOLUME_DEFAULT);
98+
Preconditions.checkArgument(maxNumThreadsPerVolume > 0,
99+
DFSConfigKeys.DFS_DATANODE_FSDATASETASYNCDISK_MAX_THREADS_PER_VOLUME_KEY +
100+
" must be a positive integer.");
93101
}
94102

95103
private void addExecutorForVolume(final FsVolumeImpl volume) {
@@ -110,7 +118,7 @@ public Thread newThread(Runnable r) {
110118
};
111119

112120
ThreadPoolExecutor executor = new ThreadPoolExecutor(
113-
CORE_THREADS_PER_VOLUME, MAXIMUM_THREADS_PER_VOLUME,
121+
CORE_THREADS_PER_VOLUME, maxNumThreadsPerVolume,
114122
THREADS_KEEP_ALIVE_SECONDS, TimeUnit.SECONDS,
115123
new LinkedBlockingQueue<Runnable>(), threadFactory);
116124

hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,6 +2982,16 @@
29822982
</description>
29832983
</property>
29842984

2985+
<property>
2986+
<name>dfs.datanode.fsdatasetasyncdisk.max.threads.per.volume</name>
2987+
<value>4</value>
2988+
<description>
2989+
The maximum number of threads per volume used to process async disk
2990+
operations on the datanode. These threads consume I/O and CPU at the
2991+
same time. This will affect normal data node operations.
2992+
</description>
2993+
</property>
2994+
29852995
<property>
29862996
<name>dfs.cachereport.intervalMsec</name>
29872997
<value>10000</value>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/TestSystemMetricsPublisher.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,14 @@ public static Collection<Object[]> data() {
8787
private static TimelineServiceV1Publisher metricsPublisher;
8888
private static TimelineStore store;
8989

90-
@Parameterized.Parameter
91-
public boolean rmTimelineServerV1PublisherBatchEnabled;
90+
private boolean rmTimelineServerV1PublisherBatchEnabled;
91+
private int rmTimelineServerV1PublisherInterval;
9292

93-
@Parameterized.Parameter(1)
94-
public int rmTimelineServerV1PublisherInterval;
93+
public TestSystemMetricsPublisher(boolean rmTimelineServerV1PublisherBatchEnabled,
94+
int rmTimelineServerV1PublisherInterval) {
95+
this.rmTimelineServerV1PublisherBatchEnabled = rmTimelineServerV1PublisherBatchEnabled;
96+
this.rmTimelineServerV1PublisherInterval = rmTimelineServerV1PublisherInterval;
97+
}
9598

9699
@Before
97100
public void setup() throws Exception {

0 commit comments

Comments
 (0)