if (history.getStatus()==null) { status = " - no information yet -"; status = history.getStatus().getDisplayName(); if (history.getResource()!=null) { hist.setResourceName(history.getResource().getName()); hist.setOperationName(history.getOperationDefinition().getName()); hist.lastModified(history.getModifiedTime()); if (history.getErrorMessage()!=null) { hist.setErrorMessage(history.getErrorMessage()); if (history.getResults()!=null) { Configuration results = history.getResults(); for (Property p : results.getProperties()) { String val; String jobName = history.getJobName(); String jobGroup = history.getJobGroup(); JobId jobId = new JobId(jobName, jobGroup); hist.setJobId(jobId.toString());
List<ResourceOperationHistory> histories = query.getResultList(); for (ResourceOperationHistory history : histories) { long timeout = getOperationTimeout(history.getOperationDefinition(), history.getParameters()); long duration = history.getDuration(); long createdTime = history.getCreatedTime(); boolean timedOut = (duration > timeout); boolean neverStarted = ((System.currentTimeMillis() - createdTime) > (1000 * 60 * 60 * 24)); history.setErrorMessage("Timed out : did not complete after " + duration + " ms" + " (the timeout period was " + timeout + " ms)"); } else { history.setErrorMessage("Failed to start : operation never started"); history.setStatus(OperationRequestStatus.FAILURE); notifyAlertConditionCacheManager("checkForTimedOutOperations", history); checkForCompletedGroupOperation(history.getId()); if (resourceHistory.getStatus() == OperationRequestStatus.INPROGRESS) { cancelOperationHistory(subject, resourceHistory.getId(), true); if (resourceHistory.getStatus() != OperationRequestStatus.SUCCESS) {
GroupOperationHistory groupHistory = ((ResourceOperationHistory) history).getGroupOperationHistory(); if (resourceHistory.getStatus() == OperationRequestStatus.INPROGRESS) { stillInProgress = true; break; } else if ((resourceHistory.getStatus() == OperationRequestStatus.FAILURE) || (resourceHistory.getStatus() == OperationRequestStatus.CANCELED)) { groupStatus = OperationRequestStatus.FAILURE; if (groupErrorMessage == null) { Resource resource = resourceHistory.getResource(); String name = resource.getName(); Map<Integer, String> ancestryMap = resourceManager ResourceAncestryFormat.SIMPLE); String ancestry = ancestryMap.isEmpty() ? "" : ancestryMap.get(resource.getId()); groupErrorMessage.append(name + " [" + ancestry + "] " + resourceHistory.getStatus().name());
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(); }
private void operationCanceled(StorageNode storageNode, ResourceOperationHistory operationHistory, String opType) { log.error(opType + " has been aborted due to canceled operation [" + operationHistory.getOperationDefinition().getDisplayName() + " on " + storageNode.getResource() + ": " + operationHistory.getErrorMessage()); storageNode.setErrorMessage(opType + " has been aborted due to canceled resource operation [" + operationHistory.getOperationDefinition().getDisplayName() + "]."); storageNode.setFailedOperation(operationHistory); }
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 @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void handleAddNodeMaintenance(ResourceOperationHistory resourceOperationHistory) { StorageNode storageNode = findStorageNode(resourceOperationHistory.getResource()); Configuration parameters = resourceOperationHistory.getParameters(); String newNodeAddress = parameters.getSimpleValue("newNodeAddress"); StorageNode newStorageNode; switch (resourceOperationHistory.getStatus()) { case INPROGRESS:
@Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void handleUninstall(ResourceOperationHistory operationHistory) { StorageNode storageNode = findStorageNode(operationHistory.getResource()); switch (operationHistory.getStatus()) { case INPROGRESS: // nothing to do here break; case CANCELED: undeploymentOperationCanceled(storageNode, operationHistory); break; case FAILURE: undeploymentOperationFailed(storageNode, operationHistory); break; default: // SUCCESS log.info("Successfully uninstalled " + storageNode + " from disk"); finishUninstall(getSubject(operationHistory), storageNode); } }
public AlertConditionCacheStats checkConditions(OperationHistory operationHistory) { AlertConditionCacheStats stats = new AlertConditionCacheStats(); try { if (operationHistory instanceof ResourceOperationHistory) { ResourceOperationHistory resourceOperationHistory = (ResourceOperationHistory) operationHistory; Resource resource = resourceOperationHistory.getResource(); OperationDefinition operationDefinition = resourceOperationHistory.getOperationDefinition(); OperationRequestStatus operationStatus = resourceOperationHistory.getStatus(); List<ResourceOperationCacheElement> cacheElements = lookupResourceOperationHistoryCacheElements( resource.getId(), operationDefinition.getId()); processCacheElements(cacheElements, operationStatus, resourceOperationHistory.getModifiedTime(), stats); } else { if (log.isDebugEnabled()) log.debug(getClass().getSimpleName() + " does not support checking conditions against " + operationHistory.getClass().getSimpleName() + " types"); } AlertConditionCacheMonitor.getMBean().incrementOperationCacheElementMatches(stats.matched); AlertConditionCacheMonitor.getMBean().incrementOperationProcessingTime(stats.getAge()); if (log.isDebugEnabled()) log.debug("Check OperationHistory[size=1] - " + stats); } catch (Throwable t) { // don't let any exceptions bubble up to the calling SLSB layer log.error("Error during global cache processing: ", t); } return stats; }
if (doomedHistory.getStatus() != OperationRequestStatus.INPROGRESS) { throw new IllegalStateException("The job is no longer in-progress - cannot cancel it: " + doomedHistory); String jobIdString = doomedHistory.getJobId().toString(); int resourceId = doomedHistory.getResource().getId(); CancelResults results = null; AgentClient agent = null; doomedHistory.setStatus(OperationRequestStatus.CANCELED); // we expect doomedHistory to be jpa attached notifyAlertConditionCacheManager("cancelResourceOperation", doomedHistory);
((ResourceOperationHistory) existingHistoryItem).setResults(((ResourceOperationHistory) history) .getResults()); List<ResourceOperationHistory> attached = new ArrayList<ResourceOperationHistory>(roh.size()); for (ResourceOperationHistory unattachedHistory : roh) { attached.add(entityManager.getReference(ResourceOperationHistory.class, unattachedHistory.getId()));
schedule.setSubject(s); resourceHistory.setStartedTime(); resourceHistory = (ResourceOperationHistory) operationManager.updateOperationHistory(s, resourceHistory); AgentClient agentClient = agentManager.getAgentClient(getOverlord(), resource.getId()); agentClient.getOperationAgentService().invokeOperation(resourceHistory.getJobId().toString(), resource.getId(), schedule.getOperationName(), schedule.getParameters()); } catch (Exception e) { resourceHistory.setErrorMessage(ThrowableUtil.getStackAsString(e)); operationManager.updateOperationHistory(s, resourceHistory); operationManager.checkForCompletedGroupOperation(resourceHistory.getId()); throw e;
PageList<ResourceOperationHistory> histories = operationManager .findResourceOperationHistoriesByCriteria(remoteClient.getSubject(), criteria); if (histories.size() > 0 && histories.get(0).getStatus() != OperationRequestStatus.INPROGRESS) { history = histories.get(0); Configuration result = (history != null ? history.getResults() : null);
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; }
composite.history.setErrorMessage("This has been cancelled due to halt-on-error " + "being set on the parent group operation schedule. " + "A previous resource operation that executed prior " + "to this resource operation failed, thus causing " + "this resource operation to be cancelled."); composite.history.setStatus(OperationRequestStatus.CANCELED); composite.history = (ResourceOperationHistory) operationManager.updateOperationHistory( getUserWithSession(user, true), composite.history); int resourceHistoryId = composite.history.getId(); OperationHistory updatedOperationHistory = null; long sleep = 1000L; // quick sleep for fast ops, then slow down
builder = Response.ok(hist); if (history.getStatus()== OperationRequestStatus.SUCCESS) {
@Override public OperationHistory getOperationHistoryByHistoryId(Subject subject, int historyId) { OperationHistory history = entityManager.find(OperationHistory.class, historyId); if (history == null) { throw new IllegalArgumentException("Cannot get history - it does not exist: " + historyId); } if (history.getParameters() != null) { history.getParameters().getId(); // eagerly load it } if (history instanceof ResourceOperationHistory) { ResourceOperationHistory resourceHistory = (ResourceOperationHistory) history; if (resourceHistory.getResults() != null) { resourceHistory.getResults().getId(); // eagerly load it } } ensureViewPermission(subject, history); return history; }
opsManager.deleteOperationHistory(caller,history.getId(),false);
history = new ResourceOperationHistory(uniqueJobId, jobGroupName, subject.getName(), opDef, (parameters == null ? null : parameters.deepCopy(false)), schedule.getResource(), null);
if (history.getStatus() != OperationRequestStatus.INPROGRESS) { LOG.debug("Was told an operation was canceled but, curiously, it was not in progress: " + "job-id=[" + jobId + "], op-history=[" + history + "]"); history.setErrorMessage(error.getStackTraceString()); } else { history.setErrorMessage("Operation was canceled at " + new Date(completionTime)); history.setResults(result); history.setStatus(OperationRequestStatus.CANCELED); operationManager.checkForCompletedGroupOperation(history.getId()); } catch (Exception e) { LOG.error("Failed to update history from canceled operation, jobId=[" + jobId + "]. Cause: " + e, e);