You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/01/15 21:31:22 UTC
[GitHub] [kafka] ableegoldman commented on a change in pull request #9888: KAFKA-12194: use stateListener to catch each state change
ableegoldman commented on a change in pull request #9888:
URL: https://github.com/apache/kafka/pull/9888#discussion_r558603115
##########
File path: streams/src/test/java/org/apache/kafka/streams/integration/AdjustStreamThreadCountTest.java
##########
@@ -90,24 +91,61 @@ public void setup() {
);
}
+ private void startStreamsAndWaitForRunning(final KafkaStreams kafkaStreams) throws InterruptedException {
+ kafkaStreams.start();
+ waitForRunning();
+ }
+
@After
public void teardown() throws IOException {
+ stateTransitionHistory.clear();
purgeLocalStreamsState(properties);
}
+ private void addStreamStateChangeListener(final KafkaStreams kafkaStreams) {
+ // we store each new state in state transition so that we won't miss any state change
+ kafkaStreams.setStateListener(
+ (newState, oldState) -> stateTransitionHistory.add(newState)
+ );
+ }
+
+ private void waitForRunning() throws InterruptedException {
+ waitForCondition(
+ () -> !stateTransitionHistory.isEmpty() &&
+ stateTransitionHistory.get(stateTransitionHistory.size() - 1).equals(KafkaStreams.State.RUNNING),
+ DEFAULT_DURATION.toMillis(),
+ () -> String.format("Client did not transit to state %s in %d seconds",
+ KafkaStreams.State.RUNNING, DEFAULT_DURATION.toMillis() / 1000)
+ );
+ }
+
+ // verify if state change from "before" state into "after" state
Review comment:
Classic Bruno, can't sneak any inline comments past him :P
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org