|
@@ -50,13 +50,10 @@ public class StaticRouterRpcFairnessPolicyController extends
|
|
|
init(conf);
|
|
|
}
|
|
|
|
|
|
- public void init(Configuration conf)
|
|
|
- throws IllegalArgumentException {
|
|
|
+ public void init(Configuration conf) throws IllegalArgumentException {
|
|
|
super.init(conf);
|
|
|
// Total handlers configured to process all incoming Rpc.
|
|
|
- int handlerCount = conf.getInt(
|
|
|
- DFS_ROUTER_HANDLER_COUNT_KEY,
|
|
|
- DFS_ROUTER_HANDLER_COUNT_DEFAULT);
|
|
|
+ int handlerCount = conf.getInt(DFS_ROUTER_HANDLER_COUNT_KEY, DFS_ROUTER_HANDLER_COUNT_DEFAULT);
|
|
|
|
|
|
LOG.info("Handlers available for fairness assignment {} ", handlerCount);
|
|
|
|
|
@@ -71,8 +68,7 @@ public class StaticRouterRpcFairnessPolicyController extends
|
|
|
allConfiguredNS.add(CONCURRENT_NS);
|
|
|
validateHandlersCount(conf, handlerCount, allConfiguredNS);
|
|
|
for (String nsId : allConfiguredNS) {
|
|
|
- int dedicatedHandlers =
|
|
|
- conf.getInt(DFS_ROUTER_FAIR_HANDLER_COUNT_KEY_PREFIX + nsId, 0);
|
|
|
+ int dedicatedHandlers = conf.getInt(DFS_ROUTER_FAIR_HANDLER_COUNT_KEY_PREFIX + nsId, 0);
|
|
|
LOG.info("Dedicated handlers {} for ns {} ", dedicatedHandlers, nsId);
|
|
|
if (dedicatedHandlers > 0) {
|
|
|
handlerCount -= dedicatedHandlers;
|
|
@@ -86,7 +82,7 @@ public class StaticRouterRpcFairnessPolicyController extends
|
|
|
// Assign remaining handlers equally to remaining name services and
|
|
|
// general pool if applicable.
|
|
|
if (!unassignedNS.isEmpty()) {
|
|
|
- LOG.info("Unassigned ns {}", unassignedNS.toString());
|
|
|
+ LOG.info("Unassigned ns {}", unassignedNS);
|
|
|
int handlersPerNS = handlerCount / unassignedNS.size();
|
|
|
LOG.info("Handlers available per ns {}", handlersPerNS);
|
|
|
for (String nsId : unassignedNS) {
|
|
@@ -101,24 +97,20 @@ public class StaticRouterRpcFairnessPolicyController extends
|
|
|
int existingPermits = getAvailablePermits(CONCURRENT_NS);
|
|
|
if (leftOverHandlers > 0) {
|
|
|
LOG.info("Assigned extra {} handlers to commons pool", leftOverHandlers);
|
|
|
- insertNameServiceWithPermits(CONCURRENT_NS,
|
|
|
- existingPermits + leftOverHandlers);
|
|
|
+ insertNameServiceWithPermits(CONCURRENT_NS, existingPermits + leftOverHandlers);
|
|
|
}
|
|
|
- LOG.info("Final permit allocation for concurrent ns: {}",
|
|
|
- getAvailablePermits(CONCURRENT_NS));
|
|
|
+ LOG.info("Final permit allocation for concurrent ns: {}", getAvailablePermits(CONCURRENT_NS));
|
|
|
}
|
|
|
|
|
|
private static void logAssignment(String nsId, int count) {
|
|
|
- LOG.info("Assigned {} handlers to nsId {} ",
|
|
|
- count, nsId);
|
|
|
+ LOG.info("Assigned {} handlers to nsId {} ", count, nsId);
|
|
|
}
|
|
|
|
|
|
- private void validateHandlersCount(Configuration conf, int handlerCount,
|
|
|
- Set<String> allConfiguredNS) {
|
|
|
+ private void validateHandlersCount(Configuration conf,
|
|
|
+ int handlerCount, Set<String> allConfiguredNS) {
|
|
|
int totalDedicatedHandlers = 0;
|
|
|
for (String nsId : allConfiguredNS) {
|
|
|
- int dedicatedHandlers =
|
|
|
- conf.getInt(DFS_ROUTER_FAIR_HANDLER_COUNT_KEY_PREFIX + nsId, 0);
|
|
|
+ int dedicatedHandlers = conf.getInt(DFS_ROUTER_FAIR_HANDLER_COUNT_KEY_PREFIX + nsId, 0);
|
|
|
if (dedicatedHandlers > 0) {
|
|
|
// Total handlers should not be less than sum of dedicated handlers.
|
|
|
totalDedicatedHandlers += dedicatedHandlers;
|
|
@@ -128,8 +120,7 @@ public class StaticRouterRpcFairnessPolicyController extends
|
|
|
}
|
|
|
}
|
|
|
if (totalDedicatedHandlers > handlerCount) {
|
|
|
- String msg = String.format(ERROR_MSG, handlerCount,
|
|
|
- totalDedicatedHandlers);
|
|
|
+ String msg = String.format(ERROR_MSG, handlerCount, totalDedicatedHandlers);
|
|
|
LOG.error(msg);
|
|
|
throw new IllegalArgumentException(msg);
|
|
|
}
|