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); } }