modules/common/cassandra-common/src/main/java/org/rhq/cassandra/DeploymentOptions.java | 47 ++++++++- modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java | 20 ++++ modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java | 2 modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 14 ++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java | 50 ++++++---- 5 files changed, 108 insertions(+), 25 deletions(-)
New commits: commit 01b12e00f66560e63f00487dccd79c3c7d33a317 Author: John Sanda jsanda@redhat.com Date: Fri Oct 26 08:06:59 2012 -0400
update start up logic to first look at system properties for cluster configuration
Since cluster configuration properties are now in rhq-server.properties they are made available as system properties. Now at start up we first look cluster config property values in system properties and then fall back to the values in cassandra.properties for defaults if system properties are not defined. Logic has also been added to only do the unmanaged deployment if it is an embedded cluster.
diff --git a/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/DeploymentOptions.java b/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/DeploymentOptions.java index 3aee5a3..e2c6edb 100644 --- a/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/DeploymentOptions.java +++ b/modules/common/cassandra-common/src/main/java/org/rhq/cassandra/DeploymentOptions.java @@ -25,13 +25,20 @@
package org.rhq.cassandra;
+import java.io.IOException; +import java.io.InputStream; import java.util.Properties;
+import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * @author John Sanda */ public class DeploymentOptions {
+ private final Log log = LogFactory.getLog(DeploymentOptions.class); + private String bundleFileName; private String bundleName; private String bundleVersion; @@ -42,17 +49,49 @@ public class DeploymentOptions { private String loggingLevel;
public DeploymentOptions() { + init(loadProperties()); + } + + private Properties loadProperties() { + InputStream stream = null; + try { + stream = getClass().getResourceAsStream("/cassandra.properties"); + Properties props = new Properties(); + props.load(stream); + + return props; + } catch (IOException e) { + throw new RuntimeException("Unable to create DeploymentOptions. An error occurred while loading " + + "cassandra.properties", e); + } finally { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + String msg = "An error occurred while closing input stream on cassandra.properties"; + log.info(msg, e); + } + } + } }
public DeploymentOptions(Properties properties) { + init(properties); + } + + private void init(Properties properties) { setBundleFileName(properties.getProperty("rhq.cassandra.bundle.filename")); setBundleName(properties.getProperty("rhq.cassandra.bundle.name")); setBundleVersion(properties.getProperty("rhq.cassandra.bundle.version")); - setClusterDir(properties.getProperty("rhq.cassandra.cluster.dir")); - setNumNodes(Integer.parseInt(properties.getProperty("rhq.cassandra.cluster.num-nodes"))); + setClusterDir(System.getProperty("rhq.cassandra.cluster.dir", + properties.getProperty("rhq.cassandra.cluster.dir"))); + setNumNodes(Integer.parseInt(System.getProperty("rhq.cassandra.cluster.num-nodes", + properties.getProperty("rhq.cassandra.cluster.num-nodes")))); setAutoDeploy(Boolean.valueOf(properties.getProperty("rhq.cassandra.cluster.auto-deploy"))); - setEmbedded(Boolean.valueOf(properties.getProperty("rhq.cassandra.cluster.is-embedded"))); - setLoggingLevel(properties.getProperty("rhq.cassandra.logging.level")); + setEmbedded(Boolean.valueOf(System.getProperty("rhq.cassandra.cluster.is-embedded", + properties.getProperty("rhq.cassandra.cluster.is-embedded")))); + setLoggingLevel(System.getProperty("rhq.cassandra.logging.level", + properties.getProperty("rhq.cassandra.logging.level"))); }
public String getBundleFileName() { diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java index 7a0fbaa..00660a2 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/CassandraClusterManagerBean.java @@ -47,8 +47,8 @@ import org.apache.commons.logging.LogFactory; import org.quartz.JobDataMap; import org.quartz.SchedulerException;
-import org.rhq.cassandra.CassandraException; import org.rhq.cassandra.BootstrapDeployer; +import org.rhq.cassandra.CassandraException; import org.rhq.cassandra.DeploymentOptions; import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.bundle.Bundle; @@ -64,13 +64,16 @@ import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceCategory; import org.rhq.core.domain.resource.group.ResourceGroup; import org.rhq.core.domain.util.PageList; +import org.rhq.core.util.PropertiesFileUpdate; import org.rhq.core.util.stream.StreamUtil; import org.rhq.enterprise.server.auth.SubjectManagerLocal; import org.rhq.enterprise.server.bundle.BundleManagerLocal; +import org.rhq.enterprise.server.core.CoreServerMBean; import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.resource.ResourceNotFoundException; import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal; import org.rhq.enterprise.server.scheduler.SchedulerLocal; +import org.rhq.enterprise.server.util.LookupUtil;
/** * @author John Sanda @@ -98,20 +101,12 @@ public class CassandraClusterManagerBean implements CassandraClusterManagerLocal @Override @TransactionAttribute(NEVER) public void installBundle() throws CassandraException { - Properties deploymentProps = null; - try { - deploymentProps = loadDeploymentProps(); - } catch (IOException e) { - String msg = "An error occurred while trying to load cassandra.properties. Cannot proceed with " + - "Cassandra bundle installation"; - logException(msg, e); - throw new CassandraException(msg, e); - } + DeploymentOptions deploymentOptions = new DeploymentOptions(); File deployBaseDir = getDeployBaseDir(); Subject overlord = subjectManager.getOverlord(); - String bundleName = deploymentProps.getProperty("rhq.cassandra.bundle.name"); - String bundleVersionString = deploymentProps.getProperty("rhq.cassandra.bundle.version"); - String bundleFileName = deploymentProps.getProperty("rhq.cassandra.bundle.filename"); + String bundleName = deploymentOptions.getBundleName(); + String bundleVersionString = deploymentOptions.getBundleVersion(); + String bundleFileName = deploymentOptions.getBundleFileName(); Bundle bundle = null; try { bundle = getBundle(overlord, bundleName); @@ -130,16 +125,37 @@ public class CassandraClusterManagerBean implements CassandraClusterManagerLocal throw new CassandraException(msg, e); }
- BootstrapDeployer deployer = new BootstrapDeployer(); - deployer.setDeploymentOptions(new DeploymentOptions(deploymentProps)); - deployer.deploy(); + String seeds; + if (deploymentOptions.isEmbedded()) { + BootstrapDeployer deployer = new BootstrapDeployer(); + deployer.setDeploymentOptions(deploymentOptions); + seeds = deployer.getCassandraHosts(); + + // need to save the seeds list back to rhq-server.properties. + CoreServerMBean coreServer = LookupUtil.getCoreServer(); + File installDir = coreServer.getInstallDir(); + File binDir = new File(installDir, "bin"); + File serverProperties = new File(binDir, "rhq-server.properties"); + PropertiesFileUpdate propsFile = new PropertiesFileUpdate(serverProperties.getAbsolutePath()); + + try { + propsFile.update("rhq.cassandra.cluster.seeds", seeds); + } catch (IOException e) { + log.warn("Failed to update rhq.cassandra.cluster.seeds property in " + serverProperties, e); + } + + deployer.deploy(); + + } else { + seeds = System.getProperty("rhq.cassandra.cluster.seeds"); + }
String jobTrigger = "CassandraClusterHeartBeatTrigger - " + UUID.randomUUID().toString(); String jobGroup = CassandraClusterHeartBeatJob.JOB_NAME + "Group";
JobDataMap jobDataMap = new JobDataMap(); jobDataMap.put(CassandraClusterHeartBeatJob.KEY_CONNECTION_TIMEOUT, "100"); - jobDataMap.put(CassandraClusterHeartBeatJob.KEY_CASSANDRA_HOSTS, deployer.getCassandraHosts()); + jobDataMap.put(CassandraClusterHeartBeatJob.KEY_CASSANDRA_HOSTS, seeds);
try { scheduler.scheduleRepeatingJob(CassandraClusterHeartBeatJob.JOB_NAME, jobGroup, jobDataMap,
commit 540462a1afac65efeaec68e07bf55b3c10419cd8 Author: John Sanda jsanda@redhat.com Date: Fri Oct 26 07:59:16 2012 -0400
Adding initial support to specify cassandra hosts during installation
A section, that currently has just a single field, has been added to the installer to allow the user to enter the hostnames where cassandra will run. Those hostnames are then persisted to rhq-server.properties.
diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java index 2dd4e4c..73383be 100644 --- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java +++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/Installer.java @@ -529,6 +529,25 @@ public class Installer implements EntryPoint { databaseForm.setFields(dbType, dbConnectionUrl, dbUsername, dbPassword, buttonSpacer, testConnectionButton, dbExistingSchemaOption);
+ final DynamicForm metricsDatabaseForm = new DynamicForm(); + metricsDatabaseForm.setAutoWidth(); + metricsDatabaseForm.setPadding(5); + metricsDatabaseForm.setCellPadding(5); + metricsDatabaseForm.setWrapItemTitles(false); + metricsDatabaseForm.setIsGroup(true); + metricsDatabaseForm.setGroupTitle("Metrics Database Settings"); + + TextItem hostNames = new TextItem(ServerProperties.PROP_CASSANDRA_CLUSTER_SEEDS, "Metrics Database Nodes"); + hostNames.setWidth(fieldWidth); + hostNames.addChangedHandler(new ChangedHandler() { + @Override + public void onChanged(ChangedEvent event) { + updateServerProperty(ServerProperties.PROP_CASSANDRA_CLUSTER_SEEDS, String.valueOf(event.getValue())); + } + }); + + metricsDatabaseForm.setFields(hostNames); + //////////////////////////////////////////////////////// // The Server Settings form
@@ -677,6 +696,7 @@ public class Installer implements EntryPoint { simpleForm.setHeight100(); simpleForm.setDefaultLayoutAlign(Alignment.CENTER); simpleForm.addMember(databaseForm); + simpleForm.addMember(metricsDatabaseForm); simpleForm.addMember(serverSettingsForm);
return simpleForm; diff --git a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java index 7a04a6a..81e2e6c 100644 --- a/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java +++ b/modules/enterprise/gui/installer/src/main/java/org/rhq/enterprise/gui/installer/client/shared/ServerProperties.java @@ -113,6 +113,8 @@ public class ServerProperties { public static final String PROP_MM_AT_START = "rhq.server.maintenance-mode-at-startup"; public static final String PROP_OPERATION_TIMEOUT = "rhq.server.operation-timeout";
+ public static final String PROP_CASSANDRA_CLUSTER_SEEDS = "rhq.cassandra.cluster.seeds"; + // this list contains all the properties that are to have boolean values (true | false) public static final Set<String> BOOLEAN_PROPERTIES; static { diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml index b1944a7..b23c0a4 100644 --- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml +++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml @@ -558,6 +558,12 @@ rhq.autoinstall.enabled=${rhq.autoinstall.enabled} rhq.autoinstall.database=auto rhq.autoinstall.public-endpoint-address=
+# Cassandra cluster configuration settings +# A comma-delimited list of hostnames on which Cassandra will run. Cassandra +# nodes use this list to discover other nodes and learn about the cluster +# topology. +rhq.cassandra.cluster.seeds= + </echo>
</target> @@ -585,14 +591,11 @@ rhq.autoinstall.public-endpoint-address= <copy todir="${project.build.outputDirectory}" verbose="true"> <fileset dir="src/main/dev-resources" /> </copy> - <echo>Putting a developer setting in rhq-server.properties to turn on/off strict agent update version checking</echo> - <echo file="${project.build.outputDirectory}/bin/rhq-server.properties" append="true">rhq.server.agent-update.nonstrict-version-check=true</echo> <loadproperties> <zipentry zipfile="${settings.localRepository}/org/rhq/rhq-cassandra-common/${project.version}/rhq-cassandra-common-${project.version}.jar" name="cassandra.properties"/> </loadproperties> <echo file="${project.build.outputDirectory}/bin/rhq-server.properties" append="true"> - # The following properties that begin with a prefix of rhq.cassandra are ONLY for # development/testing environments where an embedded cluster is used. These properties are # loaded from the cassandra.properties file in the rhq-cassandra-common module. Note that @@ -614,7 +617,10 @@ rhq.autoinstall.public-endpoint-address= # # The log4j logging level to use on each node. # rhq.cassandra.logging.level=${rhq.cassandra.logging.level} - </echo> + +</echo> + <echo>Putting a developer setting in rhq-server.properties to turn on/off strict agent update version checking</echo> + <echo file="${project.build.outputDirectory}/bin/rhq-server.properties" append="true">rhq.server.agent-update.nonstrict-version-check=true</echo> </target>
<!-- The prepare-release target must be run AFTER the resources:resources goal has executed. -->
rhq-commits@lists.fedorahosted.org