use of org.apache.oozie.executor.jpa.CoordJobGetActionForNominalTimeJPAExecutor in project oozie by apache.
the class CoordUtils method getCoordActionsFromDates.
/**
* Get the list of actions for given date ranges
*
* @param jobId coordinator job id
* @param scope a comma-separated list of date ranges. Each date range element is specified with two dates separated by '::'
* @return the list of Coordinator actions for the date range
* @throws CommandException thrown if failed to get coordinator actions by given date range
*/
@VisibleForTesting
public static List<CoordinatorActionBean> getCoordActionsFromDates(String jobId, String scope, boolean active) throws CommandException {
JPAService jpaService = Services.get().get(JPAService.class);
ParamChecker.notEmpty(jobId, "jobId");
ParamChecker.notEmpty(scope, "scope");
Set<CoordinatorActionBean> actionSet = new LinkedHashSet<CoordinatorActionBean>();
String[] list = scope.split(",");
for (String s : list) {
s = s.trim();
// A date range is specified with two dates separated by '::'
if (s.contains("::")) {
List<CoordinatorActionBean> listOfActions;
try {
// Get list of actions within the range of date
listOfActions = CoordActionsInDateRange.getCoordActionsFromDateRange(jobId, s, active);
} catch (XException e) {
throw new CommandException(e);
}
actionSet.addAll(listOfActions);
} else {
try {
// Get action for the nominal time
Date date = DateUtils.parseDateOozieTZ(s.trim());
CoordinatorActionBean coordAction = jpaService.execute(new CoordJobGetActionForNominalTimeJPAExecutor(jobId, date));
if (coordAction != null) {
actionSet.add(coordAction);
} else {
throw new RuntimeException("This should never happen, Coordinator Action shouldn't be null");
}
} catch (ParseException e) {
throw new CommandException(ErrorCode.E0302, s.trim(), e);
} catch (JPAExecutorException e) {
if (e.getErrorCode() == ErrorCode.E0605) {
XLog.getLog(CoordUtils.class).info("No action for nominal time:" + s + ". Skipping over");
}
throw new CommandException(e);
}
}
}
List<CoordinatorActionBean> coordActions = new ArrayList<CoordinatorActionBean>();
for (CoordinatorActionBean coordAction : actionSet) {
coordActions.add(coordAction);
}
return coordActions;
}
Aggregations