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); } return; }
Properties existingProps = loadExistingProperties(); !isFileLineSeparatorTerminated()); FileOutputStream fos = new FileOutputStream(file, true); try { Properties newProps = new Properties(); newProps.setProperty(key, value); update(newProps);
private void applyChangesToCassandraJvmProps(File confDir, DeploymentOptions deploymentOptions) throws DeploymentException { File jvmPropsFile = new File(confDir, "cassandra-jvm.properties"); try { log.info("Applying configuration changes to " + jvmPropsFile); PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate(jvmPropsFile.getAbsolutePath()); Properties properties = propertiesUpdater.loadExistingProperties(); properties.setProperty("heap_min", "-Xms" + deploymentOptions.getHeapSize()); properties.setProperty("heap_max", "-Xmx" + deploymentOptions.getHeapSize()); properties.setProperty("heap_new", "-Xmn" + deploymentOptions.getHeapNewSize()); properties.setProperty("thread_stack_size", "-Xss" + deploymentOptions.getStackSize()); properties.setProperty("jmx_port", deploymentOptions.getJmxPort().toString()); String javaVersion = System.getProperty("java.version"); // The check here is taken right from cassandra-env.sh if ((!isOpenJDK() || javaVersion.compareTo("1.6.0") > 0) || (javaVersion.equals("1.6.0") && getJavaPatchVersion() > 23)) { properties.put("java_agent", "-javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"); } propertiesUpdater.update(properties); } catch (IOException e) { log.error("An error occurred while updating " + jvmPropsFile, e); throw new DeploymentException("An error occurred while updating " + jvmPropsFile, e); } }
Properties existingProps = loadExistingProperties(); } else { String existingKey = line.substring(0, equalsSign); existingKey = trimString(existingKey, false, true); if (!propsToUpdate.containsKey(existingKey)) {
public void applyChangesToWindowsServiceWrapper(File deployDir) throws DeploymentException { File wrapperDir = new File(deployDir, "../bin/wrapper"); File wrapperEnvFile = new File(wrapperDir, "rhq-storage-wrapper.env"); try { log.info("Applying configuration changes to " + wrapperEnvFile); PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate(wrapperEnvFile.getAbsolutePath()); Properties wrapperEnvProps = propertiesUpdater.loadExistingProperties(); wrapperEnvProps.setProperty("set.heap_min", "-Xms" + deploymentOptions.getHeapSize()); wrapperEnvProps.setProperty("set.heap_max", "-Xmx" + deploymentOptions.getHeapSize()); wrapperEnvProps.setProperty("set.heap_new", "-Xmn" + deploymentOptions.getHeapNewSize()); wrapperEnvProps.setProperty("set.thread_stack_size", "-Xss" + deploymentOptions.getStackSize()); wrapperEnvProps.setProperty("set.jmx_port", deploymentOptions.getJmxPort().toString()); // This is always on by default, just set it literally wrapperEnvProps.setProperty("set.heap_dump_on_OOMError", "-XX:+HeapDumpOnOutOfMemoryError"); // This is always set to the bin directory initially wrapperEnvProps.setProperty("set.heap_dump_dir", "-XX:HeapDumpPath=" + useForwardSlash(new File(deployDir, "bin").getAbsolutePath())); propertiesUpdater.update(wrapperEnvProps); } catch (IOException e) { log.error("An error occurred while updating " + wrapperEnvFile, e); throw new DeploymentException("An error occurred while updating " + wrapperEnvFile, e); } }
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public void persistStorageProperty(String key, String value) { if (Boolean.getBoolean("running.itests-2")) { // When running itests-2, there is no server props file, so avoid logging a confusing exception return; } PropertiesFileUpdate updater = new PropertiesFileUpdate(getServerPropsFile().getAbsolutePath()); try { updater.update(key, value); } catch (IOException e) { // TODO should we propagate the exception? LOG.warn("Failed to persist property " + key + " due to unexpected I/O error", ThrowableUtil.getRootCause(e)); } }
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);