Examples of ResourceUpgradeReport


Examples of org.rhq.core.domain.resource.ResourceUpgradeReport

        long timeout = getDiscoveryComponentTimeout();
        try {
            ResourceUpgradeFacet<T> proxy = this.discoveryComponentProxyFactory.getDiscoveryComponentProxy(
                resourceType, component, timeout, ResourceUpgradeFacet.class, parentResourceContainer);

            ResourceUpgradeReport report = proxy.upgrade(inventoriedResource);

            //funnel the report through all the optional resource upgrade callbacks
            Map<String, List<String>> callbacks = this.pluginManager.getMetadataManager()
                .getResourceUpgradeCallbacks(resourceType);

            if (callbacks != null) {
                //never pass a nul report to the callbacks... if it is null at the moment, just
                //create a new "blank" one. The upgrade delegate will see that there's nothing to upgrade
                //in it.
                if (report == null) {
                    report = new ResourceUpgradeReport();
                }
                //no timeouts or anything, just direct invocation.. let's hope plugins play nice
                for (Map.Entry<String, List<String>> e : callbacks.entrySet()) {
                    String pluginName = e.getKey();
                    List<String> callbackClasses = e.getValue();
View Full Code Here

Examples of org.rhq.core.domain.resource.ResourceUpgradeReport

        ResourceUpgradeRequest request = new ResourceUpgradeRequest(resource.getId());

        request.setTimestamp(System.currentTimeMillis());

        ResourceUpgradeReport upgradeReport = null;
        try {
            upgradeReport = inventoryManager.invokeDiscoveryComponentResourceUpgradeFacet(resource.getResourceType(),
                discoveryComponent, upgradeContext, parentResourceContainer);
        } catch (Throwable t) {
            log.error("ResourceUpgradeFacet threw an exception while upgrading resource [" + resource + "]", t);
            request.setErrorProperties(t);
        } finally {
            if (isResConfigCompacted) {
                resource.setResourceConfiguration(null);
            }
        }

        if (upgradeReport != null && upgradeReport.hasSomethingToUpgrade()) {
            request.fillInFromReport(upgradeReport);
        }

        if (request.hasSomethingToUpgrade()) {
            requests.add(request);
View Full Code Here

Examples of org.rhq.core.domain.resource.ResourceUpgradeReport

            RESOURCE_NAME, null, RESOURCE_DESCRIPTION, pluginConfig, null));
    }

    public ResourceUpgradeReport upgrade(ResourceUpgradeContext<T> inventoriedResource) {
        if (V1_RESOURCE_KEY.equals(inventoriedResource.getResourceKey())) {
            ResourceUpgradeReport report = new ResourceUpgradeReport();
            report.setNewResourceKey(RESOURCE_KEY);
            report.setNewName(RESOURCE_NAME);
            report.setNewDescription(RESOURCE_DESCRIPTION);
            Configuration newPluginConfiguration = new Configuration();
            newPluginConfiguration.put(new PropertySimple(TEST_PROPERTY, RESOURCE_TEST_PROPERTY));
            report.setNewPluginConfiguration(newPluginConfiguration);

            File dataDir = inventoriedResource.getDataDirectory();

            if (dataDir != null) {
                if (!(dataDir.exists())) {
View Full Code Here

Examples of org.rhq.core.domain.resource.ResourceUpgradeReport

    // The Matching logic here is the same as above, but instead of setting the discovery details we
    // set new values in the upgrade report for name, version and key.  Note that if multiple resources
    // upgrade to the same resource key it will be caught and fail downstream.
    @Override
    public ResourceUpgradeReport upgrade(ResourceUpgradeContext inventoriedResource) {
        ResourceUpgradeReport result = null;

        if (DISABLED) {
            return result;
        }

        MATCHER.reset(inventoriedResource.getName());
        if (MATCHER.matches()) {
            result = new ResourceUpgradeReport();
            result.setForceGenericPropertyUpgrade(true); // It is critical the name and version get upgraded

            // reset the resource name with the stripped value
            result.setNewName(MATCHER.group(1) + MATCHER.group(3));
            result.setNewVersion(MATCHER.group(2));
        }

        StringBuilder sb = new StringBuilder();
        String comma = "";
        boolean upgradeKey = false;
        for (String segment : COMMA_PATTERN.split(inventoriedResource.getResourceKey())) {
            sb.append(comma);
            comma = ",";
            MATCHER.reset(segment);
            if (MATCHER.matches()) {
                upgradeKey = true;
                sb.append(MATCHER.group(1)).append(MATCHER.group(3));
            } else {
                sb.append(segment);
            }
        }
        if (upgradeKey) {
            if (null == result) {
                result = new ResourceUpgradeReport();
            }
            result.setNewResourceKey(sb.toString());
        }

        if (null != result && LOG.isDebugEnabled()) {
            LOG.debug("Requesting upgrade: " + result);
        }
View Full Code Here

Examples of org.rhq.core.domain.resource.ResourceUpgradeReport

    // The Matching logic here is the same as above, but instead of setting the discovery details we
    // set new values in the upgrade report for name, version and key.
    @Override
    public ResourceUpgradeReport upgrade(ResourceUpgradeContext inventoriedResource) {
        ResourceUpgradeReport result = null;

        if (DISABLED) {
            return result;
        }

        // Note that in addition to the comma-separated segments of the DMR address, certain runtime
        // resources (e.g. "Hibernate Persistence Unit") have a forwardSlash-separated segments of
        // their own.

        StringBuilder sb = new StringBuilder();
        String slash = "";
        boolean upgradeName = false;
        for (String segment : FORWARD_SLASH_PATTERN.split(inventoriedResource.getName())) {
            MATCHER.reset(segment);
            if (MATCHER.matches()) {
                upgradeName = true;
                sb.append(slash);
                sb.append(MATCHER.group(1)).append(MATCHER.group(3));
            } else {
                sb.append(slash);
                sb.append(segment);
            }
            slash = "/";
        }

        if (upgradeName) {
            if (null == result) {
                result = new ResourceUpgradeReport();
            }
            result.setForceGenericPropertyUpgrade(true); // It is critical the name get upgraded
            result.setNewName(sb.toString());
        }

        // Note that the version string is always set to the parent's version for these
        // resources which are logically part of the umbrella deployment.
        String parentVersion = inventoriedResource.getParentResourceContext().getVersion();
        String currentVersion = inventoriedResource.getVersion();
        //noinspection StringEquality
        if ((currentVersion != parentVersion)
            && ((null == currentVersion && null != parentVersion) || !currentVersion.equals(parentVersion))) {
            if (null == result) {
                result = new ResourceUpgradeReport();
            }
            result.setForceGenericPropertyUpgrade(true); // It is critical the version get upgraded
            result.setNewVersion(parentVersion);
        }

        sb = new StringBuilder();
        String comma = "";
        boolean upgradeKey = false;
        for (String outerSegment : COMMA_PATTERN.split(inventoriedResource.getResourceKey())) {
            sb.append(comma);
            comma = ",";
            slash = "";
            for (String segment : FORWARD_SLASH_PATTERN.split(outerSegment)) {
                sb.append(slash);
                slash = "/";
                MATCHER.reset(segment);
                if (MATCHER.matches()) {
                    upgradeKey = true;
                    sb.append(MATCHER.group(1)).append(MATCHER.group(3));
                } else {
                    sb.append(segment);
                }
            }
        }
        if (upgradeKey) {
            if (null == result) {
                result = new ResourceUpgradeReport();
            }
            result.setNewResourceKey(sb.toString());
        }

        if (null != result && LOG.isDebugEnabled()) {
            LOG.debug("Requesting upgrade: " + result);
        }
View Full Code Here

Examples of org.rhq.core.domain.resource.ResourceUpgradeReport

            Boolean quotingEnabled = Boolean.valueOf(pluginConfig.getSimpleValue(PLUGINCONFIG_QUOTING_ENABLED));
            pluginConfig.setSimpleValue(PLUGINCONFIG_QUOTING_ENABLED, quotingEnabled.toString());
            pluginConfig.setSimpleValue(QUOTING_ENABLED_NEEDS_UPGRADE, FALSE.toString());

            ResourceUpgradeReport report = new ResourceUpgradeReport();
            report.setNewPluginConfiguration(pluginConfig);

            return report;
        }

        return null;
View Full Code Here

Examples of org.rhq.core.domain.resource.ResourceUpgradeReport

            }
        } finally {
            DatabasePluginUtil.safeClose(connection, statement, resultSet);
        }

        ResourceUpgradeReport report = new ResourceUpgradeReport();
        report.setNewResourceKey(createNewResourceKey(schemaName, tableName));
        report.setNewPluginConfiguration(createNewPluginConfiguration(schemaName, tableName));

        return report;
    }
View Full Code Here

Examples of org.rhq.core.domain.resource.ResourceUpgradeReport

        }

        // key is in the old format - build a key in the new format
        String resourceKey = buildResourceKey(inventoriedResourceKey, binDir);

        ResourceUpgradeReport upgradeReport = new ResourceUpgradeReport();
        upgradeReport.setNewResourceKey(resourceKey);

        return upgradeReport;
    }
View Full Code Here

Examples of org.rhq.core.domain.resource.ResourceUpgradeReport

        }

        // key is in the old format - build a key in the new format
        String resourceKey = buildResourceKey(inventoriedResourceKey, binDir);

        ResourceUpgradeReport upgradeReport = new ResourceUpgradeReport();
        upgradeReport.setNewResourceKey(resourceKey);

        return upgradeReport;
    }
View Full Code Here

Examples of org.rhq.core.domain.resource.ResourceUpgradeReport

                }
            }
        }

        if (newResourceKey != null) {
            ResourceUpgradeReport report = new ResourceUpgradeReport();
            report.setNewResourceKey(newResourceKey);

            return report;
        }

        Map<String, Set<VHostSpec>> possibleMatchesPerRK = new HashMap<String, Set<VHostSpec>>();
        for (VHostSpec vhost : vhosts) {
            Set<String> legacyResourceKeys = legacyResourceKeyUtil.getLegacyVirtualHostResourceKeys(vhost);

            for (String legacyRK : legacyResourceKeys) {
                addPossibleRKMatch(legacyRK, vhost, possibleMatchesPerRK);
            }
        }

        for (String legacyRK : legacyResourceKeyUtil.getLegacyMainServerResourceKeys()) {
            addPossibleRKMatch(legacyRK, null, possibleMatchesPerRK);
        }

        Set<VHostSpec> matchingVhosts = possibleMatchesPerRK.get(resourceKey);
        if (matchingVhosts == null || matchingVhosts.isEmpty()) {
            throw new IllegalArgumentException(
                "Failed to identify the vhost resource with the old-style resource key '"
                    + resourceKey
                    + "' with any of the vhosts in the apache configuration files. This means that the vhost resource is stale and you can safely uninventory it.");
        } else if (matchingVhosts.size() > 1) {
            String message =
                "Failed to uniquely identify the vhost from the old-style resource key. The old resource key is '"
                    + resourceKey
                    + "' which could be matched with any of the following possible new-style resource keys: "
                    + matchingVhosts
                    + ". The plugin does not have enough information to successfully upgrade this resource."
                    + " Please take note of any alert definitions or operation schedules that you have defined for this resource and manually uninventory it.";

            throw new IllegalArgumentException(message);
        } else {
            VHostSpec vhost = matchingVhosts.iterator().next();
            if (vhost == null) {
                newResourceKey = ApacheVirtualHostServiceComponent.MAIN_SERVER_RESOURCE_KEY;
            } else {
                newResourceKey = createResourceKey(vhost.serverName, vhost.hosts);
            }
        }

        ResourceUpgradeReport report = new ResourceUpgradeReport();
        report.setNewResourceKey(newResourceKey);

        return report;
    }
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.