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

[HWKMETRICS-800] Validate when scheduled jobs has null values #1006

Merged
merged 1 commit into from
Dec 17, 2018

Conversation

rubenvp8510
Copy link
Contributor

@rubenvp8510 rubenvp8510 commented Dec 5, 2018

@rubenvp8510 rubenvp8510 force-pushed the NPEScheduler branch 3 times, most recently from 234f098 to db6a366 Compare December 7, 2018 22:28
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(
Copy link
Contributor

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?

Copy link
Contributor Author

@rubenvp8510 rubenvp8510 Dec 11, 2018

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.

"slice [%s]", jobId, timeSlice.getTime()));
// First check if the job exists
return session.executeAndFetch(findByIdAndSlice.bind(timeSlice, jobId))
.isEmpty()
Copy link
Contributor Author

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.

@rubenvp8510
Copy link
Contributor Author

@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");
Copy link
Contributor

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));

Copy link
Contributor

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;
}

@rubenvp8510 rubenvp8510 force-pushed the NPEScheduler branch 2 times, most recently from d7dd726 to 4da57f1 Compare December 13, 2018 23:50
@rubenvp8510 rubenvp8510 changed the title [WIP] Validate when scheduled jobs has null values Validate when scheduled jobs has null values Dec 13, 2018
@rubenvp8510
Copy link
Contributor Author

I've already addressed all comments, is ready for other review and merge.

@rubenvp8510 rubenvp8510 merged commit 9106d33 into hawkular:master Dec 17, 2018
@rubenvp8510 rubenvp8510 changed the title Validate when scheduled jobs has null values [HWKMETRICS-800] Validate when scheduled jobs has null values Dec 17, 2018
rubenvp8510 added a commit to rubenvp8510/hawkular-metrics that referenced this pull request Dec 17, 2018
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.

2 participants