*/
@Override
protected void verifyPrecondition() throws CommandException, PreconditionException {
if (!(coordJob.getStatus() == CoordinatorJobBean.Status.PREP || coordJob.getStatus() == CoordinatorJobBean.Status.RUNNING
|| coordJob.getStatus() == CoordinatorJobBean.Status.RUNNINGWITHERROR)) {
throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId=" + jobId
+ " job is not in PREP or RUNNING but in " + coordJob.getStatus());
}
if (coordJob.isDoneMaterialization()) {
throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId =" + jobId
+ " job is already materialized");
}
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() + lookAheadWindow * 1000))) {
throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId="
+ jobId + " job's start time is not reached yet - nothing to materialize");
}
}
if (coordJob.getNextMaterializedTimestamp() != null
&& coordJob.getNextMaterializedTimestamp().after(
new Timestamp(System.currentTimeMillis() + lookAheadWindow * 1000))) {
throw new PreconditionException(ErrorCode.E1100, "CoordMaterializeTransitionXCommand for jobId=" + jobId
+ " Request is for future time. Lookup time is "
+ new Timestamp(System.currentTimeMillis() + lookAheadWindow * 1000) + " mat time is "
+ coordJob.getNextMaterializedTimestamp());
}
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());
}