Skip to content

Commit 13f284b

Browse files
committed
HBASE-26727 Fix CallDroppedException reporting
1 parent 351caa5 commit 13f284b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public void drop() {
222222
call.setResponse(null, null, CALL_DROPPED_EXCEPTION, "Call dropped, server "
223223
+ (address != null ? address : "(channel closed)") + " is overloaded, please retry.");
224224
call.sendResponseIfReady();
225+
this.rpcServer.getMetrics().exception(CALL_DROPPED_EXCEPTION);
225226
} catch (ClosedChannelException cce) {
226227
InetSocketAddress address = rpcServer.getListenerAddress();
227228
RpcServer.LOG.warn(Thread.currentThread().getName() + ": caught a ClosedChannelException, " +

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)