Package org.rhq.core.clientapi.agent.bundle

Examples of org.rhq.core.clientapi.agent.bundle.BundlePurgeResponse


        return new BundleScheduleResponse();
    }

    @Override
    public BundlePurgeResponse purge(BundlePurgeRequest request) {
        return new BundlePurgeResponse();
    }
View Full Code Here


                // get a connection to the agent and tell it to purge the bundle from the file system
                Subject overlord = subjectManager.getOverlord();
                AgentClient agentClient = agentManager.getAgentClient(overlord, resourceDeploy.getResource().getId());
                BundleAgentService bundleAgentService = agentClient.getBundleAgentService();
                BundlePurgeRequest request = new BundlePurgeRequest(resourceDeploy);
                BundlePurgeResponse results = bundleAgentService.purge(request);
                if (!results.isSuccess()) {
                    String errorMessage = results.getErrorMessage();
                    failedToPurge.put(resourceDeploy, errorMessage);
                }
            } catch (Exception e) {
                String errorMessage = ThrowableUtil.getStackAsString(e);
                failedToPurge.put(resourceDeploy, errorMessage);
View Full Code Here

        return null;
    }

    @Override
    public BundlePurgeResponse purge(BundlePurgeRequest request) {
        final BundlePurgeResponse response = new BundlePurgeResponse();

        try {
            final BundleResourceDeployment resourceDeployment = request.getLiveBundleResourceDeployment();
            final BundleDeployment bundleDeployment = resourceDeployment.getBundleDeployment();

            // find the resource that will purge the bundle
            BundleType bundleType = bundleDeployment.getBundleVersion().getBundle().getBundleType();
            ResourceType resourceType = bundleType.getResourceType();
            Set<Resource> resources = inventoryManager.getResourcesWithType(resourceType);
            if (resources.isEmpty()) {
                throw new Exception("No bundle plugin supports bundle type [" + bundleType + "]");
            }
            final int bundleHandlerResourceId = resources.iterator().next().getId();
            final ResourceContainer resourceContainer = inventoryManager.getResourceContainer(bundleHandlerResourceId);
            if (null == resourceContainer.getResourceContext()) {
                throw new Exception("No bundle plugin resource available to handle purge for bundle type ["
                    + bundleType
                    + "]. Ensure the bundle plugin is deployed and its resource is imported into inventory.");
            }

            // purge the bundle utilizing the bundle facet object
            String deploymentMessage = "Deployment [" + bundleDeployment + "] to be purged via ["
                + resourceDeployment.getResource() + "]";
            auditDeployment(resourceDeployment, AUDIT_PURGE_STARTED, bundleDeployment.getName(), deploymentMessage);

            org.rhq.core.pluginapi.bundle.BundlePurgeRequest purgeRequest = new org.rhq.core.pluginapi.bundle.BundlePurgeRequest();
            purgeRequest.setBundleManagerProvider(this);
            purgeRequest.setLiveResourceDeployment(resourceDeployment);

            File absoluteDestDir = getAbsoluteDestinationDir(request.getLiveBundleResourceDeployment());
            if (absoluteDestDir != null) {
                purgeRequest.setDestinationTarget(absoluteDestDir.toURI());
            } else {
                String connectionString = getConnectionString(request.getLiveBundleResourceDeployment());
                if (connectionString != null) {
                    purgeRequest.setDestinationTarget(URI.create(connectionString));
                }

                purgeRequest.setReferencedConfiguration(
                    createReferencedConfigurationFromResource(request.getLiveBundleResourceDeployment()));
            }

            // get the bundle facet object that will process the bundle and call it to start the purge
            int facetMethodTimeout =
                30 * 60 * 1000; // 30 minutes should be enough time for the bundle plugin to purge everything
            BundleFacet bundlePluginComponent = getBundleFacet(bundleHandlerResourceId, facetMethodTimeout);
            BundlePurgeResult result = bundlePluginComponent.purgeBundle(purgeRequest);
            if (result.isSuccess()) {
                auditDeployment(resourceDeployment, AUDIT_PURGE_ENDED, bundleDeployment.getName(), deploymentMessage);
            } else {
                response.setErrorMessage(result.getErrorMessage());
                auditDeployment(resourceDeployment, AUDIT_PURGE_ENDED, bundleDeployment.getName(), null,
                    Status.FAILURE, "Failed: " + deploymentMessage, result.getErrorMessage());
            }
        } catch (Throwable t) {
            LOG.error("Failed to purge bundle: " + request, t);
            response.setErrorMessage(t);
        }

        return response;
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.clientapi.agent.bundle.BundlePurgeResponse

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.