Package org.rhq.core.domain.resource

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


        return configDir.getAbsoluteFile();
    }

    @Override
    public ResourceUpgradeReport upgrade(ResourceUpgradeContext inventoriedResource) {
        ResourceUpgradeReport report = new ResourceUpgradeReport();
        boolean upgraded = false;

        String configDirPath = inventoriedResource.getResourceKey();
        File configDir = new File(configDirPath);
        try {
            String configDirCanonicalPath = configDir.getCanonicalPath();
            if (!configDirCanonicalPath.equals(configDirPath)) {
                upgraded = true;
                report.setNewResourceKey(configDirCanonicalPath);
            }
        } catch (IOException e) {
            LOG.warn("Unexpected IOException while converting host config file path to its canonical form", e);
        }
View Full Code Here


    // 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));

            // The version string for a subdeployment must incorporate the parent deployment's version
            // so that we detect an overall version change if the parent is re-deployed.  Without this
            // the Subdeployment will not be properly updated if its version remains unchanged in the
            // updated Deployment.
            if (SUBDEPLOYMENT_TYPE.equals(inventoriedResource.getResourceType().getName())) {
                String parentResourceVersion = inventoriedResource.getParentResourceContext().getVersion();
                parentResourceVersion = (null == parentResourceVersion) ? "" : (parentResourceVersion + "/");
                result.setNewVersion(parentResourceVersion + MATCHER.group(2));
            } else {
                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

        if (existingPluginConfig.getSimpleValue(DEPLOYMENT_NAME_PROPERTY) != null) {
            newPluginConfiguration = getNewPluginConfig(upgradeContext);
        }

        if (newResourceKey != null || newPluginConfiguration != null) {
            ResourceUpgradeReport upgradeReport = new ResourceUpgradeReport();
            upgradeReport.setNewResourceKey(newResourceKey);
            upgradeReport.setNewPluginConfiguration(newPluginConfiguration);
            return upgradeReport;
        }

        return null;
    }
View Full Code Here

        if (newKey == null) {
            return null;
        }

        ResourceUpgradeReport report = new ResourceUpgradeReport();

        report.setNewResourceKey(getResourceKey(newKey, ordinal, parentOrdinal));

        return report;
    }
View Full Code Here

        AgentManagementMBean mbean = getAgentManagementMBean();

        String oldResourceKey = inventoriedResource.getResourceKey();
        String newResourceKey = getResourceKey(inventoriedResource.getParentResourceContext(), mbean);

        ResourceUpgradeReport ret = null;

        if (!oldResourceKey.equals(newResourceKey)) {
            ret = new ResourceUpgradeReport();
            ret.setNewResourceKey(newResourceKey);
            return ret;
        }

        /* if we ever allow resource name upgrades on the server, we can uncomment
         * this but I'm leaving it out for now so that we don't litter the upgrade
View Full Code Here

    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Override
    public ResourceUpgradeReport upgrade(ResourceUpgradeContext ruc) {
        ResourceUpgradeReport result = null;

        // We want to update the plugin config.  To get the new plugin config we need to:
        // 1) perform a discovery
        // 2) make sure the reskey matches telling us we're dealing with the same logical resource
        // 3) update the plugin config props if they differ

        // generate a discovery context from the resource context (i was amazed I could do this!)
        ResourceDiscoveryContext dc = new ResourceDiscoveryContext(ruc.getResourceType(),
            ruc.getParentResourceComponent(), ruc.getParentResourceContext(), ruc.getSystemInformation(),
            ruc.getNativeProcessesForType(), ruc.getPluginContainerName(), ruc.getPluginContainerDeployment());

        Set<DiscoveredResourceDetails> discoveredResources = discoverResources(dc);
        boolean upgrade = false;

        for (DiscoveredResourceDetails drd : discoveredResources) {
            if (drd.getResourceKey().equals(ruc.getResourceKey())) {
                Configuration newPluginConfig = drd.getPluginConfiguration();
                Configuration oldPluginConfig = ruc.getPluginConfiguration();

                String newCommandLine = newPluginConfig.getSimpleValue(COMMAND_LINE_CONFIG_PROPERTY);
                String oldCommandLine = oldPluginConfig.getSimpleValue(COMMAND_LINE_CONFIG_PROPERTY);
                if (null != newCommandLine && !newCommandLine.equals(oldCommandLine)) {
                    oldPluginConfig.put(new PropertySimple(COMMAND_LINE_CONFIG_PROPERTY, newCommandLine));
                    upgrade = true;
                }

                String newBasedir = newPluginConfig.getSimpleValue(BASEDIR_PROPERTY);
                String oldBasedir = oldPluginConfig.getSimpleValue(BASEDIR_PROPERTY);
                if (null != newBasedir && !newBasedir.equals(oldBasedir)) {
                    oldPluginConfig.put(new PropertySimple(BASEDIR_PROPERTY, newBasedir));
                    upgrade = true;
                }

                String newYaml = newPluginConfig.getSimpleValue(YAML_PROPERTY);
                String oldYaml = oldPluginConfig.getSimpleValue(YAML_PROPERTY);
                if (null != newYaml && !newYaml.equals(oldYaml)) {
                    oldPluginConfig.put(new PropertySimple(YAML_PROPERTY, newYaml));
                    upgrade = true;
                }

                if (upgrade) {
                    result = new ResourceUpgradeReport();
                    result.setNewPluginConfiguration(oldPluginConfig);
                }

                break;
            }
        }
View Full Code Here

        return details;
    }

    @Override
    public ResourceUpgradeReport upgrade(ResourceUpgradeContext<ResourceComponent<?>> inventoriedResource) {
        ResourceUpgradeReport report = new ResourceUpgradeReport();
        if ("Cassandra Server JVM".equals(inventoriedResource.getName())) {
            report.setNewName("JVM");
            report.setNewDescription("The JVM of the Storage node");
            report.setForceGenericPropertyUpgrade(true);
            return report;
        }
        return null;
    }
View Full Code Here

        //all the information we need for the new style resource key is
        //actually present in the plugin configuration of the existing resource
        //already, so let's just generate the new style resource key from it.       
        String resourceKey = formatResourceKey(context.getPluginConfiguration());

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

        return rep;
    }
View Full Code Here

                    newKey = JvmResourceKey.fromExplicitValue(mainClassName, explicitKeyValue);
                } else {
                    newKey = JvmResourceKey.fromJmxRemotingPort(mainClassName, oldKey.getJmxRemotingPort());
                }

                ResourceUpgradeReport resourceUpgradeReport = new ResourceUpgradeReport();
                resourceUpgradeReport.setNewResourceKey(newKey.toString());
                return resourceUpgradeReport;
            }
        }

        return null;
View Full Code Here

        return detail;
    }

    @Override
    public ResourceUpgradeReport upgrade(ResourceUpgradeContext inventoriedResource) {
        ResourceUpgradeReport report = new ResourceUpgradeReport();
        boolean upgraded = false;

        String currentResourceKey = inventoriedResource.getResourceKey();
        Configuration pluginConfiguration = inventoriedResource.getPluginConfiguration();
        ServerPluginConfiguration serverPluginConfiguration = new ServerPluginConfiguration(pluginConfiguration);

        boolean hasLocalResourcePrefix = currentResourceKey.startsWith(LOCAL_RESOURCE_KEY_PREFIX);
        boolean hasRemoteResourcePrefix = currentResourceKey.startsWith(REMOTE_RESOURCE_KEY_PREFIX);
        if (!hasLocalResourcePrefix && !hasRemoteResourcePrefix) {
            // Resource key in wrong format
            upgraded = true;
            if (new File(currentResourceKey).isDirectory()) {
                // Old key format for a local resource (key is base dir)
                report.setNewResourceKey(createKeyForLocalResource(serverPluginConfiguration));
            } else if (currentResourceKey.contains(":")) {
                // Old key format for a remote (manually added) resource (key is base dir)
                report.setNewResourceKey(createKeyForRemoteResource(currentResourceKey));
            } else {
                upgraded = false;
                LOG.warn("Unknown format, cannot upgrade resource key [" + currentResourceKey + "]");
            }
        } else if (hasLocalResourcePrefix) {
            String configFilePath = currentResourceKey.substring(LOCAL_RESOURCE_KEY_PREFIX.length());
            File configFile = new File(configFilePath);
            try {
                String configFileCanonicalPath = configFile.getCanonicalPath();
                if (!configFileCanonicalPath.equals(configFilePath)) {
                    upgraded = true;
                    report.setNewResourceKey(LOCAL_RESOURCE_KEY_PREFIX + configFileCanonicalPath);
                }
            } catch (IOException e) {
                LOG.warn("Unexpected IOException while converting host config file path to its canonical form", e);
            }
        }

        if (pluginConfiguration.getSimpleValue("expectedRuntimeProductName") == null) {
            upgraded = true;
            pluginConfiguration.setSimpleValue("expectedRuntimeProductName",
                serverPluginConfiguration.getProductType().PRODUCT_NAME);
            report.setNewPluginConfiguration(pluginConfiguration);
        }

        String supportsPatching = pluginConfiguration.getSimpleValue("supportsPatching");
        if (supportsPatching == null || supportsPatching.startsWith("__UNINITIALIZED_")) {
            upgraded = true;

            JBossProductType productType = JBossProductType.valueOf(pluginConfiguration.getSimpleValue("productType"));
            pluginConfiguration
                .setSimpleValue("supportsPatching", Boolean.toString(supportsPatching(productType, inventoriedResource.getVersion())));

            report.setNewPluginConfiguration(pluginConfiguration);
        }

        if (upgraded) {
            return report;
        }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.ResourceUpgradeReport

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.