@Override public void deleteOperationHistory(Subject subject, int historyId, boolean purgeInProgress) { OperationHistory doomedHistory = getOperationHistoryByHistoryId(subject, historyId); // this also checks authorization so we don't have to do it again ensureControlPermission(subject, doomedHistory); if ((doomedHistory.getStatus() == OperationRequestStatus.INPROGRESS) && !purgeInProgress) { throw new IllegalStateException( "The job is still in the in-progress state. Please wait for it to complete: " + doomedHistory.getId()); } if (doomedHistory instanceof GroupOperationHistory) { List<ResourceOperationHistory> resourceHistories = ((GroupOperationHistory) doomedHistory) .getResourceOperationHistories(); for (ResourceOperationHistory child : resourceHistories) { deleteOperationHistory_helper(child.getId()); } } deleteOperationHistory_helper(doomedHistory.getId()); }
public void operationTimedOut(String jobId, long invocationTime, long timeoutTime) { LOG.debug("Operation invocation [" + jobId + "] failed due to a timeout " + getFromStartToEndTimestampString(invocationTime, timeoutTime)); try { Subject superuser = LookupUtil.getSubjectManager().getOverlord(); OperationManagerLocal operationManager = LookupUtil.getOperationManager(); OperationHistory history = operationManager.getOperationHistoryByJobId(superuser, jobId); if (history.getStatus() == OperationRequestStatus.INPROGRESS) { history.setErrorMessage("Timed out"); history.setStatus(OperationRequestStatus.FAILURE); operationManager.updateOperationHistory(superuser, history); operationManager.checkForCompletedGroupOperation(history.getId()); } else { // if the operation was not in progress, the server side probably already timed it out LOG.warn("Was told to timeout an operation history but it was not in progress: " + "job-id=[" + jobId + "], op-history=[" + history + "]"); } } catch (Exception e) { LOG.error("Failed to update history from timed out operation, jobId=[" + jobId + "]. Cause: " + e, e); } }