Hi, CheckpointedFunction is needed to trigger and complete the checkpoint, is it right?
What is the work for the code in here [1]? it [1] said to enable checkpointing or some other function. What is the difference between [1] and [2]? If we use ExampleCountSource[2] example, what will be the import portion at the beginning of code and the pom.xml? [1] https://ci.apache.org/projects/flink/flink-docs-stable/dev/stream/state/checkpointing.html#java [2] https://ci.apache.org/projects/flink/flink-docs-release-1.12/api/java/org/apache/flink/streaming/api/functions/source/SourceFunction.html Thank you for your service! On Tue, Mar 9, 2021 at 6:21 AM Smile <letters_sm...@163.com> wrote: > Hi, > > After implementing SourceFunction, you can use it to create a DataStream > using env.addSource() in your main method. > For example, if you have your custom source class with the name > CustomSource > that implements SourceFunction<String>, then it can be used for getting > input data and the if-statement after it can be removed: > > // get input data > DataStream<String> text = env.addSource(new CustomSource()); > > > ExampleCountSource in [1] implements SourceFunction<Long>, which can be > used > to get a DataStream with type Long, not String, such as: > > DataStream<Long> numbers = env.addSource(new ExampleCountSource()); > > > If you only want to have a look at how checkpoint being triggered, see [2] > for another sample that has a custom endless source named > TransactionSource. > When enabled checkpoint it can be triggered with your rules. It might be > easier for a beginner than implement it by yourself. > However, it may not restore from a checkpoint perfectly since it doesn't > implement CheckpointedFunction. That is to say, if you want your source to > be restored successfully after failures, CheckpointedFunction is also > necessary and ExampleCountSource in [1] is a good example. > > > [1]. > > https://ci.apache.org/projects/flink/flink-docs-release-1.12/api/java/org/apache/flink/streaming/api/functions/source/SourceFunction.html > [2]. > > https://ci.apache.org/projects/flink/flink-docs-release-1.12/try-flink/datastream_api.html > > Regards, > Smile > > > > > -- > Sent from: > http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/ >