muralibasani commented on code in PR #23738:
URL: https://github.com/apache/kafka/pull/23738#discussion_r4234223739
##########
streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/HeadersStoreUpgradeIntegrationTest.java:
##########
@@ -128,16 +152,43 @@ private Properties props() {
private void buildAndStart(final StoreBuilder<?> storeBuilder,
final ProcessorSupplier<String, String, Void,
Void> processorSupplier,
- final String storeName,
- final Properties props) throws Exception {
+ final String storeName) throws Exception {
final StreamsBuilder builder = new StreamsBuilder();
builder.addStateStore(storeBuilder)
.stream(inputStream, Consumed.with(Serdes.String(),
Serdes.String()))
.process(processorSupplier, storeName);
- kafkaStreams = new KafkaStreams(builder.build(), props);
+ kafkaStreams = new KafkaStreams(builder.build(), streamsConfig);
IntegrationTestUtils.startApplicationAndWaitUntilRunning(kafkaStreams);
}
+ /**
+ * Stops the running instance (leaving the group) and starts a new one
over the same state
+ * directory with the given store and processor — the upgrade step every
migration/proxy test
+ * performs between writing legacy data and reading it back through the
new store type.
+ */
+ private void restart(final StoreBuilder<?> storeBuilder,
+ final ProcessorSupplier<String, String, Void, Void>
processorSupplier,
+ final String storeName) throws Exception {
+ closeAndLeaveGroupBeforeRestart();
+ kafkaStreams = null;
+ buildAndStart(storeBuilder, processorSupplier, storeName);
+ }
+
+ /**
+ * Deletes the local state of the (already closed) instance, so the next
start has to rebuild
+ * its stores from the changelog — the supported way to downgrade from a
headers-aware store.
+ */
+ private void wipeLocalState() {
+ kafkaStreams.cleanUp();
+ kafkaStreams = null;
+ }
+
+ private void closeAndLeaveGroupBeforeRestart() {
+ // Leave the group so the immediate restart with the same application
id
+ // does not wait for the previous member's session timeout.
+
kafkaStreams.close(CloseOptions.groupMembershipOperation(GroupMembershipOperation.LEAVE_GROUP));
Review Comment:
Good one. closeAndLeaveGroupBeforeRestart() now calls
.withTimeout(CLOSE_TIMEOUT), so every close is limited to 30s.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]