Skip to content

Commit

Permalink
HBASE-26175 MetricsHBaseServer should record all kinds of Exceptions (#…
Browse files Browse the repository at this point in the history
…4248)

Signed-off-by: Pankaj Kumar <pankajkumar@apache.org>
  • Loading branch information
sunhelly committed Mar 24, 2022
1 parent 2d1dc53 commit 7906703
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public interface ExceptionTrackingSource extends BaseSource {
String EXCEPTIONS_RPC_THROTTLING = "exceptions.rpcThrottling";
String EXCEPTIONS_CALL_DROPPED = "exceptions.callDropped";
String EXCEPTIONS_CALL_TIMED_OUT = "exceptions.callTimedOut";
String EXCEPTIONS_REQUEST_TOO_BIG = "exceptions.requestTooBig";
String OTHER_EXCEPTIONS = "exceptions.otherExceptions";

void exception();

Expand All @@ -64,4 +66,6 @@ public interface ExceptionTrackingSource extends BaseSource {
void rpcThrottlingException();
void callDroppedException();
void callTimedOut();
void requestTooBigException();
void otherExceptions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class ExceptionTrackingSourceImpl extends BaseSourceImpl
protected MutableFastCounter exceptionsRpcThrottling;
protected MutableFastCounter exceptionsCallDropped;
protected MutableFastCounter exceptionsCallTimedOut;
protected MutableFastCounter exceptionRequestTooBig;
protected MutableFastCounter otherExceptions;

public ExceptionTrackingSourceImpl(String metricsName, String metricsDescription,
String metricsContext, String metricsJmxContext) {
Expand Down Expand Up @@ -78,6 +80,10 @@ public void init() {
.newCounter(EXCEPTIONS_CALL_DROPPED, EXCEPTIONS_TYPE_DESC, 0L);
this.exceptionsCallTimedOut = this.getMetricsRegistry()
.newCounter(EXCEPTIONS_CALL_TIMED_OUT, EXCEPTIONS_TYPE_DESC, 0L);
this.exceptionRequestTooBig = this.getMetricsRegistry()
.newCounter(EXCEPTIONS_REQUEST_TOO_BIG, EXCEPTIONS_TYPE_DESC, 0L);
this.otherExceptions = this.getMetricsRegistry()
.newCounter(OTHER_EXCEPTIONS, EXCEPTIONS_TYPE_DESC, 0L);
}

@Override
Expand Down Expand Up @@ -149,4 +155,14 @@ public void callDroppedException() {
public void callTimedOut() {
exceptionsCallTimedOut.incr();
}

@Override
public void requestTooBigException() {
exceptionRequestTooBig.incr();
}

@Override
public void otherExceptions() {
otherExceptions.incr();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.RegionTooBusyException;
import org.apache.hadoop.hbase.UnknownScannerException;
import org.apache.hadoop.hbase.exceptions.RequestTooBigException;
import org.apache.hadoop.hbase.quotas.QuotaExceededException;
import org.apache.hadoop.hbase.quotas.RpcThrottlingException;
import org.apache.yetus.audience.InterfaceAudience;
Expand Down Expand Up @@ -129,8 +130,13 @@ public void exception(Throwable throwable) {
source.rpcThrottlingException();
} else if (throwable instanceof CallDroppedException) {
source.callDroppedException();
} else if (LOG.isDebugEnabled()) {
LOG.debug("Unknown exception type", throwable);
} else if (throwable instanceof RequestTooBigException) {
source.requestTooBigException();
} else {
source.otherExceptions();
if (LOG.isDebugEnabled()) {
LOG.debug("Unknown exception type", throwable);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
*/
package org.apache.hadoop.hbase.ipc;

import static org.junit.Assert.*;

import static org.junit.Assert.assertEquals;
import org.apache.hadoop.hbase.CallDroppedException;
import org.apache.hadoop.hbase.CompatibilityFactory;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.RegionTooBusyException;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException;
import org.apache.hadoop.hbase.exceptions.RegionMovedException;
import org.apache.hadoop.hbase.exceptions.RequestTooBigException;
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
Expand Down Expand Up @@ -145,12 +146,23 @@ public void testSourceMethods() {
mrpc.exception(new OutOfOrderScannerNextException());
mrpc.exception(new NotServingRegionException());
mrpc.exception(new CallDroppedException());
mrpc.exception(new RequestTooBigException());
mrpc.exception(new FakeException());
HELPER.assertCounter("exceptions.RegionMovedException", 1, serverSource);
HELPER.assertCounter("exceptions.RegionTooBusyException", 1, serverSource);
HELPER.assertCounter("exceptions.OutOfOrderScannerNextException", 1, serverSource);
HELPER.assertCounter("exceptions.NotServingRegionException", 1, serverSource);
HELPER.assertCounter("exceptions.callDropped", 1, serverSource);
HELPER.assertCounter("exceptions", 6, serverSource);
HELPER.assertCounter("exceptions.requestTooBig", 1, serverSource);
HELPER.assertCounter("exceptions.otherExceptions", 1, serverSource);
HELPER.assertCounter("exceptions", 8, serverSource);
}

private class FakeException extends DoNotRetryIOException {

public FakeException() {
super();
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException;
import org.apache.hadoop.hbase.exceptions.RegionMovedException;
import org.apache.hadoop.hbase.exceptions.RequestTooBigException;
import org.apache.hadoop.hbase.exceptions.ScannerResetException;
import org.apache.hadoop.hbase.quotas.QuotaExceededException;
import org.apache.hadoop.hbase.quotas.RpcThrottlingException;
Expand Down Expand Up @@ -155,8 +156,13 @@ public void exception(Throwable rawThrowable) {
source.rpcThrottlingException();
} else if (throwable instanceof CallDroppedException) {
source.callDroppedException();
} else if (LOG.isDebugEnabled()) {
LOG.debug("Unknown exception type", throwable);
} else if (throwable instanceof RequestTooBigException) {
source.requestTooBigException();
} else {
source.otherExceptions();
if (LOG.isDebugEnabled()) {
LOG.debug("Unknown exception type", throwable);
}
}
}
}
Expand Down

0 comments on commit 7906703

Please sign in to comment.