Skip to content

Commit

Permalink
HBASE-22559 [RPC] set guard against CALL_QUEUE_HANDLER_FACTOR_CONF_KEY
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Purtell <[email protected]>
  • Loading branch information
Reidddddd committed Jun 14, 2019
1 parent 8e15f4e commit ab44531
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ public RpcExecutor(final String name, final int handlerCount, final String callQ
this.abortable = abortable;

float callQueuesHandlersFactor = this.conf.getFloat(CALL_QUEUE_HANDLER_FACTOR_CONF_KEY, 0.1f);
if (Float.compare(callQueuesHandlersFactor, 1.0f) > 0 ||
Float.compare(0.0f, callQueuesHandlersFactor) > 0) {
LOG.warn(CALL_QUEUE_HANDLER_FACTOR_CONF_KEY +
" is *ILLEGAL*, it should be in range [0.0, 1.0]");
// For callQueuesHandlersFactor > 1.0, we just set it 1.0f.
if (Float.compare(callQueuesHandlersFactor, 1.0f) > 0) {
LOG.warn("Set " + CALL_QUEUE_HANDLER_FACTOR_CONF_KEY + " 1.0f");
callQueuesHandlersFactor = 1.0f;
} else {
// But for callQueuesHandlersFactor < 0.0, following method #computeNumCallQueues
// will compute max(1, -x) => 1 which has same effect of default value.
LOG.warn("Set " + CALL_QUEUE_HANDLER_FACTOR_CONF_KEY + " default value 0.0f");
}
}
this.numCallQueues = computeNumCallQueues(handlerCount, callQueuesHandlersFactor);
this.queues = new ArrayList<>(this.numCallQueues);

Expand Down

0 comments on commit ab44531

Please sign in to comment.