Package org.rhq.core.domain.cloud

Examples of org.rhq.core.domain.cloud.StorageNodeConfigurationComposite


    public static final String RHQ_STORAGE_CONNECTOR_PROPERTY = "connectorAddress";
    public static final String RHQ_STORAGE_NOTIFY_DIR_CHANGE_PROPERTY = "dataDirectoriesChanged";

    public static StorageNodeConfigurationComposite createCompositeConfiguration(Configuration storageNodeConfiguration, Configuration storageNodePluginConfiguration, StorageNode storageNode) {
        StorageNodeConfigurationComposite configuration = new StorageNodeConfigurationComposite(storageNode);
        configuration.setHeapSize(storageNodeConfiguration.getSimpleValue(RHQ_STORAGE_HEAP_MAX_PROPERTY));
        configuration.setHeapNewSize(storageNodeConfiguration.getSimpleValue(RHQ_STORAGE_HEAP_NEW_PROPERTY));
        configuration.setThreadStackSize(storageNodeConfiguration.getSimpleValue(RHQ_STORAGE_THREAD_STACK_PROPERTY));
        configuration.setCommitLogLocation(storageNodeConfiguration.getSimpleValue(RHQ_STORAGE_COMMIT_LOG_PROPERTY));
        configuration.setSavedCachesLocation(storageNodeConfiguration.getSimpleValue(RHQ_STORAGE_SAVED_CACHES_PROPERTY));
        PropertyList allDataFileLocations = storageNodeConfiguration.getList(RHQ_STORAGE_DATA_FILE_PROPERTY);
        if(allDataFileLocations != null) {
            List<String> dataDirectories = new LinkedList<String>();
            for (Property property : allDataFileLocations.getList()) {
                PropertySimple dataFileLocation = (PropertySimple) property;
                dataDirectories.add(dataFileLocation.getStringValue());
            }
            configuration.setDataLocations(dataDirectories);
        }

        configuration.setJmxPort(Integer.parseInt(storageNodePluginConfiguration
                .getSimpleValue(RHQ_STORAGE_JMX_PORT_PROPERTY)));

        return configuration;
    }
View Full Code Here


            if (configurationUpdate != null) {
                return StorageNodeConfigurationUtil.createCompositeConfiguration(storageNodeConfiguration, storageNodePluginConfiguration, storageNode);
            }
        }
        return new StorageNodeConfigurationComposite(storageNode);
    }
View Full Code Here

        // StorageNodePluginConfig
        Configuration storageNodePluginConfig = configurationManager.getPluginConfiguration(subject,
                storageNodeResource.getId());

        StorageNodeConfigurationComposite existingStorageNodeConfigurationComposite = StorageNodeConfigurationUtil.createCompositeConfiguration(storageNodeResourceConfig, storageNodePluginConfig, storageNode);
        StorageNodeConfigurationUtil.syncConfigs(newStorageNodeConfigurationComposite, existingStorageNodeConfigurationComposite);

        if(!existingStorageNodeConfigurationComposite.equals(newStorageNodeConfigurationComposite)) {
            // Now we need an update
            StorageNodeConfigurationUtil.updateValuesToConfiguration(newStorageNodeConfigurationComposite, storageNodeResourceConfig);

            if(!existingStorageNodeConfigurationComposite.isDirectoriesEqual(newStorageNodeConfigurationComposite)) {
                storageNodeResourceConfig.setSimpleValue(StorageNodeConfigurationUtil.RHQ_STORAGE_NOTIFY_DIR_CHANGE_PROPERTY, Boolean.TRUE.toString());
            }

            ResourceConfigurationUpdate resourceUpdate = configurationManager.updateResourceConfiguration(subject, storageNodeResource.getId(),
                storageNodeResourceConfig);

            // initial waiting before the first check
            try {
                Thread.sleep(2000L);
            } catch (InterruptedException e) {
                // nothing
            }
            // wait for the resource config update
            ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
            criteria.addFilterId(resourceUpdate.getId());
            criteria.addFilterStartTime(System.currentTimeMillis() - (5 * 60 * 1000));
            boolean updateSuccess = waitForConfigurationUpdateToFinish(subject, criteria, 10);

            // restart the storage node and wait for it
            boolean restartSuccess = runOperationAndWaitForResult(subject, storageNodeResource, RESTART_OPERATION,
                    null, 5000, 15);

            if (!updateSuccess || !restartSuccess)
                return false;
        }

        if (existingStorageNodeConfigurationComposite.getJmxPort() != newStorageNodeConfigurationComposite.getJmxPort()) {
            String newJMXPort = Integer.toString(newStorageNodeConfigurationComposite.getJmxPort());
            String existingJMXPort = Integer.toString(existingStorageNodeConfigurationComposite.getJmxPort());
            // 2. upgrade the plugin configuration if there was a change
            storageNodePluginConfig.setSimpleValue(StorageNodeConfigurationUtil.RHQ_STORAGE_JMX_PORT_PROPERTY, newJMXPort);
            String existingConnectionURL = storageNodePluginConfig.getSimpleValue(StorageNodeConfigurationUtil.RHQ_STORAGE_CONNECTOR_PROPERTY);
            String newConnectionURL = existingConnectionURL.replace(":" + existingJMXPort + "/", ":"
                    + newStorageNodeConfigurationComposite.getJmxPort() + "/");
View Full Code Here

public class StorageNodeConfigurationUtilTest {

    @Test
    public void testConfigurationSync() throws Exception {
        StorageNode mockStorageNode = Mockito.mock(StorageNode.class);
        StorageNodeConfigurationComposite oldConfig = new StorageNodeConfigurationComposite(mockStorageNode);
        StorageNodeConfigurationComposite newConfig = new StorageNodeConfigurationComposite(mockStorageNode);

        // These should be copied to newConfig
        String oldLogLocationValue = "oldLogLocation";
//        int oldJmxPort = 123;
        oldConfig.setCommitLogLocation(oldLogLocationValue); // Test object copy
//        oldConfig.setJmxPort(oldJmxPort); // Test primitive copy, but actually don't test it.

        // This should stay null in oldConfig and be left alone in newConfig
        String heapNewSize = "384m";
        newConfig.setHeapNewSize(heapNewSize);

        // These should not be touched
        String newCacheLocationValue = "newCacheLocation";
        String oldCacheLocationValue = "oldCacheLocation";
        newConfig.setSavedCachesLocation(newCacheLocationValue);
        oldConfig.setSavedCachesLocation(oldCacheLocationValue);

        StorageNodeConfigurationUtil.syncConfigs(newConfig, oldConfig);

        assertEquals(newConfig.getCommitLogLocation(), oldLogLocationValue);
//        assertEquals(newConfig.getJmxPort(), oldJmxPort);

        assertEquals(newConfig.getHeapNewSize(), heapNewSize);
        assertNull(oldConfig.getHeapNewSize());

        assertEquals(newConfig.getSavedCachesLocation(), newCacheLocationValue);
        assertEquals(oldConfig.getSavedCachesLocation(), oldCacheLocationValue);

        // TODO: Add test to check against StorageNodeReplacement
    }
View Full Code Here

                        errors.put(FIELD_HEAP_MAX, MSG.view_adminTopology_storageNodes_settings_validator1());
                        errors.put(FIELD_HEAP_NEW, MSG.view_adminTopology_storageNodes_settings_validator2());
                        form.setErrors(errors, true);
                        return;
                    }
                    final StorageNodeConfigurationComposite configuration = getConfiguration();
                    if (StorageNodeConfigurationEditor.this.configuration.equals(configuration)) {
                        SC.say("Info", MSG.view_adminTopology_storageNodes_settings_noChanges());
                    } else {
                        SC.ask(
                            MSG.view_adminTopology_storageNodes_settings_confirmation(),
View Full Code Here

        return toolStrip;
    }

    private StorageNodeConfigurationComposite getConfiguration() {
        StorageNodeConfigurationComposite configuration = new StorageNodeConfigurationComposite(
            this.configuration.getStorageNode());
        configuration.setHeapSize(getJVMMemoryString(form.getField(FIELD_HEAP_MAX).getValue().toString()));
        configuration.setHeapNewSize(getJVMMemoryString(form.getField(FIELD_HEAP_NEW).getValue().toString()));
        configuration.setThreadStackSize(form.getValueAsString(FIELD_THREAD_STACK_SIZE));
        configuration.setJmxPort(Integer.parseInt(form.getValueAsString(FIELD_JMX_PORT)));
        configuration.setCommitLogLocation(form.getValueAsString(FIELD_COMMITLOG));
        configuration.setSavedCachesLocation(form.getValueAsString(FIELD_SAVED_CACHES));

        List<String> newDataLocations = new LinkedList<String>();
        newDataLocations.add(form.getValueAsString(FIELD_DATA));
        configuration.setDataLocations(newDataLocations);

        return configuration;
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.cloud.StorageNodeConfigurationComposite

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.