Examples of BundleScheduleResponse


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

        return null;
    }

    @Override
    public BundleScheduleResponse schedule(BundleScheduleRequest request) {
        return new BundleScheduleResponse();
    }
View Full Code Here

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

                    BundleResourceDeploymentHistory.Status.SUCCESS, "Requested deployment time: "
                        + request.getRequestedDeployTimeAsString(), null);
                bundleManager.addBundleResourceDeploymentHistoryInNewTrans(subjectManager.getOverlord(),
                    resourceDeployment.getId(), history);

                BundleScheduleResponse response = bundleAgentService.schedule(request);

                if (!response.isSuccess()) {
                    // Handle Schedule Failures. This may include deployment failures for immediate deployment request
                    bundleManager.setBundleResourceDeploymentStatusInNewTransaction(subject,
                        resourceDeployment.getId(), BundleDeploymentStatus.FAILURE);
                    history = new BundleResourceDeploymentHistory(subject.getName(), AUDIT_ACTION_DEPLOYMENT,
                        deployment.getName(), null, BundleResourceDeploymentHistory.Status.FAILURE,
                        response.getErrorMessage(), null);
                    bundleManager.addBundleResourceDeploymentHistoryInNewTrans(subject, resourceDeployment.getId(),
                        history);
                }
            } catch (Throwable t) {
                // fail the unlaunched resource deployment
View Full Code Here

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

            false, true, false);
    }

    @Override
    public BundleScheduleResponse schedule(final BundleScheduleRequest request) {
        final BundleScheduleResponse response = new BundleScheduleResponse();

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

            // find the resource that will handle the bundle processing
            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 deployment for bundle type ["
                    + bundleType
                    + "]. Ensure the bundle plugin is deployed and its resource is imported into inventory.");
            }

            auditDeployment(resourceDeployment, AUDIT_DEPLOYMENT_SCHEDULED, bundleDeployment.getName(),
                "Scheduled deployment time: " + request.getRequestedDeployTimeAsString());

            Runnable deployerRunnable = new Runnable() {
                @Override
                public void run() {
                    try {
                        // pull down the bundle files that the plugin will need in order to process the bundle
                        File pluginTmpDir = resourceContainer.getResourceContext().getTemporaryDirectory();
                        File bundleFilesDir = new File(pluginTmpDir, "bundle-versions/"
                            + bundleDeployment.getBundleVersion().getId());
                        bundleFilesDir.mkdirs();

                        // clean up any old downloads we may have retrieved before. This helps clean out
                        // our temp directory so we don't unnecessarily fill up our file system with obsolete files
                        removeOldDownloadedBundleFiles(bundleFilesDir);

                        // now download the bundle files we need for the current deployment
                        Map<PackageVersion, File> downloadedFiles = downloadBundleFiles(resourceDeployment,
                            bundleFilesDir);

                        // deploy the bundle utilizing the bundle facet object
                        String deploymentMessage = "Deployment [" + bundleDeployment + "] to ["
                            + resourceDeployment.getResource() + "]";
                        auditDeployment(resourceDeployment, AUDIT_DEPLOYMENT_STARTED, bundleDeployment.getName(),
                            deploymentMessage);

                        BundleDeployRequest deployRequest = new BundleDeployRequest();
                        deployRequest.setBundleManagerProvider(BundleManager.this);
                        deployRequest.setResourceDeployment(resourceDeployment);
                        deployRequest.setBundleFilesLocation(bundleFilesDir);
                        deployRequest.setPackageVersionFiles(downloadedFiles);
                        deployRequest.setCleanDeployment(request.isCleanDeployment());
                        deployRequest.setRevert(request.isRevert());

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

                            deployRequest.setReferencedConfiguration(
                                createReferencedConfigurationFromResource(resourceDeployment));
                        }

                        // get the bundle facet object that will process the bundle and call it to start the deployment
                        int facetMethodTimeout =
                            4 * 60 * 60 * 1000; // 4 hours is given to the bundle plugin to do its thing
                        BundleFacet bundlePluginComponent = getBundleFacet(bundleHandlerResourceId, facetMethodTimeout);
                        BundleDeployResult result = bundlePluginComponent.deployBundle(deployRequest);
                        if (result.isSuccess()) {
                            completeDeployment(resourceDeployment, BundleDeploymentStatus.SUCCESS, deploymentMessage);
                        } else {
                            completeDeployment(resourceDeployment, BundleDeploymentStatus.FAILURE,
                                result.getErrorMessage());
                        }
                    } catch (InterruptedException ie) {
                        LOG.error("Failed to complete bundle deployment due to interrupt", ie);
                        completeDeployment(resourceDeployment, BundleDeploymentStatus.FAILURE, "Deployment interrupted");
                    } catch (Throwable t) {
                        LOG.error("Failed to complete bundle deployment", t);
                        completeDeployment(resourceDeployment, BundleDeploymentStatus.FAILURE, "Deployment failed: "
                            + ThrowableUtil.getAllMessages(t));
                    }
                }
            };

            this.deployerThreadPool.execute(deployerRunnable);
        } catch (Throwable t) {
            LOG.error("Failed to schedule bundle request: " + request, t);
            response.setErrorMessage(t);
        }

        return response;
    }
View Full Code Here

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

        // No matter what the CONTEXT_VALUE_FS is (i.e. the default context value in the plugin descriptor),
        // if the user specifies an absolute path for the destination, that will be used explicitly. So here in this test,
        // the destination was specified with a destDir that had an absolute path of /tmp/dest and it will be used as-is
        mockBundleManager.absolutePathToAssert = getPath("/tmp/dest");
        BundleScheduleResponse response = mockBundleManager.schedule(request);
        assertSuccess(response);
        assertBundleDeploymentStatus(BundleDeploymentStatus.SUCCESS);
    }
View Full Code Here

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

        // in the real world, the context value for fileSystem contexts will probably always be "/" but
        // to test that we are really using this context value, our tests set it to something other than "/".
        // That's why we prepend CONTEXT_VALUE_FS to the front of the destination's destDir
        // note that we expect that relative path converted to absolute
        mockBundleManager.absolutePathToAssert = BUNDLE_CONFIG_CONTEXT_VALUE_FS + "/relative/path";
        BundleScheduleResponse response = mockBundleManager.schedule(request);
        assertSuccess(response);
        assertBundleDeploymentStatus(BundleDeploymentStatus.SUCCESS);

    }
View Full Code Here

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

        BundleDeployment bundleDeployment = new BundleDeployment(bundleVersion, destination, "deploymentName");
        BundleResourceDeployment resourceDeployment = new BundleResourceDeployment(bundleDeployment, im.serverPC);
        BundleScheduleRequest request = new BundleScheduleRequest(resourceDeployment);

        mockBundleManager.absolutePathToAssert = BUNDLE_CONFIG_LOCATION_PC + "/relative/path/pc";
        BundleScheduleResponse response = mockBundleManager.schedule(request);
        assertSuccess(response);
        assertBundleDeploymentStatus(BundleDeploymentStatus.SUCCESS);

    }
View Full Code Here

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

        BundleDeployment bundleDeployment = new BundleDeployment(bundleVersion, destination, "deploymentName");
        BundleResourceDeployment resourceDeployment = new BundleResourceDeployment(bundleDeployment, im.serverRC);
        BundleScheduleRequest request = new BundleScheduleRequest(resourceDeployment);

        mockBundleManager.absolutePathToAssert = BUNDLE_CONFIG_LOCATION_RC + "/relative/path/rc";
        BundleScheduleResponse response = mockBundleManager.schedule(request);
        assertSuccess(response);
        assertBundleDeploymentStatus(BundleDeploymentStatus.SUCCESS);

    }
View Full Code Here

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

        BundleDeployment bundleDeployment = new BundleDeployment(bundleVersion, destination, "deploymentName");
        BundleResourceDeployment resourceDeployment = new BundleResourceDeployment(bundleDeployment, im.serverMT);
        BundleScheduleRequest request = new BundleScheduleRequest(resourceDeployment);

        mockBundleManager.absolutePathToAssert = BUNDLE_CONFIG_LOCATION_MT + "/relative/path/mt";
        BundleScheduleResponse response = mockBundleManager.schedule(request);
        assertSuccess(response);
        assertBundleDeploymentStatus(BundleDeploymentStatus.SUCCESS);

    }
View Full Code Here

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

        BundleDeployment bundleDeployment = new BundleDeployment(bundleVersion, destination, "deploymentName");
        BundleResourceDeployment resourceDeployment = new BundleResourceDeployment(bundleDeployment, im.serverFS);
        BundleScheduleRequest request = new BundleScheduleRequest(resourceDeployment);

        mockBundleManager.absolutePathToAssert = "/should_fail_to_match"; // this will not match the /tmp/dest that we set the destination to
        BundleScheduleResponse response = mockBundleManager.schedule(request);
        assertSuccess(response);
        assertBundleDeploymentStatus(BundleDeploymentStatus.FAILURE);

    }
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.