Last active
May 3, 2019 13:13
-
-
Save zuston/2dbc699a207c4f65ecbca4f93206a132 to your computer and use it in GitHub Desktop.
Fix Oozie bug in CoordSubmitXCommand#validateCoordinatorJob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Method that validates values in the definition for correctness. Placeholder to add more. | |
*/ | |
private void validateCoordinatorJob() throws Exception { | |
// check if startTime < endTime | |
if (!coordJob.getStartTime().before(coordJob.getEndTime())) { | |
throw new IllegalArgumentException("Coordinator Start Time must be earlier than End Time."); | |
} | |
try { | |
// Check if a coord job with cron frequency will materialize actions | |
int freq = Integer.parseInt(coordJob.getFrequency()); | |
// Check if the frequency is faster than 5 min if enabled, | |
// but not validate the crontab formual | |
if (ConfigurationService.getBoolean(CONF_CHECK_MAX_FREQUENCY)) { | |
CoordinatorJob.Timeunit unit = coordJob.getTimeUnit(); | |
if (freq == 0 || (freq < 5 && unit == CoordinatorJob.Timeunit.MINUTE)) { | |
throw new IllegalArgumentException("Coordinator job with frequency [" + freq + | |
"] minutes is faster than allowed maximum of 5 minutes (" | |
+ CONF_CHECK_MAX_FREQUENCY + " is set to true)"); | |
} | |
} | |
} catch (NumberFormatException e) { | |
// the following is the crontab formual | |
// but not validate the EL frequency | |
Date start = coordJob.getStartTime(); | |
Calendar cal = Calendar.getInstance(); | |
cal.setTime(start); | |
cal.add(Calendar.MINUTE, -1); | |
start = cal.getTime(); | |
Date nextTime = CoordCommandUtils.getNextValidActionTimeForCronFrequency(start, coordJob); | |
if (nextTime == null) { | |
throw new IllegalArgumentException("Invalid coordinator cron frequency: " + coordJob.getFrequency()); | |
} | |
if (!nextTime.before(coordJob.getEndTime())) { | |
throw new IllegalArgumentException("Coordinator job with frequency '" + | |
coordJob.getFrequency() + "' materializes no actions between start and end time."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment