[
https://issues.apache.org/jira/browse/HDFS-14750?focusedWorklogId=767136&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-767136
]
ASF GitHub Bot logged work on HDFS-14750:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 06/May/22 10:48
Start Date: 06/May/22 10:48
Worklog Time Spent: 10m
Work Description: kokonguyen191 commented on code in PR #4199:
URL: https://github.com/apache/hadoop/pull/4199#discussion_r866709948
##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/fairness/TestDynamicRouterRpcFairnessPolicyController.java:
##########
@@ -0,0 +1,177 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hdfs.server.federation.fairness;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.LongAdder;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hdfs.HdfsConfiguration;
+import org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys;
+
+import static
org.apache.hadoop.hdfs.server.federation.fairness.RouterRpcFairnessConstants.CONCURRENT_NS;
+import static
org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys.DFS_ROUTER_HANDLER_COUNT_KEY;
+import static
org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys.DFS_ROUTER_MONITOR_NAMENODE;
+
+/**
+ * Test functionality of {@link DynamicRouterRpcFairnessPolicyController).
+ */
+public class TestDynamicRouterRpcFairnessPolicyController {
+
+ private static String nameServices = "ns1.nn1, ns1.nn2, ns2.nn1, ns2.nn2";
+
+ @Test
+ public void testDynamicControllerSimple() throws InterruptedException {
+ verifyDynamicControllerSimple(true);
+ verifyDynamicControllerSimple(false);
+ }
+
+ @Test
+ public void testDynamicControllerAllPermitsAcquired() throws
InterruptedException {
+ verifyDynamicControllerAllPermitsAcquired(true);
+ verifyDynamicControllerAllPermitsAcquired(false);
+ }
+
+ private void verifyDynamicControllerSimple(boolean manualRefresh)
+ throws InterruptedException {
+ // 3 permits each ns
+ DynamicRouterRpcFairnessPolicyController controller;
+ if (manualRefresh) {
+ controller = getFairnessPolicyController(9);
+ } else {
+ controller = getFairnessPolicyController(9, 4000);
+ }
+ for (int i = 0; i < 3; i++) {
+ Assert.assertTrue(controller.acquirePermit("ns1"));
+ Assert.assertTrue(controller.acquirePermit("ns2"));
+ Assert.assertTrue(controller.acquirePermit(CONCURRENT_NS));
+ }
+ Assert.assertFalse(controller.acquirePermit("ns1"));
+ Assert.assertFalse(controller.acquirePermit("ns2"));
+ Assert.assertFalse(controller.acquirePermit(CONCURRENT_NS));
+
+ // Release all permits
+ for (int i = 0; i < 3; i++) {
+ controller.releasePermit("ns1");
+ controller.releasePermit("ns2");
+ controller.releasePermit(CONCURRENT_NS);
+ }
+
+ // Inject dummy metrics
+ // Split half half for ns1 and concurrent
+ Map<String, LongAdder> rejectedPermitsPerNs = new HashMap<>();
+ Map<String, LongAdder> acceptedPermitsPerNs = new HashMap<>();
+ injectDummyMetrics(rejectedPermitsPerNs, "ns1", 10);
+ injectDummyMetrics(rejectedPermitsPerNs, "ns2", 0);
+ injectDummyMetrics(rejectedPermitsPerNs, CONCURRENT_NS, 10);
+ controller.setMetrics(rejectedPermitsPerNs, acceptedPermitsPerNs);
+
+ if (manualRefresh) {
+ controller.refreshPermitsCap();
+ } else {
+ Thread.sleep(5000);
+ }
+
+ // Current permits count should be 5:1:5
Review Comment:
Yes it's an inherent issue with the approach when permit count scales with
traffic.
For example, initial handlers assigned to ns0,ns1,concurrent are 5,5,30 (40
total). After a while, all 3 namespaces have the same traffic and 40 handlers
have to be spread between all of them, leading to a tiebreaking situation. Not
sure what approach is best to handle these kinds of situations.
Issue Time Tracking
-------------------
Worklog Id: (was: 767136)
Time Spent: 40m (was: 0.5h)
> RBF: Improved isolation for downstream name nodes. {Dynamic}
> ------------------------------------------------------------
>
> Key: HDFS-14750
> URL: https://issues.apache.org/jira/browse/HDFS-14750
> Project: Hadoop HDFS
> Issue Type: Improvement
> Reporter: CR Hota
> Assignee: CR Hota
> Priority: Major
> Labels: pull-request-available
> Time Spent: 40m
> Remaining Estimate: 0h
>
> This Jira tracks the work around dynamic allocation of resources in routers
> for downstream hdfs clusters.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]