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);
  }
  public void createCluster() {
    if (log.isDebugEnabled()) {
      log.debug(
          "Installing embedded "
              + deploymentOptions.getNumNodes()
              + " node cluster to "
              + deploymentOptions.getClusterDir());
    } else {
      log.info("Installing embedded cluster");
    }

    File clusterDir = new File(deploymentOptions.getClusterDir());
    File installedMarker = new File(clusterDir, ".installed");

    if (installedMarker.exists()) {
      log.info("It appears that the cluster already exists in " + clusterDir);
      log.info("Skipping cluster creation.");
      getStorageClusterConfiguration();
    }
    FileUtil.purge(clusterDir, false);

    String seeds = collectionToString(calculateLocalIPAddresses(deploymentOptions.getNumNodes()));

    this.nodes = new String[deploymentOptions.getNumNodes()];
    this.jmxPorts = new int[deploymentOptions.getNumNodes()];
    this.cqlPort = deploymentOptions.getCqlPort();

    boolean useRemoteJMX = this.nodes.length > 1;

    for (int i = 0; i < deploymentOptions.getNumNodes(); ++i) {
      File basedir = new File(deploymentOptions.getClusterDir(), "node" + i);
      String address = getLocalIPAddress(i + 1);

      DeploymentOptionsFactory factory = new DeploymentOptionsFactory();
      DeploymentOptions nodeOptions = factory.newDeploymentOptions();
      nodeOptions.setSeeds(seeds);
      nodeOptions.setJmxPort(deploymentOptions.getJmxPort() + i);
      nodeOptions.setBasedir(basedir.getAbsolutePath());
      nodeOptions.setListenAddress(address);
      nodeOptions.setRpcAddress(address);
      nodeOptions.setCommitLogDir(new File(basedir, "commit_log").getAbsolutePath());
      nodeOptions.setDataDir(new File(basedir, "data").getAbsolutePath());
      nodeOptions.setSavedCachesDir(new File(basedir, "saved_caches").getAbsolutePath());

      nodeOptions.merge(deploymentOptions);
      try {
        nodeOptions.load();
        Deployer deployer = new Deployer();
        deployer.setDeploymentOptions(nodeOptions);

        deployer.unzipDistro();
        deployer.applyConfigChanges();
        deployer.updateFilePerms();
        deployer.updateStorageAuthConf(calculateLocalIPAddresses(deploymentOptions.getNumNodes()));

        if (useRemoteJMX) {
          File confDir = new File(nodeOptions.getBasedir(), "conf");
          File cassandraJvmPropsFile = new File(confDir, "cassandra-jvm.properties");
          PropertiesFileUpdate propertiesUpdater =
              new PropertiesFileUpdate(cassandraJvmPropsFile.getAbsolutePath());
          Properties properties = propertiesUpdater.loadExistingProperties();
          String jmxOpts =
              "\"-Djava.rmi.server.hostname="
                  + nodeOptions.getRpcAddress()
                  + " -Dcom.sun.management.jmxremote.port="
                  + nodeOptions.getJmxPort()
                  + " -Dcom.sun.management.jmxremote.rmi.port="
                  + nodeOptions.getJmxPort()
                  + " -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false \"";

          properties.setProperty("JMX_OPTS", jmxOpts);

          propertiesUpdater.update(properties);
        }

        this.nodes[i] = address;
        this.jmxPorts[i] = deploymentOptions.getJmxPort() + i;

        installedNodeDirs.add(basedir);
      } catch (Exception e) {
        log.error("Failed to install node at " + basedir);
        throw new RuntimeException("Failed to install node at " + basedir, e);
      }
    }
    try {
      FileUtil.writeFile(new ByteArrayInputStream(new byte[] {0}), installedMarker);
    } catch (IOException e) {
      log.warn("Failed to write installed file marker to " + installedMarker, e);
    }
  }