Skip to content
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

Cron Support for CDC #59

Merged
merged 4 commits into from
Jun 17, 2020
Merged

Cron Support for CDC #59

merged 4 commits into from
Jun 17, 2020

Conversation

Ajanthy
Copy link
Contributor

@Ajanthy Ajanthy commented May 18, 2020

Purpose

Cron Support for CDC

Security checks

Related Issues

wso2/streaming-integrator#115
#58

@@ -585,6 +585,7 @@
io.siddhi.query.*;version="${siddhi.import.version.range}",
*;resolution:=optional
</Import-Package>
<DynamicImport-Package>*</DynamicImport-Package>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using dynamic imports. Add the necessary packages in the import-packages section

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in ee838f8

),
@Parameter(
name = "cron.expression",
description = "This is used to specify a timestamp in cron expression. " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the description is wrong. Please check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in ee838f8

// Tell quartz to schedule the job using our trigger
scheduler.scheduleJob(cron, trigger);
} catch (SchedulerException e) {
log.error("The error occurs at scheduler start in SiddhiApp : " + e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we change this as "An error occurred when scheduling job in siddhi app for cdc polling"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in ee838f8

@@ -185,6 +190,9 @@ public void resume() {
public void run() {
try {
pollingStrategy.poll();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this come in the else part? In this scenario, whenever the cdc source starts running, a poll() happens right. Please confirm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poll() is called to set the lastReadPollingColumnValue. If the poll() is called in the scheduleJob() then records which has been inserted between the time app starts running and the first cronschedule will be missed. To ignore this issue the lastReadPollingColumnValue has to be stored. So it shouldn't come in the else part.

}
} catch (SQLException ex) {
throw new CDCPollingModeException(buildError("Error in polling for changes on %s.", tableName), ex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to log the error without throwing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed the same approach.

} finally {
CDCPollingUtil.cleanupConnection(resultSet, statement, connection);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should close connection and statement after using. And re-initialize when using again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Connection and statement are closed at the end of the method.


// Constants for Cron Support
public static final String CRON_EXPRESSION = "cron.expression";
public static final String JOB_GROUP = "JobGroup";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add some meaningful names if those are getting printed when debugging or on errors?? Eg: CDCPollingGroup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in ee838f8

@@ -92,7 +97,7 @@ public CDCPoller(String url, String username, String password, String tableName,
} else {
log.debug(DefaultPollingStrategy.class + " is selected as the polling strategy.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we validate and throw app creation error if cron and some other strategy is selected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in ee838f8

@AnuGayan AnuGayan merged commit aa93861 into siddhi-io:master Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants