Skip to content

Commit 54fa4eb

Browse files
committed
HDFS-17713. [ARR] Throtting asynchronous calls for each nameservice.
1 parent 8efd978 commit 54fa4eb

File tree

5 files changed

+237
-50
lines changed

5 files changed

+237
-50
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.hadoop.hdfs.server.federation.fairness;
20+
21+
import org.apache.hadoop.conf.Configuration;
22+
import org.apache.hadoop.hdfs.server.federation.router.FederationUtil;
23+
import org.slf4j.Logger;
24+
import org.slf4j.LoggerFactory;
25+
26+
import java.util.Set;
27+
28+
import static org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys.
29+
DFS_ROUTER_ASYNC_RPC_MAX_ASYNCCALL_PERMIT_KEY;
30+
import static org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys.
31+
DFS_ROUTER_ASYNC_RPC_MAX_ASYNC_CALL_PERMIT_DEFAULT;
32+
33+
public class RouterAsyncRpcFairnessPolicyController extends
34+
AbstractRouterRpcFairnessPolicyController {
35+
36+
private static final Logger LOG =
37+
LoggerFactory.getLogger(RouterAsyncRpcFairnessPolicyController.class);
38+
39+
public RouterAsyncRpcFairnessPolicyController(Configuration conf) {
40+
init(conf);
41+
}
42+
43+
public void init(Configuration conf) throws IllegalArgumentException {
44+
super.init(conf);
45+
46+
int maxAsyncCallPermit = conf.getInt(DFS_ROUTER_ASYNC_RPC_MAX_ASYNCCALL_PERMIT_KEY,
47+
DFS_ROUTER_ASYNC_RPC_MAX_ASYNC_CALL_PERMIT_DEFAULT);
48+
if (maxAsyncCallPermit <= 0) {
49+
maxAsyncCallPermit = DFS_ROUTER_ASYNC_RPC_MAX_ASYNC_CALL_PERMIT_DEFAULT;
50+
}
51+
LOG.info("Max async call permits per nameservice: {}", maxAsyncCallPermit);
52+
53+
// Get all name services configured
54+
Set<String> allConfiguredNS = FederationUtil.getAllConfiguredNS(conf);
55+
56+
for (String nsId : allConfiguredNS) {
57+
LOG.info("Dedicated permits {} for ns {} ", maxAsyncCallPermit, nsId);
58+
insertNameServiceWithPermits(nsId, maxAsyncCallPermit);
59+
logAssignment(nsId, maxAsyncCallPermit);
60+
}
61+
}
62+
63+
private static void logAssignment(String nsId, int count) {
64+
LOG.info("Assigned {} permits to nsId {} ", count, nsId);
65+
}
66+
}

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RBFConfigKeys.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ public class RBFConfigKeys extends CommonConfigurationKeysPublic {
8888
public static final String DFS_ROUTER_ASYNC_RPC_RESPONDER_COUNT_KEY =
8989
FEDERATION_ROUTER_ASYNC_RPC_PREFIX + "responder.count";
9090
public static final int DFS_ROUTER_ASYNCRPC_RESPONDER_COUNT_DEFAULT = 10;
91+
public static final String DFS_ROUTER_ASYNC_RPC_MAX_ASYNCCALL_PERMIT_KEY =
92+
FEDERATION_ROUTER_ASYNC_RPC_PREFIX + "max.asynccall.permit";
93+
public static final int DFS_ROUTER_ASYNC_RPC_MAX_ASYNC_CALL_PERMIT_DEFAULT = 20000;
9194

9295
public static final String DFS_ROUTER_METRICS_ENABLE =
9396
FEDERATION_ROUTER_PREFIX + "metrics.enable";

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterRpcClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ protected void releasePermit(final String nsId, final UserGroupInformation ugi,
18801880
return routerRpcFairnessPolicyController;
18811881
}
18821882

1883-
private void incrRejectedPermitForNs(String ns) {
1883+
protected void incrRejectedPermitForNs(String ns) {
18841884
rejectedPermitsPerNs.computeIfAbsent(ns, k -> new LongAdder()).increment();
18851885
}
18861886

@@ -1889,7 +1889,7 @@ public Long getRejectedPermitForNs(String ns) {
18891889
rejectedPermitsPerNs.get(ns).longValue() : 0L;
18901890
}
18911891

1892-
private void incrAcceptedPermitForNs(String ns) {
1892+
protected void incrAcceptedPermitForNs(String ns) {
18931893
acceptedPermitsPerNs.computeIfAbsent(ns, k -> new LongAdder()).increment();
18941894
}
18951895

0 commit comments

Comments
 (0)