@Override public String toString() { StringBuilder buf = new StringBuilder(); buf.append("id=[" + this.id); buf.append("], job-name=[" + this.jobName); buf.append("], job-group=[" + this.jobGroup); buf.append("], status=[" + this.status); buf.append("], subject-name=[" + this.subjectName); buf.append("], ctime=[" + new java.util.Date(this.createdTime)); buf.append("], mtime=[" + new java.util.Date(this.modifiedTime)); buf.append("], duration-millis=[" + getDuration()); String err = this.errorMessage; if ((err != null) && (err.indexOf('\n') > -1)) { err = err.substring(0, err.indexOf('\n')) + "..."; } buf.append("], error-message=[" + err); return buf.toString(); }
/** * Calling this method with a non-<code>null</code> error message implies that the request's status is * {@link OperationRequestStatus#FAILURE}. The inverse is <i>not</i> true - that is, if you set the error message to * <code>null</code>, the status is left as-is; it will not assume that a <code>null</code> error message means the * status is successful. * * @param errorMessage */ public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; if (this.errorMessage != null) { setStatus(OperationRequestStatus.FAILURE); } }
boolean isNewHistory = (0 == history.getId()); OperationRequestStatus originalStatus = null; if (!isNewHistory) { OperationHistory existingHistoryItem = entityManager.find(OperationHistory.class, history.getId()); if (null == existingHistoryItem) { throw new IllegalArgumentException( originalStatus = existingHistoryItem.getStatus(); existingHistoryItem.setStatus(history.getStatus()); existingHistoryItem.setErrorMessage(history.getErrorMessage()); if (existingHistoryItem.getStartedTime() == 0) { existingHistoryItem.setStartedTime(history.getStartedTime()); Configuration parameters = history.getParameters(); if ((parameters != null) && (parameters.getId() == 0)) { entityManager.persist(parameters); history.setParameters(parameters); if (history.getParameters() != null) { history.getParameters().getId(); // eagerly reload the parameters if (isNewHistory || originalStatus != history.getStatus()) { notifyAlertConditionCacheManager("updateOperationHistory", history);
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); } }
if (updatedOperationHistory.getDuration() > (GroupOperationJob.BREAK_VALUE)) { break; } while (updatedOperationHistory.getStatus() == OperationRequestStatus.INPROGRESS); && (updatedOperationHistory.getStatus() != OperationRequestStatus.SUCCESS) && schedule.isHaltOnFailure()) { hadFailure = true;
@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()); }
@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; }
} else if (operationHistory.getOperationDefinition().getName().equals("prepareForBootstrap")) { try { storageNodeOperationsHandler.handlePrepareForBootstrap(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("addNodeMaintenance")) { try { storageNodeOperationsHandler.handleAddNodeMaintenance(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("decommission")) { try { storageNodeOperationsHandler.handleDecommission(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("removeNodeMaintenance")) { try { storageNodeOperationsHandler.handleRemoveNodeMaintenance(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("unannounce")) { try { storageNodeOperationsHandler.handleUnannounce(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("uninstall")) { try { storageNodeOperationsHandler.handleUninstall(resourceOperationHistory); } else if (operationHistory.getOperationDefinition().getName().equals("repair")) { try { storageNodeOperationsHandler.handleRepair(resourceOperationHistory);
if (history.getStatus() == OperationRequestStatus.INPROGRESS) {
@Override public int hashCode() { return getJobId().hashCode(); }