Skip to content

Commit a6bfe19

Browse files
committed
HBASE-26154: Adds exception metrics for QuotaExceededException and RpcThrottlingException
1 parent f8ba9b3 commit a6bfe19

File tree

6 files changed

+53
-2
lines changed

6 files changed

+53
-2
lines changed

hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/metrics/ExceptionTrackingSource.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public interface ExceptionTrackingSource extends BaseSource {
4141
"rest of the requests will have to be retried.";
4242
String EXCEPTIONS_CALL_QUEUE_TOO_BIG = "exceptions.callQueueTooBig";
4343
String EXCEPTIONS_CALL_QUEUE_TOO_BIG_DESC = "Call queue is full";
44+
String EXCEPTIONS_QUOTA_EXCEEDED = "exceptions.quotaExceeded";
45+
String EXCEPTIONS_RPC_THROTTLING = "exceptions.rpcThrottling";
4446

4547
void exception();
4648

@@ -56,4 +58,6 @@ public interface ExceptionTrackingSource extends BaseSource {
5658
void tooBusyException();
5759
void multiActionTooLargeException();
5860
void callQueueTooBigException();
61+
void quotaExceededException();
62+
void rpcThrottlingException();
5963
}

hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/metrics/ExceptionTrackingSourceImpl.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class ExceptionTrackingSourceImpl extends BaseSourceImpl
3838
protected MutableFastCounter exceptionsMoved;
3939
protected MutableFastCounter exceptionsMultiTooLarge;
4040
protected MutableFastCounter exceptionsCallQueueTooBig;
41+
protected MutableFastCounter exceptionsQuotaExceeded;
42+
protected MutableFastCounter exceptionsRpcThrottling;
4143

4244
public ExceptionTrackingSourceImpl(String metricsName, String metricsDescription,
4345
String metricsContext, String metricsJmxContext) {
@@ -66,6 +68,10 @@ public void init() {
6668
.newCounter(EXCEPTIONS_MULTI_TOO_LARGE_NAME, EXCEPTIONS_MULTI_TOO_LARGE_DESC, 0L);
6769
this.exceptionsCallQueueTooBig = this.getMetricsRegistry()
6870
.newCounter(EXCEPTIONS_CALL_QUEUE_TOO_BIG, EXCEPTIONS_CALL_QUEUE_TOO_BIG_DESC, 0L);
71+
this.exceptionsQuotaExceeded = this.getMetricsRegistry()
72+
.newCounter(EXCEPTIONS_QUOTA_EXCEEDED, EXCEPTIONS_TYPE_DESC, 0L);
73+
this.exceptionsRpcThrottling = this.getMetricsRegistry()
74+
.newCounter(EXCEPTIONS_RPC_THROTTLING, EXCEPTIONS_TYPE_DESC, 0L);
6975
}
7076

7177
@Override
@@ -117,4 +123,14 @@ public void multiActionTooLargeException() {
117123
public void callQueueTooBigException() {
118124
exceptionsCallQueueTooBig.incr();
119125
}
126+
127+
@Override
128+
public void quotaExceededException() {
129+
exceptionsQuotaExceeded.incr();
130+
}
131+
132+
@Override
133+
public void rpcThrottlingException() {
134+
exceptionsRpcThrottling.incr();
135+
}
120136
}

hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/test/MetricsAssertHelperImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void assertGaugeLt(String name, double expected, BaseSource source) {
184184
@Override
185185
public void assertCounter(String name, long expected, BaseSource source) {
186186
long found = getCounter(name, source);
187-
assertEquals("Metrics Counters should be equal", (long) Long.valueOf(expected), found);
187+
assertEquals(name + "(" + found + ") should be equal", (long) Long.valueOf(expected), found);
188188
}
189189

190190
@Override

hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/MetricsHBaseServer.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,21 @@
2424
import org.apache.hadoop.hbase.NotServingRegionException;
2525
import org.apache.hadoop.hbase.RegionTooBusyException;
2626
import org.apache.hadoop.hbase.UnknownScannerException;
27+
import org.apache.hadoop.hbase.quotas.QuotaExceededException;
28+
import org.apache.hadoop.hbase.quotas.RpcThrottlingException;
2729
import org.apache.yetus.audience.InterfaceAudience;
2830
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
2931
import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
3032
import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException;
3133
import org.apache.hadoop.hbase.exceptions.RegionMovedException;
3234
import org.apache.hadoop.hbase.exceptions.ScannerResetException;
35+
import org.slf4j.Logger;
36+
import org.slf4j.LoggerFactory;
3337

3438
@InterfaceAudience.Private
3539
public class MetricsHBaseServer {
40+
private static final Logger LOG = LoggerFactory.getLogger(MetricsHBaseServer.class);
41+
3642
private MetricsHBaseServerSource source;
3743
private MetricsHBaseServerWrapper serverWrapper;
3844

@@ -116,6 +122,12 @@ public void exception(Throwable throwable) {
116122
source.multiActionTooLargeException();
117123
} else if (throwable instanceof CallQueueTooBigException) {
118124
source.callQueueTooBigException();
125+
} else if (throwable instanceof QuotaExceededException) {
126+
source.quotaExceededException();
127+
} else if (throwable instanceof RpcThrottlingException) {
128+
source.rpcThrottlingException();
129+
} else if (LOG.isDebugEnabled()) {
130+
LOG.debug("Unknown exception type", throwable);
119131
}
120132
}
121133
}

hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift/ThriftMetrics.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@
3131
import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException;
3232
import org.apache.hadoop.hbase.exceptions.RegionMovedException;
3333
import org.apache.hadoop.hbase.exceptions.ScannerResetException;
34+
import org.apache.hadoop.hbase.quotas.QuotaExceededException;
35+
import org.apache.hadoop.hbase.quotas.RpcThrottlingException;
3436
import org.apache.hadoop.hbase.thrift.generated.IOError;
3537
import org.apache.hadoop.hbase.thrift2.generated.TIOError;
3638
import org.apache.yetus.audience.InterfaceAudience;
39+
import org.slf4j.Logger;
40+
import org.slf4j.LoggerFactory;
3741

3842
/**
3943
* This class is for maintaining the various statistics of thrift server
@@ -42,6 +46,7 @@
4246
@InterfaceAudience.Private
4347
public class ThriftMetrics {
4448

49+
private static final Logger LOG = LoggerFactory.getLogger(ThriftMetrics.class);
4550

4651
public enum ThriftServerType {
4752
ONE,
@@ -143,6 +148,12 @@ public void exception(Throwable rawThrowable) {
143148
source.multiActionTooLargeException();
144149
} else if (throwable instanceof CallQueueTooBigException) {
145150
source.callQueueTooBigException();
151+
} else if (throwable instanceof QuotaExceededException) {
152+
source.quotaExceededException();
153+
} else if (throwable instanceof RpcThrottlingException) {
154+
source.rpcThrottlingException();
155+
} else if (LOG.isDebugEnabled()) {
156+
LOG.debug("Unknown exception type", throwable);
146157
}
147158
}
148159
}

hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/ErrorThrowingGetObserver.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import org.apache.hadoop.hbase.exceptions.RegionMovedException;
4141
import org.apache.hadoop.hbase.exceptions.ScannerResetException;
4242
import org.apache.hadoop.hbase.metrics.ExceptionTrackingSource;
43+
import org.apache.hadoop.hbase.quotas.QuotaExceededException;
44+
import org.apache.hadoop.hbase.quotas.RpcThrottlingException;
4345
import org.apache.hadoop.hbase.util.Bytes;
4446

4547
/**
@@ -79,6 +81,10 @@ public void preGetOp(ObserverContext<RegionCoprocessorEnvironment> e,
7981
throw new RegionTooBusyException("Failing for test");
8082
case OUT_OF_ORDER_SCANNER_NEXT:
8183
throw new OutOfOrderScannerNextException("Failing for test");
84+
case QUOTA_EXCEEDED:
85+
throw new QuotaExceededException("Failing for test");
86+
case RPC_THROTTLING:
87+
throw new RpcThrottlingException("Failing for test");
8288
default:
8389
throw new DoNotRetryIOException("Failing for test");
8490
}
@@ -94,7 +100,9 @@ public enum ErrorType {
94100
SCANNER_RESET(ExceptionTrackingSource.EXCEPTIONS_SCANNER_RESET_NAME),
95101
UNKNOWN_SCANNER(ExceptionTrackingSource.EXCEPTIONS_UNKNOWN_NAME),
96102
REGION_TOO_BUSY(ExceptionTrackingSource.EXCEPTIONS_BUSY_NAME),
97-
OUT_OF_ORDER_SCANNER_NEXT(ExceptionTrackingSource.EXCEPTIONS_OOO_NAME);
103+
OUT_OF_ORDER_SCANNER_NEXT(ExceptionTrackingSource.EXCEPTIONS_OOO_NAME),
104+
QUOTA_EXCEEDED(ExceptionTrackingSource.EXCEPTIONS_QUOTA_EXCEEDED),
105+
RPC_THROTTLING(ExceptionTrackingSource.EXCEPTIONS_RPC_THROTTLING);
98106

99107
private final String metricName;
100108

0 commit comments

Comments
 (0)