private String getDetailsURL(ResourceOperationHistory history) { String protocol; if (request.isSecure()) { protocol = "https"; } else { protocol = "http"; } return protocol + "://" + request.getServerName() + ":" + request.getServerPort() + "/coregui/#Resource/" + history.getResource().getId() + "/Operations/History/" + history.getId(); }
opsManager.deleteOperationHistory(caller,history.getId(),false);
public void operationSucceeded(String jobId, Configuration result, long invocationTime, long completionTime) { LOG.debug("Operation invocation [" + jobId + "] succeeded " + getFromStartToEndTimestampString(invocationTime, completionTime)); try { Subject superuser = LookupUtil.getSubjectManager().getOverlord(); OperationManagerLocal operationManager = LookupUtil.getOperationManager(); ResourceOperationHistory history; history = (ResourceOperationHistory) operationManager.getOperationHistoryByJobId(superuser, jobId); // I think this will only ever occur if the server-side timed this out but the long running // operation finally got back to us afterwards. We will still go ahead and // persist the success data because, obviously, the operation really didn't time out. // I think, in reality, this condition will never occur (since the server-side will only ever // timeout ridiculously long-lived operations, which is typically only when an agent shutdown occurred). if (history.getStatus() != OperationRequestStatus.INPROGRESS) { LOG.debug("Was told an operation succeeded but, curiously, it was not in progress: " + "job-id=[" + jobId + "], op-history=[" + history + "]"); } history.setErrorMessage(null); history.setResults(result); history.setStatus(OperationRequestStatus.SUCCESS); operationManager.updateOperationHistory(superuser, history); operationManager.checkForCompletedGroupOperation(history.getId()); } catch (Exception e) { LOG.error("Failed to update history from successful operation, jobId=[" + jobId + "]. Cause: " + e, e); LOG.error("The successful operation [" + jobId + "] had results of: " + result); } }
@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()); }
operationManager.checkForCompletedGroupOperation(history.getId()); } catch (Exception e) { LOG.error("Failed to update history from canceled operation, jobId=[" + jobId + "]. Cause: " + e, e);
operationManager.checkForCompletedGroupOperation(history.getId()); } catch (Exception e) { LOG.error("Failed to update history from failed operation, jobId=[" + jobId + "]. Cause: " + e, e);
operationManager.deleteOperationHistory(subject, iter.next().getId(), true);
List<ResourceOperationHistory> attached = new ArrayList<ResourceOperationHistory>(roh.size()); for (ResourceOperationHistory unattachedHistory : roh) { attached.add(entityManager.getReference(ResourceOperationHistory.class, unattachedHistory.getId()));
protected ResourceOperationHistory createOperationHistory(String jobName, String jobGroup, ResourceOperationSchedule schedule, GroupOperationHistory groupHistory, OperationManagerLocal operationManager) { // we need the operation definition to fill in the history item OperationDefinition op; op = operationManager.getSupportedResourceOperation(schedule.getSubject(), schedule.getResource().getId(), schedule.getOperationName(), false); // first we need to create an INPROGRESS history item Configuration parameters = schedule.getParameters(); if (parameters != null) { parameters = parameters.deepCopy(false); // we need a copy to avoid constraint violations upon delete } ResourceOperationHistory history; history = new ResourceOperationHistory(jobName, jobGroup, schedule.getSubject().getName(), op, parameters, schedule.getResource(), groupHistory); // persist the results of the initial create ResourceOperationHistory persisted; persisted = (ResourceOperationHistory) operationManager.updateOperationHistory(schedule.getSubject(), history); history.setId(persisted.getId()); // we need this - this enables the server to successfully update the group history later return persisted; }
int resourceHistoryId = composite.history.getId(); OperationHistory updatedOperationHistory = null; long sleep = 1000L; // quick sleep for fast ops, then slow down
operationManager.checkForCompletedGroupOperation(resourceHistory.getId()); throw e;