* @see org.apache.oozie.command.XCommand#verifyPrecondition()
*/
@Override
protected void verifyPrecondition() throws CommandException, PreconditionException {
if (!(coordJob.getStatus() == CoordinatorJobBean.Status.PREP || coordJob.getStatus() == CoordinatorJobBean.Status.RUNNING)) {
throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId=" + jobId
+ " job is not in PREP or RUNNING but in " + coordJob.getStatus());
}
if (coordJob.getNextMaterializedTimestamp() != null
&& coordJob.getNextMaterializedTimestamp().compareTo(coordJob.getEndTimestamp()) >= 0) {
throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId=" + jobId
+ " job is already materialized");
}
Timestamp startTime = coordJob.getNextMaterializedTimestamp();
if (startTime == null) {
startTime = coordJob.getStartTimestamp();
if (startTime.after(new Timestamp(System.currentTimeMillis() + LOOKAHEAD_WINDOW * 1000))) {
throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId="
+ jobId + " job's start time is not reached yet - nothing to materialize");
}
}
if (coordJob.getLastActionTime() != null && coordJob.getLastActionTime().compareTo(coordJob.getEndTime()) >= 0) {
throw new PreconditionException(ErrorCode.E1100, "ENDED Coordinator materialization for jobId = " + jobId
+ ", all actions have been materialized from start time = " + coordJob.getStartTime()
+ " to end time = " + coordJob.getEndTime() + ", job status = " + coordJob.getStatusStr());
}
if (coordJob.getLastActionTime() != null && coordJob.getLastActionTime().compareTo(endMatdTime) >= 0) {
throw new PreconditionException(ErrorCode.E1100, "ENDED Coordinator materialization for jobId = " + jobId
+ ", action is *already* materialized for Materialization start time = " + startMatdTime
+ ", materialization end time = " + endMatdTime + ", job status = " + coordJob.getStatusStr());
}
if (endMatdTime.after(coordJob.getEndTime())) {
throw new PreconditionException(ErrorCode.E1100, "ENDED Coordinator materialization for jobId = " + jobId
+ " materialization end time = " + endMatdTime + " surpasses coordinator job's end time = "
+ coordJob.getEndTime() + " job status = " + coordJob.getStatusStr());
}
if (coordJob.getPauseTime() != null && !startMatdTime.before(coordJob.getPauseTime())) {
throw new PreconditionException(ErrorCode.E1100, "ENDED Coordinator materialization for jobId = " + jobId
+ ", materialization start time = " + startMatdTime
+ " is after or equal to coordinator job's pause time = " + coordJob.getPauseTime()
+ ", job status = " + coordJob.getStatusStr());
}