Skip to content

Commit 1eea7f0

Browse files
MINOR: Make coordinator runtime inner classes static (apache#19332)
Make DeferredEventCollection and CoordinatorBatch static classes. DeferredEventCollection only needs to access the logger and CoordinatorBatch is only non-static because it holds DeferredEventCollections. Reviewers: David Jacot <[email protected]>
1 parent ccf2510 commit 1eea7f0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public int size() {
459459
* A simple container class to hold all the attributes
460460
* related to a pending batch.
461461
*/
462-
private class CoordinatorBatch {
462+
private static class CoordinatorBatch {
463463
/**
464464
* The base (or first) offset of the batch. If the batch fails
465465
* for any reason, the state machines is rolled back to it.
@@ -510,6 +510,7 @@ private class CoordinatorBatch {
510510
long nextOffset;
511511

512512
CoordinatorBatch(
513+
Logger log,
513514
long baseOffset,
514515
long appendTimeMs,
515516
int maxBatchSize,
@@ -526,7 +527,7 @@ private class CoordinatorBatch {
526527
this.buffer = buffer;
527528
this.builder = builder;
528529
this.lingerTimeoutTask = lingerTimeoutTask;
529-
this.deferredEvents = new DeferredEventCollection();
530+
this.deferredEvents = new DeferredEventCollection(log);
530531
}
531532
}
532533

@@ -893,6 +894,7 @@ public void run() {
893894
}
894895

895896
currentBatch = new CoordinatorBatch(
897+
log,
896898
prevLastWrittenOffset,
897899
currentTimeMs,
898900
maxBatchSize,
@@ -1160,9 +1162,21 @@ public void run() {
11601162
* A collection of {@link DeferredEvent}. When completed, completes all the events in the collection
11611163
* and logs any exceptions thrown.
11621164
*/
1163-
class DeferredEventCollection implements DeferredEvent {
1165+
static class DeferredEventCollection implements DeferredEvent {
1166+
/**
1167+
* The logger.
1168+
*/
1169+
private final Logger log;
1170+
1171+
/**
1172+
* The list of events.
1173+
*/
11641174
private final List<DeferredEvent> events = new ArrayList<>();
11651175

1176+
public DeferredEventCollection(Logger log) {
1177+
this.log = log;
1178+
}
1179+
11661180
@Override
11671181
public void complete(Throwable t) {
11681182
for (DeferredEvent event : events) {

0 commit comments

Comments
 (0)