Skip to content

Commit 33043e1

Browse files
committed
fix: suggested changes
1 parent 9d55ee5 commit 33043e1

3 files changed

Lines changed: 17 additions & 15 deletions

File tree

netty/src/main/java/io/grpc/netty/NettyServerBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import io.grpc.ExperimentalApi;
3333
import io.grpc.ForwardingServerBuilder;
3434
import io.grpc.Internal;
35+
import io.grpc.MetricRecorder;
3536
import io.grpc.ServerBuilder;
3637
import io.grpc.ServerCredentials;
3738
import io.grpc.ServerStreamTracer;
@@ -165,7 +166,7 @@ private final class NettyClientTransportServersBuilder implements ClientTranspor
165166
@Override
166167
public InternalServer buildClientTransportServers(
167168
List<? extends ServerStreamTracer.Factory> streamTracerFactories,
168-
io.grpc.MetricRecorder metricRecorder) {
169+
MetricRecorder metricRecorder) {
169170
return buildTransportServers(streamTracerFactories, metricRecorder);
170171
}
171172
}
@@ -707,7 +708,7 @@ void eagAttributes(Attributes eagAttributes) {
707708
@VisibleForTesting
708709
NettyServer buildTransportServers(
709710
List<? extends ServerStreamTracer.Factory> streamTracerFactories,
710-
io.grpc.MetricRecorder metricRecorder) {
711+
MetricRecorder metricRecorder) {
711712
assertEventLoopsAndChannelType();
712713

713714
ProtocolNegotiator negotiator = protocolNegotiatorFactory.newNegotiator(

netty/src/main/java/io/grpc/netty/TcpMetrics.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ final class TcpMetrics {
4242

4343
static final class EpollInfo {
4444
final Class<?> channelClass;
45-
final Class<?> infoClass;
4645
final java.lang.reflect.Constructor<?> infoConstructor;
4746
final Method tcpInfo;
4847
final Method totalRetrans;
@@ -51,14 +50,12 @@ static final class EpollInfo {
5150

5251
EpollInfo(
5352
Class<?> channelClass,
54-
Class<?> infoClass,
5553
java.lang.reflect.Constructor<?> infoConstructor,
5654
Method tcpInfo,
5755
Method totalRetrans,
5856
Method retransmits,
5957
Method rtt) {
6058
this.channelClass = channelClass;
61-
this.infoClass = infoClass;
6259
this.infoConstructor = infoConstructor;
6360
this.tcpInfo = tcpInfo;
6461
this.totalRetrans = totalRetrans;
@@ -78,7 +75,6 @@ static EpollInfo loadEpollInfo() {
7875
Class<?> infoClass = Class.forName("io.netty.channel.epoll.EpollTcpInfo");
7976
return new EpollInfo(
8077
channelClass,
81-
infoClass,
8278
infoClass.getDeclaredConstructor(),
8379
channelClass.getMethod("tcpInfo", infoClass),
8480
infoClass.getMethod("totalRetrans"),

netty/src/test/java/io/grpc/netty/TcpMetricsTest.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.List;
3939
import java.util.Objects;
4040
import java.util.concurrent.TimeUnit;
41+
import org.junit.After;
4142
import org.junit.Before;
4243
import org.junit.Rule;
4344
import org.junit.Test;
@@ -61,12 +62,16 @@ public class TcpMetricsTest {
6162

6263
@Before
6364
public void setUp() throws Exception {
64-
TcpMetrics.epollInfo = TcpMetrics.loadEpollInfo();
6565
FakeEpollTcpInfo dummyInfo = new FakeEpollTcpInfo();
6666
channel = new ConfigurableFakeWithTcpInfo(dummyInfo);
6767
metrics = new TcpMetrics(metricRecorder);
6868
}
6969

70+
@After
71+
public void tearDown() throws Exception {
72+
TcpMetrics.epollInfo = TcpMetrics.loadEpollInfo();
73+
}
74+
7075
@Test
7176
public void metricsInitialization() {
7277

@@ -108,7 +113,7 @@ public long rtt() {
108113
public void tracker_recordTcpInfo_reflectionSuccess() throws Exception {
109114
MetricRecorder recorder = mock(MetricRecorder.class);
110115
TcpMetrics.epollInfo = new TcpMetrics.EpollInfo(
111-
ConfigurableFakeWithTcpInfo.class, FakeEpollTcpInfo.class,
116+
ConfigurableFakeWithTcpInfo.class,
112117
FakeEpollTcpInfo.class.getConstructor(),
113118
ConfigurableFakeWithTcpInfo.class.getMethod("tcpInfo", FakeEpollTcpInfo.class),
114119
FakeEpollTcpInfo.class.getMethod("totalRetrans"),
@@ -138,7 +143,7 @@ public void tracker_recordTcpInfo_reflectionSuccess() throws Exception {
138143
public void tracker_periodicRecord_doesNotRecordRecurringRetransmits() throws Exception {
139144
MetricRecorder recorder = mock(MetricRecorder.class);
140145
TcpMetrics.epollInfo = new TcpMetrics.EpollInfo(
141-
ConfigurableFakeWithTcpInfo.class, FakeEpollTcpInfo.class,
146+
ConfigurableFakeWithTcpInfo.class,
142147
FakeEpollTcpInfo.class.getConstructor(),
143148
ConfigurableFakeWithTcpInfo.class.getMethod("tcpInfo", FakeEpollTcpInfo.class),
144149
FakeEpollTcpInfo.class.getMethod("totalRetrans"),
@@ -176,7 +181,7 @@ public void tracker_periodicRecord_doesNotRecordRecurringRetransmits() throws Ex
176181
public void tracker_channelInactive_recordsRecurringRetransmits_raw_notDelta() throws Exception {
177182
MetricRecorder recorder = mock(MetricRecorder.class);
178183
TcpMetrics.epollInfo = new TcpMetrics.EpollInfo(
179-
ConfigurableFakeWithTcpInfo.class, FakeEpollTcpInfo.class,
184+
ConfigurableFakeWithTcpInfo.class,
180185
FakeEpollTcpInfo.class.getConstructor(),
181186
ConfigurableFakeWithTcpInfo.class.getMethod("tcpInfo", FakeEpollTcpInfo.class),
182187
FakeEpollTcpInfo.class.getMethod("totalRetrans"),
@@ -220,7 +225,7 @@ public void tracker_channelInactive_recordsRecurringRetransmits_raw_notDelta() t
220225
public void tracker_periodicRecord_reportsDeltaForTotalRetrans() throws Exception {
221226
MetricRecorder recorder = mock(MetricRecorder.class);
222227
TcpMetrics.epollInfo = new TcpMetrics.EpollInfo(
223-
ConfigurableFakeWithTcpInfo.class, FakeEpollTcpInfo.class,
228+
ConfigurableFakeWithTcpInfo.class,
224229
FakeEpollTcpInfo.class.getConstructor(),
225230
ConfigurableFakeWithTcpInfo.class.getMethod("tcpInfo", FakeEpollTcpInfo.class),
226231
FakeEpollTcpInfo.class.getMethod("totalRetrans"),
@@ -274,7 +279,7 @@ public void tracker_periodicRecord_reportsDeltaForTotalRetrans() throws Exceptio
274279
public void tracker_periodicRecord_doesNotReportZeroDeltaForTotalRetrans() throws Exception {
275280
MetricRecorder recorder = mock(MetricRecorder.class);
276281
TcpMetrics.epollInfo = new TcpMetrics.EpollInfo(
277-
ConfigurableFakeWithTcpInfo.class, FakeEpollTcpInfo.class,
282+
ConfigurableFakeWithTcpInfo.class,
278283
FakeEpollTcpInfo.class.getConstructor(),
279284
ConfigurableFakeWithTcpInfo.class.getMethod("tcpInfo", FakeEpollTcpInfo.class),
280285
FakeEpollTcpInfo.class.getMethod("totalRetrans"),
@@ -362,7 +367,7 @@ public void tracker_reportsDeltas_correctly() throws Exception {
362367
MetricRecorder recorder = mock(MetricRecorder.class);
363368

364369
TcpMetrics.epollInfo = new TcpMetrics.EpollInfo(
365-
ConfigurableFakeWithTcpInfo.class, FakeEpollTcpInfo.class,
370+
ConfigurableFakeWithTcpInfo.class,
366371
FakeEpollTcpInfo.class.getConstructor(),
367372
ConfigurableFakeWithTcpInfo.class.getMethod("tcpInfo", FakeEpollTcpInfo.class),
368373
FakeEpollTcpInfo.class.getMethod("totalRetrans"),
@@ -548,7 +553,7 @@ public void channelInactive_decrementsCount_noEpoll_noError() {
548553
@Test
549554
public void channelActive_schedulesReportTimer() throws Exception {
550555
TcpMetrics.epollInfo = new TcpMetrics.EpollInfo(
551-
ConfigurableFakeWithTcpInfo.class, FakeEpollTcpInfo.class,
556+
ConfigurableFakeWithTcpInfo.class,
552557
FakeEpollTcpInfo.class.getConstructor(),
553558
ConfigurableFakeWithTcpInfo.class.getMethod("tcpInfo", FakeEpollTcpInfo.class),
554559
FakeEpollTcpInfo.class.getMethod("totalRetrans"),
@@ -587,7 +592,7 @@ public void channelActive_schedulesReportTimer() throws Exception {
587592
@Test
588593
public void channelInactive_cancelsReportTimer() throws Exception {
589594
TcpMetrics.epollInfo = new TcpMetrics.EpollInfo(
590-
ConfigurableFakeWithTcpInfo.class, FakeEpollTcpInfo.class,
595+
ConfigurableFakeWithTcpInfo.class,
591596
FakeEpollTcpInfo.class.getConstructor(),
592597
ConfigurableFakeWithTcpInfo.class.getMethod("tcpInfo", FakeEpollTcpInfo.class),
593598
FakeEpollTcpInfo.class.getMethod("totalRetrans"),

0 commit comments

Comments
 (0)