-
Notifications
You must be signed in to change notification settings - Fork 498
[FLINK-33525] Move ImpulseSource to new Source API #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-33525] Move ImpulseSource to new Source API #950
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Poorvankbhatia thanks for the PR. Did you evaluate if this can be achieved based off of the existing DataGeneratorSource/GeneratorFunction? Generally, our approach should be to try to capture usage patterns that might also be required for generating synthetic data by Flink users and make them available by providing utilities in the generator package.
Yes, absolutely! However, using DataGeneratorSource requires adding a dependency on flink-connector-datagen in autoscaling's pom.xml. I wasn't sure if that was acceptable, so I replicated the original source instead. Let me know if i can add that dependency. |
I think it is fine - datagen's only major transitive dependency is on |
|
Since this is only an example we should focus on simplicity and add the extra dep to use the built in generator functionality. We should not add new dependencies to the autoscaler, only this example module |
Updated the code. Please have a look. Thanks. |
| * Flink's DataGeneratorSource with RateLimiterStrategy is used to control the emission rate. | ||
| * | ||
| * Rate Calculation: | ||
| * - samplingIntervalMs / 10 gives maxSleepTimeMs, which represents the interval between emissions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this section needs to be adjusted. Since we do not control the maxSleepTimeMs directly, but it is rather controlled internally by the Guava's token bucket algorithm, it should not be explicitly mentioned here. It is also not strictly guaranteed to be max - at the startup there can be a short burst. The value 10 seems to just be a hardcoded parameter meaning that we want at least 10 impulses per sampling interval. Basically it should rather explain: check how many sampling intervals are there within a second, make sure that 10 impulses are generated for each sampling interval (IMPULSES_PER_SAMPLING_INTERVAL).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the comment. Let me know if this makes sense.
| * - `samplingIntervalsPerSecond = 1000 / 2000 = 0.5` | ||
| * - `impulsesPerSecond = 10 * 0.5 = 5 records per second` | ||
| * | ||
| * This approach ensures that the number of records emitted dynamically scales |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds very AI-generated :) I the intention is clear without the last paragraph.
Also, one example should suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
| (index) -> 42L, // Emits constant value 42 | ||
| Long.MAX_VALUE, // Unbounded stream | ||
| RateLimiterStrategy.perSecond( | ||
| (double) 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More importantly, please actually adjust the calculation to align with the comments description
a/b/c -> (a/b)*c
c: 10 -> IMPULSES_PER_SAMPLING_INTERVAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected this.
| * Emission Rate Logic: | ||
| * - The goal is to generate a fixed number of impulses per sampling interval. | ||
| * - `samplingIntervalMs` defines the duration of one sampling interval in milliseconds. | ||
| * - We define `IMPULSES_PER_SAMPLING_INTERVAL = 10`, meaning that for every sampling interval, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: either introduce this constant and use it in the calculations or use plain text in the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the constant.
afedulov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks @Poorvankbhatia
What is the purpose of the change
This pull request migrates the ImpulseSource (used in LoadSimulationPipeline) to use Flink's DataGeneratorSource, replacing the older SourceFunction.
Brief change log
Verifying this change
This change is already covered by existing tests, such as:
Does this pull request potentially affect one of the following parts:
CustomResourceDescriptors: noDocumentation