-
Notifications
You must be signed in to change notification settings - Fork 74
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
[HWKMETRICS-800] Validate when scheduled jobs has null values #1006
Conversation
234f098
to
db6a366
Compare
return session.execute(insertScheduled.bind(timeSlice, job.getJobId(), job.getJobType(), job.getJobName(), | ||
job.getParameters().getMap(), getTriggerValue(session, job.getTrigger()))); | ||
} | ||
|
||
public Observable<ResultSet> updateStatusToFinished(Date timeSlice, UUID jobId) { | ||
return session.execute(updateStatus.bind((byte) 1, timeSlice, jobId)) | ||
// First check if the job exists | ||
return session.executeAndFetch(findByIdAndSlice.bind(timeSlice, jobId)).flatMap( |
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 would consider adding some logging in here. The expectation is that there will be a row for timeSlice
and jobId
. At a minimum, I would log a warning that the row does not exist. Then the question is, what if anything else should be done?
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 think for now just logging and then ignore it and of course, don't try to do the upsert operation.
f997992
to
5469633
Compare
"slice [%s]", jobId, timeSlice.getTime())); | ||
// First check if the job exists | ||
return session.executeAndFetch(findByIdAndSlice.bind(timeSlice, jobId)) | ||
.isEmpty() |
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 don't have too much experience on javarx, not sure if this is a good way to do the things.
@jsanda I've already updated the PR with all comments we talked about. Thanks for taking the time to review this! |
@@ -195,14 +213,28 @@ public Completable deleteJob(UUID jobId, rx.Scheduler scheduler) { | |||
} | |||
|
|||
public Observable<ResultSet> insert(Date timeSlice, JobDetails job) { | |||
if (job.getJobId() == null || job.getJobName() == null || job.getJobType() == null || job.getTrigger() == null) { | |||
logger.warn("Tried to insert job on scheduled jobs with invalid values"); |
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 would include timeSlice
and job
in the log statement to provide as much info as possible.
// Fields that shouldn't be null: time_slice, job_id, job_type, job_name, trigger | ||
private Func1<Row, Boolean> filterAllScheduledQuery = row -> !(row.isNull(0) || row.isNull(1) | ||
|| row.isNull(2) || row.isNull(3) || row.isNull(5)); | ||
|
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.
The functions look good. I'll mention one thing to consider. The filters should help avoid the NPEs but will do so silently. You could add some additional logging at the expense of making the filter functions a bit more verbose, e.g.,
private Func1<Row, Boolean> filterAllScheduledQuery = row -> {
boolean isNull = !(row.isNull(0) || row.isNull(1) || row.isNull(2) || row.isNull(3) || row.isNull(5));
if (isNull) {
// log column names/values...
}
return isNull;
}
d7dd726
to
4da57f1
Compare
4da57f1
to
4dd4142
Compare
I've already addressed all comments, is ready for other review and merge. |
Fixes https://issues.jboss.org/projects/HWKMETRICS/issues/HWKMETRICS-800