* @throws Exception if exception occurred
*/
protected JobStatus waitStatus(Job job, long timeout, TimeUnit unit, JobStatus... jobStatuses) throws Exception {
Assert.notNull(job, "Hadoop job must be set");
JobStatus status = null;
long end = System.currentTimeMillis() + unit.toMillis(timeout);
// break label for inner loop
done: do {
status = findStatus(job);
if (status == null) {
break;
}
for (JobStatus statusCheck : jobStatuses) {
if (status.equals(statusCheck)) {
break done;
}
}
Thread.sleep(1000);
} while (System.currentTimeMillis() < end);