[ 
https://issues.apache.org/jira/browse/HDFS-17935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18089898#comment-18089898
 ] 

ASF GitHub Bot commented on HDFS-17935:
---------------------------------------

kokonguyen191 commented on code in PR #8548:
URL: https://github.com/apache/hadoop/pull/8548#discussion_r3435326285


##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcServer.java:
##########
@@ -510,44 +515,75 @@ public RouterRpcServer(Configuration conf, Router router,
   public void initAsyncThreadPools(Configuration configuration) {
     Set<String> allConfiguredNS = 
FederationUtil.getAllConfiguredNS(configuration);
     allConfiguredNS.add(CONCURRENT_NS);
-    Map<String, Integer> nsAsyncActiveHandlerCount = 
parseNsAsyncHandlerCount(configuration);
-    initAsyncHandlerThreadPools(configuration, allConfiguredNS, 
nsAsyncActiveHandlerCount);
+    Map<String, Integer> nsAsyncActiveHandlerCount = 
parseNsAsyncHandlerCount(configuration,
+        DFS_ROUTER_ASYNC_RPC_NS_HANDLER_COUNT_KEY);
+    initAsyncHandlerThreadPools(configuration, allConfiguredNS, false,
+        DFS_ROUTER_ASYNC_RPC_HANDLER_COUNT_KEY, 
DFS_ROUTER_ASYNC_RPC_HANDLER_COUNT_DEFAULT,
+        nsAsyncActiveHandlerCount, asyncRouterHandlerExecutors);
+
+    Map<String, Integer> nsAsyncObserverHandlerCount = 
parseNsAsyncHandlerCount(configuration,
+        DFS_ROUTER_ASYNC_RPC_NS_OBSERVER_HANDLER_COUNT_KEY);
+    initAsyncHandlerThreadPools(configuration, allConfiguredNS, true,
+        DFS_ROUTER_ASYNC_RPC_OBSERVER_HANDLER_COUNT_KEY,
+        DFS_ROUTER_ASYNC_RPC_OBSERVER_HANDLER_COUNT_DEFAULT, 
nsAsyncObserverHandlerCount,
+        asyncRouterOBHandlerExecutors);
+
     initAsyncResponderThreadPools(configuration);
   }
 
-  private void initAsyncHandlerThreadPools(Configuration configuration,
-      Set<String> allConfiguredNS, Map<String, Integer> nsAsyncHandlerCount) {
-    LOG.info("Initializing asynchronous handler thread pools");
+  /**
+   * Initializes async handler executors for each configured namespace.
+   *
+   * @param configuration        router configuration
+   * @param allConfiguredNS      set of all configured namespace IDs
+   * @param useObserver         true if these handlers serve observer namenodes
+   * @param handlerCountKey     key for the default handler count
+   * @param handlerCountDefault default handler count
+   * @param nsAsyncHandlerCount per-namespace handler counts
+   * @param executors           executor map to populate
+   */
+  private void initAsyncHandlerThreadPools(Configuration configuration, 
Set<String> allConfiguredNS,
+      boolean useObserver, String handlerCountKey, int handlerCountDefault,
+      Map<String, Integer> nsAsyncHandlerCount, Map<String, 
ThreadPoolExecutor> executors) {
+    String namenodeTypeForLogging = useObserver ? "Observer Namenode" : 
"Active Namenode";
     int asyncQueueSize = configuration.getInt(DFS_ROUTER_ASYNC_RPC_QUEUE_SIZE,
         DFS_ROUTER_ASYNC_RPC_QUEUE_SIZE_DEFAULT);
     if (asyncQueueSize < 1) {
       throw new IllegalArgumentException("Async queue size must be at least 
1");
     }
-    int asyncHandlerCountDefault = 
configuration.getInt(DFS_ROUTER_ASYNC_RPC_HANDLER_COUNT_KEY,
-        DFS_ROUTER_ASYNC_RPC_HANDLER_COUNT_DEFAULT);
+    int asyncHandlerCountDefault = configuration.getInt(handlerCountKey, 
handlerCountDefault);
+    // Skip separate observer handlers and let them share with active if not 
configured
+    if (asyncHandlerCountDefault < 1 && nsAsyncHandlerCount.isEmpty() && 
useObserver) {
+      LOG.info("Async observer handlers are not configured, skipping...");
+      return;
+    } else {
+      useSeparateAsyncRouterOBHandlerExecutors = true;
+    }

Review Comment:
   oof, good catch. Fixed and added unit test





> [ARR] Separate router async handlers for active and observer
> ------------------------------------------------------------
>
>                 Key: HDFS-17935
>                 URL: https://issues.apache.org/jira/browse/HDFS-17935
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: hdfs, rbf
>            Reporter: Felix N
>            Assignee: Felix N
>            Priority: Minor
>              Labels: pull-request-available
>
> Most router traffic are reads, and currently all traffic to a namespace is 
> handled by one same executor, so high observer load can increase competition 
> for active ops. It would be beneficial to split the handler pools into 2 
> separate sets, one for active, one for observer.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to