HubSpot Backport: HBASE-26727 Fix CallDroppedException reporting

This commit is contained in:
Bryan Beaudreault 2022-01-31 19:55:11 -05:00
parent 27855ed288
commit cf6efffc77
2 changed files with 21 additions and 1 deletions

View File

@ -216,6 +216,7 @@ public class CallRunner {
call.setResponse(null, null, CALL_DROPPED_EXCEPTION, "Call dropped, server " call.setResponse(null, null, CALL_DROPPED_EXCEPTION, "Call dropped, server "
+ (address != null ? address : "(channel closed)") + " is overloaded, please retry."); + (address != null ? address : "(channel closed)") + " is overloaded, please retry.");
call.sendResponseIfReady(); call.sendResponseIfReady();
this.rpcServer.getMetrics().exception(CALL_DROPPED_EXCEPTION);
} catch (ClosedChannelException cce) { } catch (ClosedChannelException cce) {
InetSocketAddress address = rpcServer.getListenerAddress(); InetSocketAddress address = rpcServer.getListenerAddress();
RpcServer.LOG.warn(Thread.currentThread().getName() + ": caught a ClosedChannelException, " + RpcServer.LOG.warn(Thread.currentThread().getName() + ": caught a ClosedChannelException, " +

View File

@ -17,6 +17,8 @@
*/ */
package org.apache.hadoop.hbase.ipc; package org.apache.hadoop.hbase.ipc;
import java.net.InetSocketAddress;
import org.apache.hadoop.hbase.CallDroppedException;
import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandlerImpl; import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandlerImpl;
import org.apache.hadoop.hbase.testclassification.RPCTests; import org.apache.hadoop.hbase.testclassification.RPCTests;
@ -60,7 +62,7 @@ public class TestCallRunner {
} }
@Test @Test
public void testCallRunnerDrop() { public void testCallRunnerDropDisconnected() {
RpcServerInterface mockRpcServer = Mockito.mock(RpcServerInterface.class); RpcServerInterface mockRpcServer = Mockito.mock(RpcServerInterface.class);
Mockito.when(mockRpcServer.isStarted()).thenReturn(true); Mockito.when(mockRpcServer.isStarted()).thenReturn(true);
ServerCall mockCall = Mockito.mock(ServerCall.class); ServerCall mockCall = Mockito.mock(ServerCall.class);
@ -71,4 +73,21 @@ public class TestCallRunner {
cr.drop(); cr.drop();
Mockito.verify(mockCall, Mockito.times(1)).cleanup(); Mockito.verify(mockCall, Mockito.times(1)).cleanup();
} }
@Test
public void testCallRunnerDropConnected() {
RpcServerInterface mockRpcServer = Mockito.mock(RpcServerInterface.class);
MetricsHBaseServer mockMetrics = Mockito.mock(MetricsHBaseServer.class);
Mockito.when(mockRpcServer.getMetrics()).thenReturn(mockMetrics);
Mockito.when(mockRpcServer.isStarted()).thenReturn(true);
Mockito.when(mockRpcServer.getListenerAddress()).thenReturn(InetSocketAddress.createUnresolved("foo", 60020));
ServerCall mockCall = Mockito.mock(ServerCall.class);
Mockito.when(mockCall.disconnectSince()).thenReturn(-1L);
CallRunner cr = new CallRunner(mockRpcServer, mockCall);
cr.setStatus(new MonitoredRPCHandlerImpl());
cr.drop();
Mockito.verify(mockCall, Mockito.times(1)).cleanup();
Mockito.verify(mockMetrics).exception(Mockito.any(CallDroppedException.class));
}
} }