Browse Source

HDFS-12718. Ozone: fix thread number calculation in CBlockManager. Contributed by Elek, Marton.

Mukul Kumar Singh 7 years ago
parent
commit
6739180c12

+ 4 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/cblock/storage/StorageManager.java

@@ -209,7 +209,8 @@ public class StorageManager {
 
   private boolean createVolumeContainers(VolumeDescriptor volume) {
     ArrayList<String> containerIds = new ArrayList<>();
-    ThreadPoolExecutor executor = new ThreadPoolExecutor(numThreads,
+    ThreadPoolExecutor executor = new ThreadPoolExecutor(
+        Math.min(numThreads, MAX_THREADS),
         MAX_THREADS, 1, TimeUnit.SECONDS,
         new ArrayBlockingQueue<>(MAX_QUEUE_CAPACITY),
         new ThreadPoolExecutor.CallerRunsPolicy());
@@ -254,7 +255,8 @@ public class StorageManager {
 
   private void deleteVolumeContainers(List<String> containers, boolean force)
       throws CBlockException {
-    ThreadPoolExecutor executor = new ThreadPoolExecutor(numThreads,
+    ThreadPoolExecutor executor = new ThreadPoolExecutor(
+        Math.min(numThreads, MAX_THREADS),
         MAX_THREADS, 1, TimeUnit.SECONDS,
         new ArrayBlockingQueue<>(MAX_QUEUE_CAPACITY),
         new ThreadPoolExecutor.CallerRunsPolicy());

+ 3 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/resources/ozone-default.xml

@@ -185,8 +185,9 @@
     <value>16</value>
     <tag>CBLOCK, PERFORMANCE</tag>
     <description>
-      Number of threads that cblock manager will use for container
-      operations.
+      Number of active threads that cblock manager will use for container
+      operations. The maximum number of the threads are limited to the
+      processor count * 2.
     </description>
   </property>
   <property>