Package org.rhq.core.util

Examples of org.rhq.core.util.PropertiesFileUpdate


        return m_serverPropertiesFile;
    }

    private void persistServerProperty(String name, String value) {
        String filePath = getServerPropertiesFile().getAbsolutePath();
        PropertiesFileUpdate updater = new PropertiesFileUpdate(filePath);
        try {
            updater.update(name, value);
        } catch (IOException e) {
            String msgString = LOG.getMsgString(ServerI18NResourceKeys.SERVER_PROPERTY_SAVE_FAILED, name, value,
                filePath);
            throw new RuntimeException(msgString, e);
        }
View Full Code Here


        migrateRestrictedProperties(oldServerProps);

        // now merge the old settings in with the default properties from the new server install
        String newServerPropsFilePath = getServerPropertiesFile().getAbsolutePath();
        PropertiesFileUpdate newServerPropsFile = new PropertiesFileUpdate(newServerPropsFilePath);
        newServerPropsFile.update(oldServerProps);

        return;
    }
View Full Code Here

    private Properties getAgentServerEndpoint() throws Exception {
        Properties endpointData = new Properties();

        // load in the server properties file to find out how the server will be listening for agent messages
        File serverPropsFile = getServerPropertiesFile();
        Properties serverProps = new PropertiesFileUpdate(serverPropsFile).loadExistingProperties();

        // transport and transport params
        String transport = serverProps.getProperty("rhq.communications.connector.transport", "servlet");
        endpointData.put(PREF_RHQ_AGENT_SERVER_TRANSPORT, transport);
View Full Code Here

            throw new RuntimeException("Failed to encrypt password.", e);
        }

        boolean userAlreadyExisted;
        try {
            PropertiesFileUpdate propsFileUpdate = new PropertiesFileUpdate(propertiesFile.getPath());
            userAlreadyExisted = propsFileUpdate.update(user, encryptedPassword);
        } catch (Exception e) {
            throw new RuntimeException("Failed to update management users properties file [" + propertiesFile + "].", e);
        }

        String verb = (userAlreadyExisted) ? "updated" : "added";
View Full Code Here

        };
    }

    private void testSysProps(File propsFile1, File propsFile2, File jbossHome, CommandLineProducer commandLine)
        throws Exception {
        PropertiesFileUpdate propsFile1Updater = new PropertiesFileUpdate(propsFile1.getPath());
        propsFile1Updater.update("prop1", "delta");
        propsFile1Updater.update("prop4", "epsilon");

        PropertiesFileUpdate propsFile2Updater = new PropertiesFileUpdate(propsFile1.getPath());
        propsFile2Updater.update("prop2", "zeta");
        propsFile2Updater.update("prop5", "eta");

        Map<String, String> sysprops = commandLine.get().getSystemProperties();

        Assert.assertNotNull(sysprops);
        Assert.assertEquals(sysprops.size(), 8);
View Full Code Here

                        + serverPropertiesFile.getAbsolutePath() + "]. Installation is canceled.");
            }

            // Prompt for critical required values, if not yet set.
            try {
                PropertiesFileUpdate pfu = new PropertiesFileUpdate(serverPropertiesFile);
                Properties props = pfu.loadExistingProperties();

                promptForProperty(pfu, props, serverPropertiesFile.getName(),
                    ServerProperties.PROP_AUTOINSTALL_ADMIN_PASSWORD, false, true, true);
                promptForProperty(pfu, props, serverPropertiesFile.getName(), ServerProperties.PROP_DATABASE_PASSWORD,
                    true, false, true);
View Full Code Here

            }
        }
    }

    private void updateCassandraJvmProps(Configuration newConfig) throws IOException {
        PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate(jvmOptsFile.getAbsolutePath());
        Properties properties = propertiesUpdater.loadExistingProperties();

        String jmxPort = newConfig.getSimpleValue("jmxPort");
        if (!StringUtil.isEmpty(jmxPort)) {
            validateIntegerArg("jmx_port", jmxPort);
            properties.setProperty("jmx_port", jmxPort);
        }

        String maxHeapSize = newConfig.getSimpleValue("maxHeapSize");
        if (!StringUtil.isEmpty(maxHeapSize)) {
            validateHeapArg("maxHeapSize", maxHeapSize);
            // We want min and max heap to be the same
            properties.setProperty("heap_min", "-Xms" + maxHeapSize);
            properties.setProperty("heap_max", "-Xmx" + maxHeapSize);
        }

        String heapNewSize = newConfig.getSimpleValue("heapNewSize");
        if (!StringUtil.isEmpty(heapNewSize)) {
            validateHeapArg("heapNewSize", heapNewSize);
            properties.setProperty("heap_new", "-Xmn" + heapNewSize);
        }

        String threadStackSize = newConfig.getSimpleValue("threadStackSize");
        if (!StringUtil.isEmpty(threadStackSize)) {
            validateIntegerArg("threadStackSize", threadStackSize);
            properties.setProperty("thread_stack_size", "-Xss" + threadStackSize + "k");
        }

        PropertySimple heapDumpOnOMMError = newConfig.getSimple("heapDumpOnOOMError");
        if (heapDumpOnOMMError != null) {
            if (heapDumpOnOMMError.getBooleanValue()) {
                properties.setProperty("heap_dump_on_OOMError", "-XX:+HeapDumpOnOutOfMemoryError");
            } else {
                properties.setProperty("heap_dump_on_OOMError", "");
            }
        }

        String heapDumpDir = useForwardSlash(newConfig.getSimpleValue("heapDumpDir"));
        if (!StringUtil.isEmpty(heapDumpDir)) {
            properties.setProperty("heap_dump_dir", heapDumpDir);
        }

        propertiesUpdater.update(properties);
    }
View Full Code Here

            }
        }
    }

    private void updateWrapperEnv(Configuration config) throws IOException {
        PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate(wrapperEnvFile.getAbsolutePath());
        Properties properties = propertiesUpdater.loadExistingProperties();

        String maxHeapSize = config.getSimpleValue("maxHeapSize");
        if (!StringUtil.isEmpty(maxHeapSize)) {
            validateHeapArg("maxHeapSize", maxHeapSize);
            // We want min and max heap to be the same
            properties.setProperty("set.heap_min", "-Xms" + maxHeapSize);
            properties.setProperty("set.heap_max", "-Xmx" + maxHeapSize);
        }

        String heapNewSize = config.getSimpleValue("heapNewSize");
        if (!StringUtil.isEmpty(heapNewSize)) {
            validateHeapArg("heapNewSize", heapNewSize);
            properties.setProperty("set.heap_new", "-Xmn" + heapNewSize);
        }

        String threadStackSize = config.getSimpleValue("threadStackSize");
        if (!StringUtil.isEmpty(threadStackSize)) {
            validateIntegerArg("threadStackSize", threadStackSize);
            properties.setProperty("set.thread_stack_size", "-Xss" + threadStackSize + "k");
        }

        PropertySimple heapDumpOnOMMError = config.getSimple("heapDumpOnOOMError");
        if (heapDumpOnOMMError != null) {
            if (heapDumpOnOMMError.getBooleanValue()) {
                properties.setProperty("set.heap_dump_on_OOMError", "-XX:+HeapDumpOnOutOfMemoryError");
            } else {
                properties.setProperty("set.heap_dump_on_OOMError", "");
            }
        }

        String heapDumpDir = useForwardSlash(config.getSimpleValue("heapDumpDir"));
        if (!StringUtil.isEmpty(heapDumpDir)) {
            properties.setProperty("set.heap_dump_dir", "-XX:HeapDumpPath=" + heapDumpDir);
        }

        propertiesUpdater.update(properties);
    }
View Full Code Here

        deployer.updateFilePerms();
        deployer.updateStorageAuthConf(Sets.newHashSet("127.0.0.1", "127.0.0.2"));

        File confDir = new File(deploymentOptions.getBasedir(), "conf");
        File cassandraJvmPropsFile = new File(confDir, "cassandra-jvm.properties");
        PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate(cassandraJvmPropsFile.getAbsolutePath());
        Properties properties = propertiesUpdater.loadExistingProperties();

        String jvmOpts = properties.getProperty("JVM_OPTS");
        jvmOpts = jvmOpts.substring(0, jvmOpts.lastIndexOf("\""));
        jvmOpts = jvmOpts + " -Dcassandra.ring_delay_ms=2000\"";
        properties.setProperty("JVM_OPTS", jvmOpts);

        propertiesUpdater.update(properties);

        File binDir = new File(deploymentOptions.getBasedir(), "bin");
        SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();

        ProcessExecution processExecution = getProcessExecution(binDir);
View Full Code Here

            File propsFile2 = null;
            File runJar = null;
            try {
                propsFile1 = File.createTempFile("jboss1-", ".properties");

                PropertiesFileUpdate propsFile1Updater = new PropertiesFileUpdate(propsFile1.getPath());
                propsFile1Updater.update("prop1", "delta");
                propsFile1Updater.update("prop4", "epsilon");

                propsFile2 = File.createTempFile("jboss2-", ".properties");
                PropertiesFileUpdate propsFile2Updater = new PropertiesFileUpdate(propsFile1.getPath());
                propsFile2Updater.update("prop2", "zeta");
                propsFile2Updater.update("prop5", "eta");
            } catch (IOException e) {
                Assert.fail();
            }

            return new String[] { //
View Full Code Here

TOP

Related Classes of org.rhq.core.util.PropertiesFileUpdate

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.