}
invokeOperationOnResource(composite, operationManager);
int resourceHistoryId = composite.history.getId();
OperationHistory updatedOperationHistory = null;
long sleep = 1000L; // quick sleep for fast ops, then slow down
long maxSleep = 5000L;
do {
Thread.sleep(sleep);
sleep = (sleep == maxSleep) ? sleep : sleep + 1000L;
// it's unlikely but possible that a client program could actually query for, process, and
// delete the history before this code gets a chance to run. If the record is gone just
// assume things were handled externally.
try {
updatedOperationHistory = operationManager.getOperationHistoryByHistoryId(
getUserWithSession(user, true), resourceHistoryId);
} catch (IllegalArgumentException e) {
if (log.isDebugEnabled()) {
log.debug("Failed to find operation history", e);
}
break;
}
// if the duration was ridiculously long, let's break out of here. this will rarely
// be triggered because our operation manager will timeout long running operations for us
// (based on the operation's define timeout). But, me being paranoid, I want to be able
// to break this infinite loop if for some reason the operation manager isn't doing its job.
// if the operation took longer than 24 hours, this breaks the loop.
if (updatedOperationHistory.getDuration() > (GroupOperationJob.BREAK_VALUE)) {
break;
}
} while (updatedOperationHistory.getStatus() == OperationRequestStatus.INPROGRESS);
// halt the rest if we got a failure and were told not to go on
if (null != updatedOperationHistory
&& (updatedOperationHistory.getStatus() != OperationRequestStatus.SUCCESS)
&& schedule.isHaltOnFailure()) {
hadFailure = true;
}
} catch (Exception e) {
// failed to even send to the agent, immediately mark the job as failed