queue(new CoordActionInputCheckXCommand(coordAction.getId(), coordAction.getJobId()), Math.max((nominalTime.getTime() - currentTime
.getTime()), getCoordInputCheckRequeueInterval()));
// update lastModifiedTime
coordAction.setLastModifiedTime(new Date());
try {
jpaService.execute(new CoordActionUpdateForInputCheckJPAExecutor(coordAction));
}
catch (JPAExecutorException e) {
throw new CommandException(e);
}
LOG.info("[" + actionId
+ "]::ActionInputCheck:: nominal Time is newer than current time, so requeue and wait. Current="
+ currentTime + ", nominal=" + nominalTime);
return null;
}
StringBuilder actionXml = new StringBuilder(coordAction.getActionXml());
Instrumentation.Cron cron = new Instrumentation.Cron();
boolean isChangeInDependency = false;
try {
Configuration actionConf = new XConfiguration(new StringReader(coordAction.getRunConf()));
cron.start();
StringBuilder existList = new StringBuilder();
StringBuilder nonExistList = new StringBuilder();
StringBuilder nonResolvedList = new StringBuilder();
String firstMissingDependency = "";
String missingDeps = coordAction.getMissingDependencies();
CoordCommandUtils.getResolvedList(missingDeps, nonExistList, nonResolvedList);
// For clarity regarding which is the missing dependency in synchronous order
// instead of printing entire list, some of which, may be available
if(nonExistList.length() > 0) {
firstMissingDependency = nonExistList.toString().split(CoordELFunctions.INSTANCE_SEPARATOR)[0];
}
LOG.info("[" + actionId + "]::CoordActionInputCheck:: Missing deps:" + firstMissingDependency + " "
+ nonResolvedList.toString());
// Updating the list of data dependencies that are available and those that are yet not
boolean status = checkInput(actionXml, existList, nonExistList, actionConf);
coordAction.setLastModifiedTime(currentTime);
coordAction.setActionXml(actionXml.toString());
if (nonResolvedList.length() > 0 && status == false) {
nonExistList.append(CoordCommandUtils.RESOLVED_UNRESOLVED_SEPARATOR).append(nonResolvedList);
}
String nonExistListStr = nonExistList.toString();
if (!nonExistListStr.equals(missingDeps) || missingDeps.isEmpty()) {
// missingDeps empty means action should become READY
isChangeInDependency = true;
coordAction.setMissingDependencies(nonExistListStr);
}
if (status == true) {
coordAction.setStatus(CoordinatorAction.Status.READY);
// pass jobID to the CoordActionReadyXCommand
queue(new CoordActionReadyXCommand(coordAction.getJobId()), 100);
}
else {
long waitingTime = (currentTime.getTime() - Math.max(coordAction.getNominalTime().getTime(), coordAction
.getCreatedTime().getTime()))
/ (60 * 1000);
int timeOut = coordAction.getTimeOut();
if ((timeOut >= 0) && (waitingTime > timeOut)) {
queue(new CoordActionTimeOutXCommand(coordAction), 100);
}
else {
queue(new CoordActionInputCheckXCommand(coordAction.getId(), coordAction.getJobId()), getCoordInputCheckRequeueInterval());
}
}
}
catch (Exception e) {
throw new CommandException(ErrorCode.E1021, e.getMessage(), e);
}
finally {
coordAction.setLastModifiedTime(new Date());
cron.stop();
if(jpaService != null) {
try {
if (isChangeInDependency) {
jpaService.execute(new CoordActionUpdateForInputCheckJPAExecutor(coordAction));
}
else {
jpaService.execute(new CoordActionUpdateForModifiedTimeJPAExecutor(coordAction));
}
}