Examples of DriftAgentService


Examples of org.rhq.core.clientapi.agent.drift.DriftAgentService

    public void ackChangeSetInNewTransaction(Subject subject, final int resourceId, final Headers headers,
        final List<JPADriftFile> driftFilesToRequest) throws Exception {

        try {
            AgentClient agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
            DriftAgentService service = agentClient.getDriftAgentService();

            service.ackChangeSet(resourceId, headers.getDriftDefinitionName());

            // send a message to the agent requesting the necessary JPADriftFile content. Note that the
            // driftFile status has been set to REQUESTED outside of this call.
            if (!driftFilesToRequest.isEmpty()) {
                try {
                    service.requestDriftFiles(resourceId, headers, driftFilesToRequest);

                } catch (Exception e) {
                    LOG.warn("Unable to inform agent of drift file request  [" + driftFilesToRequest + "]", e);
                }
            }
View Full Code Here

Examples of org.rhq.core.clientapi.agent.drift.DriftAgentService

        File changeSetFilesZip) throws Exception {
        authorizeOrFail(subject, resourceId, "Can not update drifts");
        saveChangeSetFiles(subject, changeSetFilesZip);

        AgentClient agent = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
        DriftAgentService driftService = agent.getDriftAgentService();
        driftService.ackChangeSetContent(resourceId, driftDefName, token);
    }
View Full Code Here

Examples of org.rhq.core.clientapi.agent.drift.DriftAgentService

            if (null == resource) {
                throw new IllegalArgumentException("Resource not found [" + resourceId + "]");
            }

            AgentClient agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
            DriftAgentService service = agentClient.getDriftAgentService();
            // this is a one-time on-demand call. If it fails throw an exception to make sure the user knows it
            // did not happen. But clean it up a bit if it's a connect exception
            try {
                service.detectDrift(resourceId, driftDef);
            } catch (CannotConnectException e) {
                throw new IllegalStateException(
                    "Agent could not be reached and may be down (see server logs for more). Could not perform drift detection request ["
                        + driftDef + "]");
            }
View Full Code Here

Examples of org.rhq.core.clientapi.agent.drift.DriftAgentService

                // tell the agent first - we don't want the agent reporting on the drift def after we delete it
                boolean unscheduledOnAgent = false;
                try {
                    AgentClient agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
                    DriftAgentService service = agentClient.getDriftAgentService();
                    service.unscheduleDriftDetection(resourceId, doomedDriftDef);
                    unscheduledOnAgent = true;
                } catch (Exception e) {
                    log.warn(" Unable to inform agent of unscheduled drift detection  [" + doomedDriftDef + "]", e);
                }
View Full Code Here

Examples of org.rhq.core.clientapi.agent.drift.DriftAgentService

        }

        try {
            AgentClient agent = agentManager.getAgentClient(subjectManager.getOverlord(), driftDef.getResource()
                .getId());
            DriftAgentService driftService = agent.getDriftAgentService();
            driftService.pinSnapshot(driftDef.getResource().getId(), driftDef.getName(), snapshot);
        } catch (Exception e) {
            log.warn("Unable to notify agent that DriftDefinition[driftDefinitionId: " + driftDefId
                + ", driftDefinitionName: " + driftDef.getName() + "] has been pinned. The agent may be down.", e);
        }
    }
View Full Code Here

Examples of org.rhq.core.clientapi.agent.drift.DriftAgentService

                }
            }
            resource.setAgentSynchronizationNeeded();

            AgentClient agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
            DriftAgentService service = agentClient.getDriftAgentService();
            try {
                DriftSnapshot snapshot = null;
                if (driftDef.getTemplate() != null && driftDef.getTemplate().isPinned()) {
                    snapshot = getSnapshot(subject, new DriftSnapshotRequest(driftDef.getId()));
                }
                // Do not pass attached entities to the following Agent call, which is outside Hibernate's control. Flush
                // and clear the entities to ensure the work above is captured and we pass out a detached object.
                entityManager.flush();
                entityManager.clear();

                if (snapshot != null) {
                    service.updateDriftDetection(resourceId, driftDef, snapshot);
                } else {
                    service.updateDriftDetection(resourceId, driftDef);
                }
            } catch (Exception e) {
                log.warn(" Unable to inform agent of unscheduled drift detection  [" + driftDef + "]", e);
            }
View Full Code Here

Examples of org.rhq.core.clientapi.agent.drift.DriftAgentService

                addedFileEntry("2.bin", file2SHA));

        final List<? extends DriftFile> missingContent = asList(new TestDriftFile(file1SHA),
                new TestDriftFile(file2SHA));

        final DriftAgentService driftAgentService = context.mock(DriftAgentService.class);
        context.checking(new Expectations() {{
            exactly(1).of(driftAgentService).ackChangeSet(resourceId, driftDefName);
            // TODO Need to verify that we send the correct headers to the agent
            exactly(1).of(driftAgentService).requestDriftFiles(with(resourceId), with(any(Headers.class)),
                    with(missingContent));
View Full Code Here

Examples of org.rhq.core.clientapi.agent.drift.DriftAgentService

        File changeSetZip = createChangeSetZipFile(headers,
                addedFileEntry("1.bin", file1SHA),
                addedFileEntry("2.bin", file2SHA));


        final DriftAgentService driftAgentService = context.mock(DriftAgentService.class);
        context.checking(new Expectations() {{
            exactly(1).of(driftAgentService).ackChangeSet(resourceId, driftDefName);
        }});
        driftServer.setDriftAgentService(driftAgentService);
View Full Code Here

Examples of org.rhq.core.clientapi.agent.drift.DriftAgentService

        File changeSetZip = createChangeSetZipFile(headers,
                changedFileEntry("1.bin", oldFile1SHA, newFile1SHA),
                removedFileEntry("2.bin", file2SHA));

        final List<? extends DriftFile> missingContent = asList(new TestDriftFile(newFile1SHA));
        final DriftAgentService driftAgentService = context.mock(DriftAgentService.class);
        context.checking(new Expectations() {{
            exactly(1).of(driftAgentService).ackChangeSet(resourceId, driftDefName);
            exactly(1).of(driftAgentService).requestDriftFiles(with(resourceId), with(any(Headers.class)),
                    with(missingContent));
        }});
View Full Code Here

Examples of org.rhq.core.clientapi.agent.drift.DriftAgentService

                // successfully persist the change set, then we need to send an
                // acknowledgement to the agent. This is critical because the agent will
                // in effect suspend drift detection (for the particular definition) until
                // it receives the ACK. Secondly, we need to tell the agent to send the
                // actual file bits for any change set content we do not have.
                DriftAgentService driftService = getDriftAgentService(resourceId);
                driftService.ackChangeSet(headers.getResourceId(), headers.getDriftDefinitionName());
                if (!missingContent.isEmpty()) {
                    driftService.requestDriftFiles(resourceId, headers, missingContent);
                }

                return true;
            }
        });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.