MINOR: Make coordinator runtime inner classes static (#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 <djacot@confluent.io>
This commit is contained in:
Sean Quah 2025-04-01 15:17:39 +01:00 committed by GitHub
parent ccf2510fdd
commit 1eea7f0528
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 3 deletions

View File

@ -459,7 +459,7 @@ public class CoordinatorRuntime<S extends CoordinatorShard<U>, U> implements Aut
* A simple container class to hold all the attributes * A simple container class to hold all the attributes
* related to a pending batch. * related to a pending batch.
*/ */
private class CoordinatorBatch { private static class CoordinatorBatch {
/** /**
* The base (or first) offset of the batch. If the batch fails * The base (or first) offset of the batch. If the batch fails
* for any reason, the state machines is rolled back to it. * for any reason, the state machines is rolled back to it.
@ -510,6 +510,7 @@ public class CoordinatorRuntime<S extends CoordinatorShard<U>, U> implements Aut
long nextOffset; long nextOffset;
CoordinatorBatch( CoordinatorBatch(
Logger log,
long baseOffset, long baseOffset,
long appendTimeMs, long appendTimeMs,
int maxBatchSize, int maxBatchSize,
@ -526,7 +527,7 @@ public class CoordinatorRuntime<S extends CoordinatorShard<U>, U> implements Aut
this.buffer = buffer; this.buffer = buffer;
this.builder = builder; this.builder = builder;
this.lingerTimeoutTask = lingerTimeoutTask; this.lingerTimeoutTask = lingerTimeoutTask;
this.deferredEvents = new DeferredEventCollection(); this.deferredEvents = new DeferredEventCollection(log);
} }
} }
@ -893,6 +894,7 @@ public class CoordinatorRuntime<S extends CoordinatorShard<U>, U> implements Aut
} }
currentBatch = new CoordinatorBatch( currentBatch = new CoordinatorBatch(
log,
prevLastWrittenOffset, prevLastWrittenOffset,
currentTimeMs, currentTimeMs,
maxBatchSize, maxBatchSize,
@ -1160,9 +1162,21 @@ public class CoordinatorRuntime<S extends CoordinatorShard<U>, U> implements Aut
* A collection of {@link DeferredEvent}. When completed, completes all the events in the collection * A collection of {@link DeferredEvent}. When completed, completes all the events in the collection
* and logs any exceptions thrown. * and logs any exceptions thrown.
*/ */
class DeferredEventCollection implements DeferredEvent { static class DeferredEventCollection implements DeferredEvent {
/**
* The logger.
*/
private final Logger log;
/**
* The list of events.
*/
private final List<DeferredEvent> events = new ArrayList<>(); private final List<DeferredEvent> events = new ArrayList<>();
public DeferredEventCollection(Logger log) {
this.log = log;
}
@Override @Override
public void complete(Throwable t) { public void complete(Throwable t) {
for (DeferredEvent event : events) { for (DeferredEvent event : events) {