1616
1717package org .radarcns .stream ;
1818
19+ import static org .radarcns .stream .GeneralStreamGroup .CommitInterval .COMMIT_INTERVAL_DEFAULT ;
1920import static org .radarcns .util .Comparison .compare ;
2021
2122import java .util .Objects ;
2425import org .apache .kafka .streams .kstream .TimeWindows ;
2526import org .radarcns .topic .KafkaTopic ;
2627
28+
2729public class StreamDefinition implements Comparable <StreamDefinition > {
2830 private final KafkaTopic inputTopic ;
2931 private final KafkaTopic outputTopic ;
3032 private final TimeWindows window ;
33+ private final long commitIntervalMs ;
3134
3235 /**
3336 * Constructor. It takes in input the topic name to be consumed and to topic name where the
@@ -36,7 +39,7 @@ public class StreamDefinition implements Comparable<StreamDefinition> {
3639 * @param output output {@link KafkaTopic}
3740 */
3841 public StreamDefinition (@ Nonnull KafkaTopic input , @ Nonnull KafkaTopic output ) {
39- this (input , output , 0L );
42+ this (input , output , 0L , COMMIT_INTERVAL_DEFAULT . getCommitInterval () );
4043 }
4144
4245 /**
@@ -47,24 +50,41 @@ public StreamDefinition(@Nonnull KafkaTopic input, @Nonnull KafkaTopic output) {
4750 * @param window time window for aggregation.
4851 */
4952 public StreamDefinition (@ Nonnull KafkaTopic input , @ Nonnull KafkaTopic output , long window ) {
50- this (input , output , window == 0 ? null : TimeWindows .of (window ));
53+ this (input , output , window == 0 ? null : TimeWindows .of (window ),
54+ COMMIT_INTERVAL_DEFAULT .getCommitInterval ());
55+ }
56+
57+ /**
58+ * Constructor. It takes in input the topic name to be consumed and to topic name where the
59+ * related stream will write the computed values.
60+ * @param input source {@link KafkaTopic}
61+ * @param output output {@link KafkaTopic}
62+ * @param window time window for aggregation.
63+ * @param commitIntervalMs The commit.interval.ms config for the stream
64+ */
65+ public StreamDefinition (@ Nonnull KafkaTopic input , @ Nonnull KafkaTopic output , long window ,
66+ long commitIntervalMs ) {
67+ this (input , output , window == 0 ? null : TimeWindows .of (window ), commitIntervalMs );
5168 }
5269
70+
5371 /**
5472 * Constructor. It takes in input the topic name to be consumed and to topic name where the
5573 * related stream will write the computed values.
5674 * @param input source {@link KafkaTopic}
5775 * @param output output {@link KafkaTopic}
5876 * @param window time window for aggregation.
77+ * @param commitIntervalMs The commit.interval.ms config for the stream
5978 */
6079 public StreamDefinition (@ Nonnull KafkaTopic input , @ Nonnull KafkaTopic output ,
61- @ Nullable TimeWindows window ) {
80+ @ Nullable TimeWindows window , @ Nonnull long commitIntervalMs ) {
6281 Objects .requireNonNull (input );
6382 Objects .requireNonNull (output );
6483
6584 this .inputTopic = input ;
6685 this .outputTopic = output ;
6786 this .window = window ;
87+ this .commitIntervalMs = commitIntervalMs ;
6888 }
6989
7090 @ Nonnull
@@ -94,6 +114,11 @@ public TimeWindows getTimeWindows() {
94114 return window ;
95115 }
96116
117+ @ Nullable
118+ public long getCommitIntervalMs (){
119+ return commitIntervalMs ;
120+ }
121+
97122 @ Override
98123 public boolean equals (Object o ) {
99124 if (this == o ) {
0 commit comments