Package org.rhq.core.domain.operation

Examples of org.rhq.core.domain.operation.OperationHistory


                        }

                        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
View Full Code Here


        return groupOperationSchedule;
    }

    @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) {
View Full Code Here

        Query query = entityManager.createNamedQuery(OperationHistory.QUERY_FIND_BY_JOB_ID);
        query.setParameter("jobName", jobIdObject.getJobName());
        query.setParameter("jobGroup", jobIdObject.getJobGroup());
        query.setParameter("createdTime", jobIdObject.getCreatedTime());

        OperationHistory history;

        try {
            history = (OperationHistory) query.getSingleResult();
        } catch (Exception e) {
            history = null;
View Full Code Here

        // The history item may have been created already, so find it in the database and
        // set the new state from our input
        boolean isNewHistory = (0 == history.getId());
        OperationRequestStatus originalStatus = null;
        if (!isNewHistory) {
            OperationHistory existingHistoryItem = entityManager.find(OperationHistory.class, history.getId());
            if (null == existingHistoryItem) {
                throw new IllegalArgumentException(
                    "Can not update operation history, history record not found. This call creates a new operation history record only if the supplied history argument has id set to 0. ["
                        + history + "]");
            }

            originalStatus = existingHistoryItem.getStatus();
            existingHistoryItem.setStatus(history.getStatus());
            existingHistoryItem.setErrorMessage(history.getErrorMessage());
            if (existingHistoryItem.getStartedTime() == 0) {
                existingHistoryItem.setStartedTime(history.getStartedTime());
            }
            if (history instanceof ResourceOperationHistory) {
                ((ResourceOperationHistory) existingHistoryItem).setResults(((ResourceOperationHistory) history)
                    .getResults());
            }
View Full Code Here

        return history;
    }

    @Override
    public void cancelOperationHistory(Subject subject, int historyId, boolean ignoreAgentErrors) {
        OperationHistory doomedHistory = getOperationHistoryByHistoryId(subject, historyId); // this also checks authorization so we don't have to do it again

        ensureControlPermission(subject, doomedHistory);

        // Do different things depending whether this is a group or resource history being canceled.
        // If group history - cancel all individual resource invocations that are part of that group.
View Full Code Here

        }
    }

    @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());
    }
View Full Code Here

     *
     * @param historyId id of a history object
     */
    @Override
    public void checkForCompletedGroupOperation(int historyId) {
        OperationHistory history = entityManager.find(OperationHistory.class, historyId);
        if (!(history instanceof ResourceOperationHistory)) {
            // if the history isn't even a resource history, then we have nothing to do
            return;
        }

        if (history.getStatus() == OperationRequestStatus.INPROGRESS) {
            // if this history isn't done, then by definition the overall group isn't done either
            return;
        }

        GroupOperationHistory groupHistory = ((ResourceOperationHistory) history).getGroupOperationHistory();
View Full Code Here

            + 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 + "]");
            }
View Full Code Here

    @Override
    protected void init(boolean isReadOnly) {
        super.init(isReadOnly);

        OperationHistory operationExample = getOperationExample();
        if (operationExample != null) {
            operationDefinitionId = operationExample.getOperationDefinition().getId();
            initNameField();
            getForm().rememberValues();
        } else if (this.operationDefinitionId != null) {
            initNameField();
            getForm().rememberValues();
View Full Code Here

                if (isNewRecord()) {
                    ConfigurationTemplate defaultTemplate = parametersDefinition.getDefaultTemplate();
                    switch (operationNameChangeContext) {
                    case INIT:
                    case RESET:
                        OperationHistory operationExample = getOperationExample();
                        if (operationExample != null) {
                            Configuration exampleParameters = operationExample.getParameters();
                            if (exampleParameters == null) {
                                Message message = new Message(
                                    MSG.view_operationScheduleDetails_example_null_parameters(), Severity.Warning);
                                CoreGUI.getMessageCenter().notify(message);
                            } else if (!ConfigurationUtility.validateConfiguration(exampleParameters,
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.operation.OperationHistory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.