mirror of https://github.com/apache/kafka.git
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:
parent
ccf2510fdd
commit
1eea7f0528
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue