Package org.rhq.core.pc.configuration

Examples of org.rhq.core.pc.configuration.ConfigurationManager


    protected int loadUpdateConfigChildResources(Resource rootResource, List<String> ignoredResources)
        throws InterruptedException, PluginContainerException {

        ignoredResources = (ignoredResources == null) ? new ArrayList<String>() : ignoredResources;

        ConfigurationManager configManager = this.pluginContainer.getConfigurationManager();
        Thread.sleep(10 * 1000L);

        Queue<Resource> unparsedResources = new LinkedList<Resource>();
        addCommitedChildrenToCollection(unparsedResources, rootResource, ignoredResources);

        int errorCount = 0;

        while (!unparsedResources.isEmpty()) {
            Resource resourceUnderTest = unparsedResources.poll();

            addCommitedChildrenToCollection(unparsedResources, resourceUnderTest, ignoredResources);

            if (resourceUnderTest.getResourceType().getResourceConfigurationDefinition() != null) {
                Configuration configUnderTest = configManager.loadResourceConfiguration(resourceUnderTest.getId());

                ConfigurationUpdateRequest updateRequest = new ConfigurationUpdateRequest(1, configUnderTest,
                    resourceUnderTest.getId());
                ConfigurationUpdateResponse updateResponse = configManager
                    .executeUpdateResourceConfigurationImmediately(updateRequest);

                if (updateResponse == null) {
                    errorCount++;
                    log.error("------------------------------");
View Full Code Here


            return;
        }

        newConfig = createConfigurationFromString(tokens[pos]);

        ConfigurationManager cm = pc.getConfigurationManager();

        if (isPluginConfig) {
            Resource targetResource = pc.getInventoryManager().getResourceContainer(resourceId).getResource();
            config = targetResource.getPluginConfiguration();
            if (merge) {
                // copy over existing properties that are not in newConfig
                for (Property p : config.getProperties()) {
                    if (newConfig.get(p.getName()) == null)
                        newConfig.put(p);
                }
            }

            targetResource.setPluginConfiguration(newConfig);
        } else {
            config = pc.getConfigurationManager().loadResourceConfiguration(resourceId);
            if (merge) {
                // copy over existing properties that are not in newConfig
                for (Property p : config.getProperties()) {
                    if (newConfig.get(p.getName()) == null)
                        newConfig.put(p);
                }
            }
            ConfigurationUpdateRequest request = new ConfigurationUpdateRequest(1, newConfig, resourceId);
            cm.updateResourceConfiguration(request);
        }
    }
View Full Code Here

            contentManager = inventoryManager.getContentManager();
            contentManager.initialize();
            pluginComponentFactory = inventoryManager.getPluginComponentFactory();
            ComponentService componentService = new ComponentServiceImpl(pluginManager);
            ConfigManagementFactory factory = new ConfigManagementFactoryImpl(componentService);
            configurationManager = new ConfigurationManager(configuration, componentService, factory,
                agentServiceStreamRemoter, inventoryManager);
            resourceFactoryManager = new ResourceFactoryManager(configuration, agentServiceStreamRemoter, pluginManager);
            supportManager = new SupportManager(agentServiceStreamRemoter);
            bundleManager = new BundleManager(configuration, agentServiceStreamRemoter, inventoryManager,
                measurementManager);
View Full Code Here

     *
     * @throws Exception
     */
    @Test(priority = 1043)
    public void testDiscoveredSecurityNodes() throws Exception {
        ConfigurationManager testConfigurationManager = pluginContainer.getConfigurationManager();
        //iterate through list of nodes and make sure they've all been discovered
        ////Ex. profile=full-ha,subsystem=security,security-domain=testDomain2,acl=classic
        String attribute = null;
        for (String jsonKey : jsonMap.keySet()) {
            //Ex. policy-modules
            attribute = jsonKey;
            //spinder 6/26/12: Temporarily disable until figure out why NPE happens only for this type?
            if (attribute.equals(ModuleOptionType.Authentication.getAttribute())) {
                break;//
            }
            //Ex. name=acl-modules
            //check the configuration for the Module Option Type Ex. 'Acl (Profile)' Resource. Should be able to verify components
            Resource moduleOptionsTypeResource = getModuleOptionTypeResource(attribute);
            //assert non-zero id returned
            assert moduleOptionsTypeResource.getId() != 0 : "The resource was not properly initialized. Expected id != 0";

            //Now request the resource complete with resource config
            Configuration loadedConfiguration = testConfigurationManager
                .loadResourceConfiguration(moduleOptionsTypeResource.getId());
            String code = null;
            String type = null;
            String flag = null;
            //populate the associated attributes if it's supported.
            for (String key : loadedConfiguration.getAllProperties().keySet()) {
                Property property = loadedConfiguration.getAllProperties().get(key);
                if (key.equals("code")) {
                    code = ((PropertySimple) property).getStringValue();
                } else if (key.equals("flag")) {
                    flag = ((PropertySimple) property).getStringValue();
                } else {//Ex. type.
                    type = ((PropertySimple) property).getStringValue();
                }
            }

            //retrieve module options as well.
            String jsonContent = jsonMap.get(attribute);
            Result result = new Result();
            try {
                // loading jsonMap contents for Ex. 'login-module'
                JsonNode node = mapper.readTree(jsonContent);
                Object obj = mapper.treeToValue(node, Object.class);
                result.setResult(obj);
                result.setOutcome("success");
            } catch (JsonProcessingException e) {
                e.printStackTrace();
                assert false;
            } catch (IOException e) {
                e.printStackTrace();
                assert false;
            }

            //populate the Value component complete with module Options.
            List<Value> moduleTypeValue = populateSecurityDomainModuleOptions(result, loadModuleOptionType(attribute));
            Value moduleOptionType = moduleTypeValue.get(0);
            //Ex. retrieve the acl-modules component and assert values.
            //always test 'code'
            assert moduleOptionType.getCode().equals(code) : "Module Option 'code' value is not correct. Expected '"
                + code + "' but was '" + moduleOptionType.getCode() + "'";
            if (attribute.equals(ModuleOptionType.Mapping.getAttribute())) {
                assert moduleOptionType.getType().equals(type) : "Mapping Module 'type' value is not correct. Expected '"
                    + type + "' but was '" + moduleOptionType.getType() + "'";
            } else if (!attribute.equals(ModuleOptionType.Audit.getAttribute())) {//Audit has no second parameter
                assert moduleOptionType.getFlag().equals(flag) : "Provider Module 'flag' value is not correct. Expected '"
                    + flag + "' but was '" + moduleOptionType.getFlag() + "'";
            }

            //Retrieve Module Options and test
            //Ex. Module Options  for (Acl Modules - Profile)
            Resource moduleOptionsResource = getModuleOptionsResource(moduleOptionsTypeResource, attribute);
            //assert non-zero id returned
            assert moduleOptionsResource.getId() != 0 : "The resource was not properly initialized. Expected id != 0";
            //fetch configuration for module options
            //Now request the resource complete with resource config
            Configuration loadedOptionsConfiguration = testConfigurationManager
                .loadResourceConfiguration(moduleOptionsResource.getId());
            for (String key : loadedOptionsConfiguration.getAllProperties().keySet()) {
                //retrieve the open map of Module Options
                PropertyMap map = ((PropertyMap) loadedOptionsConfiguration.getAllProperties().get(key));
                LinkedHashMap<String, Object> options = moduleOptionType.getOptions();
View Full Code Here

    private Map<String, Configuration> getAllBindingSets() throws PluginContainerException {
        ResourceType sbsResourceType = getResourceType(SERVICE_BINDING_SET_SERVICE_NAME, getPluginName());
       
        Map<String, Configuration> configs = new HashMap<String, Configuration>();
       
        ConfigurationManager configurationManager = PluginContainer.getInstance().getConfigurationManager();
       
        for(Resource sbs : getResources(sbsResourceType)) {
            Configuration config = configurationManager.loadResourceConfiguration(sbs.getId());
            String name = config.getSimpleValue("name", null);
            configs.put(name, config);
        }
        return configs;
    }
View Full Code Here

    private void restoreBindingSets(Resource sbm, Map<String, Configuration> originalBindingSets) throws Exception {
        ResourceType sbsResourceType = getResourceType(SERVICE_BINDING_SET_SERVICE_NAME, getPluginName());

        ResourceFactoryManager resourceFactory = PluginContainer.getInstance().getResourceFactoryManager();
        ConfigurationManager configurationManager = PluginContainer.getInstance().getConfigurationManager();
       
        for(Resource sbs : getResources(sbsResourceType)) {
            Configuration config = configurationManager.loadResourceConfiguration(sbs.getId());
            String name = config.getSimpleValue("name", null);
           
            Configuration originalConfiguration = originalBindingSets.get(name);
            if(originalConfiguration != null) {
                updateResourceConfiguration(sbs, originalConfiguration);
View Full Code Here

        return;
    }

    protected void testResourceConfigLoad() throws Exception {
        if (supportsFacet(ConfigurationFacet.class) && getResourceType().getResourceConfigurationDefinition() != null) {
            ConfigurationManager configurationManager = PluginContainer.getInstance().getConfigurationManager();
            Set<Resource> resources = getResources();
            for (Resource resource : resources) {
                try {
                    Configuration resourceConfig = configurationManager.loadResourceConfiguration(resource.getId());
                    // TODO: Validate the properties?
                } catch (Exception e) {
                    throw new Exception("Failed to load Resource config for " + resource + ".", e);
                }
            }
View Full Code Here

        assert value != null;
    }

    protected static Configuration updateResourceConfiguration(Resource resource, Configuration newConfiguration)
        throws Exception {
        ConfigurationManager configurationManager = PluginContainer.getInstance().getConfigurationManager();
        ConfigurationUpdateRequest configurationUpdateRequest = new ConfigurationUpdateRequest(0, newConfiguration,
            resource.getId());
        configurationManager.updateResourceConfiguration(configurationUpdateRequest);

        //give the component and the managed resource some time to properly persist the update
        Thread.sleep(500);

        return configurationManager.loadResourceConfiguration(resource.getId());
    }
View Full Code Here

        return configurationManager.loadResourceConfiguration(resource.getId());
    }

    protected static Configuration loadResourceConfiguration(Resource resource) throws Exception {
        ConfigurationManager configurationManager = PluginContainer.getInstance().getConfigurationManager();
        return configurationManager.loadResourceConfiguration(resource.getId());
    }
View Full Code Here

    }

    @Test(groups = TEST_GROUP)
    public void testResourceConfigLoad() throws Exception {
        ConfigurationManager configurationManager = PluginContainer.getInstance().getConfigurationManager();
        Configuration resourceConfig;
        try {
            for (Resource resource : getResources()) {
                resourceConfig = configurationManager.loadResourceConfiguration(resource.getId());
                Configuration expectedResourceConfig = getExpectedResourceConfig();
                assert resourceConfig.equals(expectedResourceConfig) : "Unexpected Resource configuration - \nExpected:\n\t"
                    + expectedResourceConfig.toString(true) + "\nActual:\n\t" + resourceConfig.toString(true);
            }
        } catch (PluginContainerException e) {
View Full Code Here

TOP

Related Classes of org.rhq.core.pc.configuration.ConfigurationManager

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.