Skip to content

Commit a49c758

Browse files
authored
HBASE-26727 Fix CallDroppedException reporting (#4088)
Signed-off-by: Andrew Purtell <apurtell@apache.org>
1 parent 8fb3d46 commit a49c758

File tree

5 files changed

+36
-1
lines changed

5 files changed

+36
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public interface ExceptionTrackingSource extends BaseSource {
4444
String EXCEPTIONS_QUOTA_EXCEEDED = "exceptions.quotaExceeded";
4545
String EXCEPTIONS_RPC_THROTTLING = "exceptions.rpcThrottling";
4646
String EXCEPTIONS_CALL_DROPPED = "exceptions.callDropped";
47+
String EXCEPTIONS_CALL_TIMED_OUT = "exceptions.callTimedOut";
4748

4849
void exception();
4950

@@ -62,4 +63,5 @@ public interface ExceptionTrackingSource extends BaseSource {
6263
void quotaExceededException();
6364
void rpcThrottlingException();
6465
void callDroppedException();
66+
void callTimedOut();
6567
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class ExceptionTrackingSourceImpl extends BaseSourceImpl
4141
protected MutableFastCounter exceptionsQuotaExceeded;
4242
protected MutableFastCounter exceptionsRpcThrottling;
4343
protected MutableFastCounter exceptionsCallDropped;
44+
protected MutableFastCounter exceptionsCallTimedOut;
4445

4546
public ExceptionTrackingSourceImpl(String metricsName, String metricsDescription,
4647
String metricsContext, String metricsJmxContext) {
@@ -75,6 +76,8 @@ public void init() {
7576
.newCounter(EXCEPTIONS_RPC_THROTTLING, EXCEPTIONS_TYPE_DESC, 0L);
7677
this.exceptionsCallDropped = this.getMetricsRegistry()
7778
.newCounter(EXCEPTIONS_CALL_DROPPED, EXCEPTIONS_TYPE_DESC, 0L);
79+
this.exceptionsCallTimedOut = this.getMetricsRegistry()
80+
.newCounter(EXCEPTIONS_CALL_TIMED_OUT, EXCEPTIONS_TYPE_DESC, 0L);
7881
}
7982

8083
@Override
@@ -141,4 +144,9 @@ public void rpcThrottlingException() {
141144
public void callDroppedException() {
142145
exceptionsCallDropped.incr();
143146
}
147+
148+
@Override
149+
public void callTimedOut() {
150+
exceptionsCallTimedOut.incr();
151+
}
144152
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public void run() {
9999
call.setStartTime(EnvironmentEdgeManager.currentTime());
100100
if (call.getStartTime() > call.getDeadline()) {
101101
RpcServer.LOG.warn("Dropping timed out call: " + call);
102+
this.rpcServer.getMetrics().callTimedOut();
102103
return;
103104
}
104105
this.status.setStatus("Setting up call");
@@ -207,6 +208,7 @@ public void drop() {
207208
call.setResponse(null, null, CALL_DROPPED_EXCEPTION, "Call dropped, server "
208209
+ (address != null ? address : "(channel closed)") + " is overloaded, please retry.");
209210
call.sendResponseIfReady();
211+
this.rpcServer.getMetrics().exception(CALL_DROPPED_EXCEPTION);
210212
} catch (ClosedChannelException cce) {
211213
InetSocketAddress address = rpcServer.getListenerAddress();
212214
RpcServer.LOG.warn(Thread.currentThread().getName() + ": caught a ClosedChannelException, " +

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ public void exception(Throwable throwable) {
135135
}
136136
}
137137

138+
void callTimedOut() {
139+
source.callTimedOut();
140+
}
141+
138142
public MetricsHBaseServerSource getMetricsSource() {
139143
return source;
140144
}

hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestCallRunner.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
package org.apache.hadoop.hbase.ipc;
1919

20+
import java.net.InetSocketAddress;
21+
import org.apache.hadoop.hbase.CallDroppedException;
2022
import org.apache.hadoop.hbase.HBaseClassTestRule;
2123
import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandlerImpl;
2224
import org.apache.hadoop.hbase.testclassification.RPCTests;
@@ -60,7 +62,7 @@ public void testCallCleanup() {
6062
}
6163

6264
@Test
63-
public void testCallRunnerDrop() {
65+
public void testCallRunnerDropDisconnected() {
6466
RpcServerInterface mockRpcServer = Mockito.mock(RpcServerInterface.class);
6567
Mockito.when(mockRpcServer.isStarted()).thenReturn(true);
6668
ServerCall mockCall = Mockito.mock(ServerCall.class);
@@ -71,4 +73,21 @@ public void testCallRunnerDrop() {
7173
cr.drop();
7274
Mockito.verify(mockCall, Mockito.times(1)).cleanup();
7375
}
76+
77+
@Test
78+
public void testCallRunnerDropConnected() {
79+
RpcServerInterface mockRpcServer = Mockito.mock(RpcServerInterface.class);
80+
MetricsHBaseServer mockMetrics = Mockito.mock(MetricsHBaseServer.class);
81+
Mockito.when(mockRpcServer.getMetrics()).thenReturn(mockMetrics);
82+
Mockito.when(mockRpcServer.isStarted()).thenReturn(true);
83+
Mockito.when(mockRpcServer.getListenerAddress()).thenReturn(InetSocketAddress.createUnresolved("foo", 60020));
84+
ServerCall mockCall = Mockito.mock(ServerCall.class);
85+
Mockito.when(mockCall.disconnectSince()).thenReturn(-1L);
86+
87+
CallRunner cr = new CallRunner(mockRpcServer, mockCall);
88+
cr.setStatus(new MonitoredRPCHandlerImpl());
89+
cr.drop();
90+
Mockito.verify(mockCall, Mockito.times(1)).cleanup();
91+
Mockito.verify(mockMetrics).exception(Mockito.any(CallDroppedException.class));
92+
}
7493
}

0 commit comments

Comments
 (0)