HBASE-21578 Fix wrong throttling exception for capacity unit
Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
parent
11193d7cc1
commit
c494e9ff20
|
@ -29,13 +29,15 @@ public class RpcThrottlingException extends HBaseIOException {
|
|||
@InterfaceAudience.Public
|
||||
public enum Type {
|
||||
NumRequestsExceeded, RequestSizeExceeded, NumReadRequestsExceeded, NumWriteRequestsExceeded,
|
||||
WriteSizeExceeded, ReadSizeExceeded,
|
||||
WriteSizeExceeded, ReadSizeExceeded, RequestCapacityUnitExceeded, ReadCapacityUnitExceeded,
|
||||
WriteCapacityUnitExceeded
|
||||
}
|
||||
|
||||
private static final String[] MSG_TYPE =
|
||||
new String[] { "number of requests exceeded", "request size limit exceeded",
|
||||
"number of read requests exceeded", "number of write requests exceeded",
|
||||
"write size limit exceeded", "read size limit exceeded", };
|
||||
"write size limit exceeded", "read size limit exceeded", "request capacity unit exceeded",
|
||||
"read capacity unit exceeded", "write capacity unit exceeded" };
|
||||
|
||||
private static final String MSG_WAIT = " - wait ";
|
||||
|
||||
|
@ -100,6 +102,21 @@ public class RpcThrottlingException extends HBaseIOException {
|
|||
throwThrottlingException(Type.ReadSizeExceeded, waitInterval);
|
||||
}
|
||||
|
||||
public static void throwRequestCapacityUnitExceeded(final long waitInterval)
|
||||
throws RpcThrottlingException {
|
||||
throwThrottlingException(Type.RequestCapacityUnitExceeded, waitInterval);
|
||||
}
|
||||
|
||||
public static void throwReadCapacityUnitExceeded(final long waitInterval)
|
||||
throws RpcThrottlingException {
|
||||
throwThrottlingException(Type.ReadCapacityUnitExceeded, waitInterval);
|
||||
}
|
||||
|
||||
public static void throwWriteCapacityUnitExceeded(final long waitInterval)
|
||||
throws RpcThrottlingException {
|
||||
throwThrottlingException(Type.WriteCapacityUnitExceeded, waitInterval);
|
||||
}
|
||||
|
||||
private static void throwThrottlingException(final Type type, final long waitInterval)
|
||||
throws RpcThrottlingException {
|
||||
String msg = MSG_TYPE[type.ordinal()] + MSG_WAIT + StringUtils.formatTime(waitInterval);
|
||||
|
|
|
@ -148,7 +148,7 @@ public class TimeBasedLimiter implements QuotaLimiter {
|
|||
reqSizeLimiter.waitInterval(estimateWriteSize + estimateReadSize));
|
||||
}
|
||||
if (!reqCapacityUnitLimiter.canExecute(estimateWriteCapacityUnit + estimateReadCapacityUnit)) {
|
||||
RpcThrottlingException.throwRequestSizeExceeded(
|
||||
RpcThrottlingException.throwRequestCapacityUnitExceeded(
|
||||
reqCapacityUnitLimiter.waitInterval(estimateWriteCapacityUnit + estimateReadCapacityUnit));
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class TimeBasedLimiter implements QuotaLimiter {
|
|||
writeSizeLimiter.waitInterval(estimateWriteSize));
|
||||
}
|
||||
if (!writeCapacityUnitLimiter.canExecute(estimateWriteCapacityUnit)) {
|
||||
RpcThrottlingException.throwWriteSizeExceeded(
|
||||
RpcThrottlingException.throwWriteCapacityUnitExceeded(
|
||||
writeCapacityUnitLimiter.waitInterval(estimateWriteCapacityUnit));
|
||||
}
|
||||
}
|
||||
|
@ -175,8 +175,8 @@ public class TimeBasedLimiter implements QuotaLimiter {
|
|||
readSizeLimiter.waitInterval(estimateReadSize));
|
||||
}
|
||||
if (!readCapacityUnitLimiter.canExecute(estimateReadCapacityUnit)) {
|
||||
RpcThrottlingException
|
||||
.throwWriteSizeExceeded(readCapacityUnitLimiter.waitInterval(estimateReadCapacityUnit));
|
||||
RpcThrottlingException.throwReadCapacityUnitExceeded(
|
||||
readCapacityUnitLimiter.waitInterval(estimateReadCapacityUnit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue