Skip to content

Commit c2aeec4

Browse files
authored
MINOR: Remove logContext arrtibute from StreamsGroup and CoordinatorRuntime (#20572)
The `logContext` attribute in `StreamsGroup` and `CoordinatorRuntime` is not used anymore. This patch removes it. Reviewers: Ken Huang <[email protected]>, TengYao Chi <[email protected]>, Chia-Ping Tsai <[email protected]>
1 parent e27ea8d commit c2aeec4

File tree

7 files changed

+14
-28
lines changed

7 files changed

+14
-28
lines changed

clients/src/main/java/org/apache/kafka/common/network/ChannelBuilders.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private static ChannelBuilder create(SecurityProtocol securityProtocol,
125125
switch (securityProtocol) {
126126
case SSL:
127127
requireNonNullMode(connectionMode, securityProtocol);
128-
channelBuilder = new SslChannelBuilder(connectionMode, listenerName, isInterBrokerListener, logContext);
128+
channelBuilder = new SslChannelBuilder(connectionMode, listenerName, isInterBrokerListener);
129129
break;
130130
case SASL_SSL:
131131
case SASL_PLAINTEXT:

clients/src/main/java/org/apache/kafka/common/network/SslChannelBuilder.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.kafka.common.security.auth.SslAuthenticationContext;
2727
import org.apache.kafka.common.security.ssl.SslFactory;
2828
import org.apache.kafka.common.security.ssl.SslPrincipalMapper;
29-
import org.apache.kafka.common.utils.LogContext;
3029
import org.apache.kafka.common.utils.Utils;
3130

3231
import java.io.Closeable;
@@ -53,8 +52,7 @@ public class SslChannelBuilder implements ChannelBuilder, ListenerReconfigurable
5352
*/
5453
public SslChannelBuilder(ConnectionMode connectionMode,
5554
ListenerName listenerName,
56-
boolean isInterBrokerListener,
57-
LogContext logContext) {
55+
boolean isInterBrokerListener) {
5856
this.connectionMode = connectionMode;
5957
this.listenerName = listenerName;
6058
this.isInterBrokerListener = isInterBrokerListener;

clients/src/test/java/org/apache/kafka/common/network/SslSelectorTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,10 @@ public void setUp() throws Exception {
7474
this.server.start();
7575
this.time = new MockTime();
7676
sslClientConfigs = createSslClientConfigs(trustStoreFile);
77-
LogContext logContext = new LogContext();
78-
this.channelBuilder = new SslChannelBuilder(ConnectionMode.CLIENT, null, false, logContext);
77+
this.channelBuilder = new SslChannelBuilder(ConnectionMode.CLIENT, null, false);
7978
this.channelBuilder.configure(sslClientConfigs);
8079
this.metrics = new Metrics();
81-
this.selector = new Selector(5000, metrics, time, "MetricGroup", channelBuilder, logContext);
80+
this.selector = new Selector(5000, metrics, time, "MetricGroup", channelBuilder, new LogContext());
8281
}
8382

8483
protected abstract Map<String, Object> createSslClientConfigs(File trustStoreFile) throws GeneralSecurityException, IOException;
@@ -255,7 +254,7 @@ public void testMuteOnOOM() throws Exception {
255254
.tlsProtocol(tlsProtocol)
256255
.createNewTrustStore(trustStoreFile)
257256
.build();
258-
channelBuilder = new SslChannelBuilder(ConnectionMode.SERVER, null, false, new LogContext());
257+
channelBuilder = new SslChannelBuilder(ConnectionMode.SERVER, null, false);
259258
channelBuilder.configure(sslServerConfigs);
260259
selector = new Selector(NetworkReceive.UNLIMITED, 5000, metrics, time, "MetricGroup",
261260
new HashMap<>(), true, false, channelBuilder, pool, new LogContext());
@@ -342,7 +341,7 @@ private SslSender createSender(String tlsProtocol, InetSocketAddress serverAddre
342341
private static class TestSslChannelBuilder extends SslChannelBuilder {
343342

344343
public TestSslChannelBuilder(ConnectionMode connectionMode) {
345-
super(connectionMode, null, false, new LogContext());
344+
super(connectionMode, null, false);
346345
}
347346

348347
@Override

clients/src/test/java/org/apache/kafka/common/network/SslTransportLayerTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -767,11 +767,10 @@ public void testApplicationBufferResize(Args args) throws Exception {
767767
@ParameterizedTest
768768
@ArgumentsSource(SslTransportLayerArgumentsProvider.class)
769769
public void testNetworkThreadTimeRecorded(Args args) throws Exception {
770-
LogContext logContext = new LogContext();
771-
ChannelBuilder channelBuilder = new SslChannelBuilder(ConnectionMode.CLIENT, null, false, logContext);
770+
ChannelBuilder channelBuilder = new SslChannelBuilder(ConnectionMode.CLIENT, null, false);
772771
channelBuilder.configure(args.sslClientConfigs);
773772
try (Selector selector = new Selector(NetworkReceive.UNLIMITED, Selector.NO_IDLE_TIMEOUT_MS, new Metrics(), Time.SYSTEM,
774-
"MetricGroup", new HashMap<>(), false, true, channelBuilder, MemoryPool.NONE, logContext)) {
773+
"MetricGroup", new HashMap<>(), false, true, channelBuilder, MemoryPool.NONE, new LogContext())) {
775774

776775
String node = "0";
777776
server = createEchoServer(args, SecurityProtocol.SSL);
@@ -967,7 +966,7 @@ public void testClosePlaintext(Args args) throws Exception {
967966
}
968967

969968
private SslChannelBuilder newClientChannelBuilder() {
970-
return new SslChannelBuilder(ConnectionMode.CLIENT, null, false, new LogContext());
969+
return new SslChannelBuilder(ConnectionMode.CLIENT, null, false);
971970
}
972971

973972
private void testClose(Args args, SecurityProtocol securityProtocol, ChannelBuilder clientChannelBuilder) throws Exception {
@@ -1311,10 +1310,9 @@ private NioEchoServer createEchoServer(Args args, SecurityProtocol securityProto
13111310
}
13121311

13131312
private Selector createSelector(Args args) {
1314-
LogContext logContext = new LogContext();
1315-
ChannelBuilder channelBuilder = new SslChannelBuilder(ConnectionMode.CLIENT, null, false, logContext);
1313+
ChannelBuilder channelBuilder = new SslChannelBuilder(ConnectionMode.CLIENT, null, false);
13161314
channelBuilder.configure(args.sslClientConfigs);
1317-
selector = new Selector(5000, new Metrics(), TIME, "MetricGroup", channelBuilder, logContext);
1315+
selector = new Selector(5000, new Metrics(), TIME, "MetricGroup", channelBuilder, new LogContext());
13181316
return selector;
13191317
}
13201318

@@ -1371,7 +1369,7 @@ static class TestSslChannelBuilder extends SslChannelBuilder {
13711369
int flushDelayCount = 0;
13721370

13731371
public TestSslChannelBuilder(ConnectionMode connectionMode) {
1374-
super(connectionMode, null, false, new LogContext());
1372+
super(connectionMode, null, false);
13751373
}
13761374

13771375
public void configureBufferSizes(Integer netReadBufSize, Integer netWriteBufSize, Integer appBufSize) {

clients/src/test/java/org/apache/kafka/common/network/SslTransportTls12Tls13Test.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ public void setup() throws Exception {
5050
sslServerConfigs = serverCertStores.getTrustingConfig(clientCertStores);
5151
sslClientConfigs = clientCertStores.getTrustingConfig(serverCertStores);
5252

53-
LogContext logContext = new LogContext();
54-
ChannelBuilder channelBuilder = new SslChannelBuilder(ConnectionMode.CLIENT, null, false, logContext);
53+
ChannelBuilder channelBuilder = new SslChannelBuilder(ConnectionMode.CLIENT, null, false);
5554
channelBuilder.configure(sslClientConfigs);
56-
this.selector = new Selector(5000, new Metrics(), TIME, "MetricGroup", channelBuilder, logContext);
55+
this.selector = new Selector(5000, new Metrics(), TIME, "MetricGroup", channelBuilder, new LogContext());
5756
}
5857

5958
@AfterEach

coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,11 +1923,6 @@ public void onHighWatermarkUpdated(
19231923
*/
19241924
private final String logPrefix;
19251925

1926-
/**
1927-
* The log context.
1928-
*/
1929-
private final LogContext logContext;
1930-
19311926
/**
19321927
* The logger.
19331928
*/
@@ -2054,7 +2049,6 @@ private CoordinatorRuntime(
20542049
ExecutorService executorService
20552050
) {
20562051
this.logPrefix = logPrefix;
2057-
this.logContext = logContext;
20582052
this.log = logContext.logger(CoordinatorRuntime.class);
20592053
this.time = time;
20602054
this.timer = timer;

group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsGroup.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public static class DeadlineAndEpoch {
113113
}
114114
}
115115

116-
private final LogContext logContext;
117116
private final Logger log;
118117

119118
/**
@@ -217,7 +216,6 @@ public StreamsGroup(
217216
String groupId
218217
) {
219218
this.log = logContext.logger(StreamsGroup.class);
220-
this.logContext = logContext;
221219
this.snapshotRegistry = Objects.requireNonNull(snapshotRegistry);
222220
this.groupId = Objects.requireNonNull(groupId);
223221
this.state = new TimelineObject<>(snapshotRegistry, EMPTY);

0 commit comments

Comments
 (0)