Skip to content

Commit

Permalink
HBASE-27799: fix misleading RpcThrottlingException message
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray Mattingly committed Apr 19, 2023
1 parent 143e9b4 commit 94fe90a
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,19 @@ public static void throwWriteCapacityUnitExceeded(final long waitInterval)

private static void throwThrottlingException(final Type type, final long waitInterval)
throws RpcThrottlingException {
String msg = MSG_TYPE[type.ordinal()] + MSG_WAIT + StringUtils.formatTime(waitInterval);
String msg = MSG_TYPE[type.ordinal()] + MSG_WAIT + stringFromMillis(waitInterval);
throw new RpcThrottlingException(type, waitInterval, msg);
}

private static String stringFromMillis(long millis) {
if (millis >= 1000) {
return StringUtils.formatTime(millis);
} else {
// StringUtils#formatTime doesn't support millis
return millis + "ms";
}
}

private static long timeFromString(String timeDiff) {
Pattern[] patterns = new Pattern[] { Pattern.compile("^(\\d+\\.\\d\\d)sec"),
Pattern.compile("^(\\d+)mins, (\\d+\\.\\d\\d)sec"),
Expand Down

0 comments on commit 94fe90a

Please sign in to comment.