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
|
@InterfaceAudience.Public
|
||||||
public enum Type {
|
public enum Type {
|
||||||
NumRequestsExceeded, RequestSizeExceeded, NumReadRequestsExceeded, NumWriteRequestsExceeded,
|
NumRequestsExceeded, RequestSizeExceeded, NumReadRequestsExceeded, NumWriteRequestsExceeded,
|
||||||
WriteSizeExceeded, ReadSizeExceeded,
|
WriteSizeExceeded, ReadSizeExceeded, RequestCapacityUnitExceeded, ReadCapacityUnitExceeded,
|
||||||
|
WriteCapacityUnitExceeded
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] MSG_TYPE =
|
private static final String[] MSG_TYPE =
|
||||||
new String[] { "number of requests exceeded", "request size limit exceeded",
|
new String[] { "number of requests exceeded", "request size limit exceeded",
|
||||||
"number of read requests exceeded", "number of write requests 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 ";
|
private static final String MSG_WAIT = " - wait ";
|
||||||
|
|
||||||
@ -100,6 +102,21 @@ public class RpcThrottlingException extends HBaseIOException {
|
|||||||
throwThrottlingException(Type.ReadSizeExceeded, waitInterval);
|
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)
|
private static void throwThrottlingException(final Type type, final long waitInterval)
|
||||||
throws RpcThrottlingException {
|
throws RpcThrottlingException {
|
||||||
String msg = MSG_TYPE[type.ordinal()] + MSG_WAIT + StringUtils.formatTime(waitInterval);
|
String msg = MSG_TYPE[type.ordinal()] + MSG_WAIT + StringUtils.formatTime(waitInterval);
|
||||||
|
@ -148,7 +148,7 @@ public class TimeBasedLimiter implements QuotaLimiter {
|
|||||||
reqSizeLimiter.waitInterval(estimateWriteSize + estimateReadSize));
|
reqSizeLimiter.waitInterval(estimateWriteSize + estimateReadSize));
|
||||||
}
|
}
|
||||||
if (!reqCapacityUnitLimiter.canExecute(estimateWriteCapacityUnit + estimateReadCapacityUnit)) {
|
if (!reqCapacityUnitLimiter.canExecute(estimateWriteCapacityUnit + estimateReadCapacityUnit)) {
|
||||||
RpcThrottlingException.throwRequestSizeExceeded(
|
RpcThrottlingException.throwRequestCapacityUnitExceeded(
|
||||||
reqCapacityUnitLimiter.waitInterval(estimateWriteCapacityUnit + estimateReadCapacityUnit));
|
reqCapacityUnitLimiter.waitInterval(estimateWriteCapacityUnit + estimateReadCapacityUnit));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ public class TimeBasedLimiter implements QuotaLimiter {
|
|||||||
writeSizeLimiter.waitInterval(estimateWriteSize));
|
writeSizeLimiter.waitInterval(estimateWriteSize));
|
||||||
}
|
}
|
||||||
if (!writeCapacityUnitLimiter.canExecute(estimateWriteCapacityUnit)) {
|
if (!writeCapacityUnitLimiter.canExecute(estimateWriteCapacityUnit)) {
|
||||||
RpcThrottlingException.throwWriteSizeExceeded(
|
RpcThrottlingException.throwWriteCapacityUnitExceeded(
|
||||||
writeCapacityUnitLimiter.waitInterval(estimateWriteCapacityUnit));
|
writeCapacityUnitLimiter.waitInterval(estimateWriteCapacityUnit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,8 +175,8 @@ public class TimeBasedLimiter implements QuotaLimiter {
|
|||||||
readSizeLimiter.waitInterval(estimateReadSize));
|
readSizeLimiter.waitInterval(estimateReadSize));
|
||||||
}
|
}
|
||||||
if (!readCapacityUnitLimiter.canExecute(estimateReadCapacityUnit)) {
|
if (!readCapacityUnitLimiter.canExecute(estimateReadCapacityUnit)) {
|
||||||
RpcThrottlingException
|
RpcThrottlingException.throwReadCapacityUnitExceeded(
|
||||||
.throwWriteSizeExceeded(readCapacityUnitLimiter.waitInterval(estimateReadCapacityUnit));
|
readCapacityUnitLimiter.waitInterval(estimateReadCapacityUnit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user