trying to understand how to use the reset tool for kafka stream application. However i am confused by the explanation.
It is said that there are 2 stage to it, local rest (cleanup), followed by the global reset which is using the reset-tool.
The following example is provided in confluent:
https://docs.confluent.io/current/streams/developer-guide/app-reset-tool.html#step-2-reset-the-local-environments-of-your-application-instances
package io.confluent.examples.streams;
import ...;
public class ResetDemo {
public static void main(String[] args) throws Exception {
// Kafka Streams configuration
Properties props = new Properties();
props.put(StreamsConfig.APPLICATION_ID_CONFIG, "my-streams-app");
// ...and so on...
// Define the processing topology
StreamsBuilder builder = new StreamsBuilder();
builder.stream("my-input-topic")
.selectKey(...)
.through("rekeyed-topic")
.groupByKey()
.count("global-count")
.to("my-output-topic");
KafkaStreams app = new KafkaStreams(builder.build(), props);
// Delete the application's local state.
// Note: In real application you'd call `cleanUp()` only under
// certain conditions. See tip on `cleanUp()` below.
app.cleanUp();
app.start();
// Note: In real applications you would register a shutdown hook
// that would trigger the call to `app.close()` rather than
// using the sleep-then-close example we show here.
Thread.sleep(30 * 1000L);
app.close();
}
}
followed by the following example:
Tip: To avoid the corresponding recovery overhead, you should not call cleanUp() unconditionally and every time an application instance is restarted or resumed. For exammple, in a production application you could use command line arguments to enable or disable the cleanUp() call on an as-needed basis.
You can then perform run-reset-modify cycles as follows:
# Run your application
bin/kafka-run-class io.confluent.examples.streams.ResetDemo
# After stopping all application instances, reset the application
bin/kafka-streams-application-reset --application-id my-streams-app \
--input-topics my-input-topic \
--intermediate-topics rekeyed-topic
# Now you can modify/recompile as needed and then re-run the application again.
# You can also experiment, for example, with different input data without
# modifying the application.
I do not understand it.
- Does app.cleanUp () require app.start() to be executed ?
- Why having a app.cleanUp () followed by an app.start(), in what circumstances would that be useful ?
- Why not just having a flag that say if it is cleanUp then just run app.cleanUp(), and it is not run app.start();
I simply do not understand the last part of the example
run your app then apply the reset tool. but if the app look like in the example, then after the cleanUp, the app will run and we will have local data. So stopping will not help the rest-tool.
It is very confusing. Can someone who understand it explain please ?