[rhq] 2 commits - modules/common modules/enterprise modules/plugins
by Jay Shaughnessy
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java | 44 ++-
modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.conf | 36 +-
modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.env | 24 +
modules/enterprise/server/appserver/src/main/dev-resources/bin/wrapper/rhq-storage-wrapper.inc | 6
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java | 60 ++++
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java | 18 -
modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java | 142 +++++++---
7 files changed, 258 insertions(+), 72 deletions(-)
New commits:
commit c6c9e50398ffb5fc6d297ceffc369975a56b3ef9
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Jul 22 14:09:52 2013 -0400
Add windows support storage install options and resource config update. Introduce
rhq-storage-wrapper.env to hold the configurable values (mimicing somewhat
cassandra-jvm.properties) and apply the values as token replacements in
rhq-storage-wrapper.conf.
Note that cassandra-jvm.properties is still kept up to date on windows and
can be used generically, as needed.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
index 6547043..60667cc 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
@@ -91,7 +91,14 @@ public class Deployer {
applyConfigChanges(confDir, "cassandra.yaml", tokens);
applyConfigChanges(confDir, "log4j-server.properties", tokens);
applyChangesToCassandraJvmProps(confDir, deploymentOptions);
-// applyConfigChanges(confDir, "cassandra-env.sh", tokens);
+
+ // For windows, update the service wrapper env. It may not ne necessary to have updated cassandra-jvm.properties
+ // as well as this file, but for now we'll update both, leaving the former as a dependably set file.
+ if (File.separatorChar == '\\') {
+ applyChangesToWindowsServiceWrapper(deployDir);
+ }
+
+ // applyConfigChanges(confDir, "cassandra-env.sh", tokens);
}
private void applyConfigChanges(File confDir, String fileName, Map<String, String> tokens)
@@ -109,8 +116,8 @@ public class Deployer {
rhqFile.delete();
} catch (IOException e) {
log.error("An unexpected error occurred while apply configuration changes to " + filteredFile, e);
- throw new DeploymentException("An unexpected error occurred while apply configuration changes to " +
- filteredFile, e);
+ throw new DeploymentException("An unexpected error occurred while apply configuration changes to "
+ + filteredFile, e);
}
}
@@ -132,8 +139,8 @@ public class Deployer {
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)) {
+ 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");
}
@@ -165,6 +172,29 @@ public class Deployer {
return Integer.parseInt(javaVersion.substring(startIndex + 1, javaVersion.length()));
}
+ 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());
+
+ 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);
+ }
+ }
+
public void updateFilePerms() {
File deployDir = new File(deploymentOptions.getBasedir());
File binDir = new File(deployDir, "bin");
@@ -187,8 +217,8 @@ public class Deployer {
try {
authFile.delete();
- StreamUtil.copy(new StringReader(StringUtil.collectionToString(addresses, "\n")),
- new FileWriter(authFile), true);
+ StreamUtil.copy(new StringReader(StringUtil.collectionToString(addresses, "\n")), new FileWriter(authFile),
+ true);
} catch (IOException e) {
throw new RuntimeException("Failed to update " + authFile);
}
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.conf b/modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.conf
index 14f2ff1..de83364 100644
--- a/modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.conf
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.conf
@@ -66,23 +66,25 @@ wrapper.app.parameter.3="-Dcassandra-foreground=yes"
# Additional JVM parameters (quotes ARE needed)
wrapper.java.additional.1="-ea"
wrapper.java.additional.2="-javaagent:"%RHQ_STORAGE_HOME%\lib\jamm-0.2.5.jar""
-wrapper.java.additional.3="-Xms1G"
-wrapper.java.additional.4="-Xmx1G"
-wrapper.java.additional.5="-XX:+HeapDumpOnOutOfMemoryError"
-wrapper.java.additional.6="-XX:+UseParNewGC"
-wrapper.java.additional.7="-XX:+UseConcMarkSweepGC"
-wrapper.java.additional.8="-XX:+CMSParallelRemarkEnabled"
-wrapper.java.additional.9="-XX:SurvivorRatio=8"
-wrapper.java.additional.10="-XX:MaxTenuringThreshold=1"
-wrapper.java.additional.11="-XX:CMSInitiatingOccupancyFraction=75"
-wrapper.java.additional.12="-XX:+UseCMSInitiatingOccupancyOnly"
-wrapper.java.additional.13="-Dcom.sun.management.jmxremote.port=7299"
-wrapper.java.additional.14="-Dcom.sun.management.jmxremote.ssl=false"
-wrapper.java.additional.15="-Dcom.sun.management.jmxremote.authenticate=false"
-wrapper.java.additional.16="-Dlog4j.configuration=log4j-server.properties"
-wrapper.java.additional.17="-Dlog4j.defaultInitOverride=true"
-
-# We want to make sure the Storage Node starts in the casandra bin directory
+wrapper.java.additional.3="%heap_min%"
+wrapper.java.additional.4="%heap_max%"
+wrapper.java.additional.5="%heap_new%"
+wrapper.java.additional.6="%heap_dump_on_OOMError%"
+wrapper.java.additional.7="%heap_dump_dir%"
+wrapper.java.additional.8="-XX:+UseConcMarkSweepGC"
+wrapper.java.additional.9="-XX:+CMSParallelRemarkEnabled"
+wrapper.java.additional.10="-XX:SurvivorRatio=8"
+wrapper.java.additional.11="-XX:MaxTenuringThreshold=1"
+wrapper.java.additional.12="-XX:CMSInitiatingOccupancyFraction=75"
+wrapper.java.additional.13="-XX:+UseCMSInitiatingOccupancyOnly"
+wrapper.java.additional.14="-XX:+UseParNewGC"
+wrapper.java.additional.15="-Dcom.sun.management.jmxremote.port=%jmx_port%"
+wrapper.java.additional.16="-Dcom.sun.management.jmxremote.ssl=false"
+wrapper.java.additional.17="-Dcom.sun.management.jmxremote.authenticate=false"
+wrapper.java.additional.18="-Dlog4j.configuration=log4j-server.properties"
+wrapper.java.additional.19="-Dlog4j.defaultInitOverride=true"
+
+# We want to make sure the Storage Node starts in the cassandra bin directory
wrapper.working.dir=%RHQ_STORAGE_HOME%/bin
#*****************************************************************************
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.env b/modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.env
new file mode 100644
index 0000000..1441e0a
--- /dev/null
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.env
@@ -0,0 +1,24 @@
+#*****************************************************************************
+# RHQ Storage Node Java Service Wrapper Environment Settings File
+#
+# This file specifies a set of environment variables that will be
+# applied to the Storage Node JVM.
+#
+# THIS FILE SHOULD NOT BE EDITED!
+#
+# This file represents the values managed as RHQ Storage Node resource
+# configuration values. Or, set by the installer.
+#
+#*****************************************************************************
+
+set.jmx_port=7299
+
+set.heap_min=-Xms512M
+set.heap_max=-Xms512M
+set.heap_new=-Xmn128M
+
+set.thread_stack_size=-Xss180k
+
+set.heap_dump_on_OOMError=-XX:+HeapDumpOnOutOfMemoryError
+
+set.heap_dump_dir=
diff --git a/modules/enterprise/server/appserver/src/main/dev-resources/bin/wrapper/rhq-storage-wrapper.inc b/modules/enterprise/server/appserver/src/main/dev-resources/bin/wrapper/rhq-storage-wrapper.inc
index ee0d448..6941358 100644
--- a/modules/enterprise/server/appserver/src/main/dev-resources/bin/wrapper/rhq-storage-wrapper.inc
+++ b/modules/enterprise/server/appserver/src/main/dev-resources/bin/wrapper/rhq-storage-wrapper.inc
@@ -4,11 +4,11 @@
#
# override and lower the initial memory profile
-wrapper.java.additional.18=-Xms128M
-wrapper.java.additional.19=-Xmx256M
+wrapper.java.additional.20=-Xms128M
+wrapper.java.additional.21=-Xmx256M
# enable remote debugging
-#wrapper.java.additional.20=-agentlib:jdwp=transport=dt_socket,address=8788,server=y,suspend=n
+#wrapper.java.additional.22=-agentlib:jdwp=transport=dt_socket,address=8788,server=y,suspend=n
# disable JVM startup timeout
wrapper.startup.timeout=0
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
index 8d1771d..1667877 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeConfigDelegate.java
@@ -19,10 +19,17 @@ import org.rhq.core.util.StringUtil;
public class StorageNodeConfigDelegate implements ConfigurationFacet {
private File jvmOptsFile;
+ private File wrapperEnvFile;
public StorageNodeConfigDelegate(File basedir) {
File confDir = new File(basedir, "conf");
jvmOptsFile = new File(confDir, "cassandra-jvm.properties");
+
+ // for windows, config props also get propagated to the wrapper env
+ if (isWindows()) {
+ File wrapperDir = new File(basedir, "../bin/wrapper");
+ wrapperEnvFile = new File(wrapperDir, "rhq-storage-wrapper.env");
+ }
}
@Override
@@ -56,6 +63,16 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
return config;
}
+ /**
+ * Ensure that the path uses only forward slash.
+ * @param path
+ * @return forward-slashed path, or null if path is null
+ */
+ private static String useForwardSlash(String path) {
+
+ return (null != path) ? path.replace('\\', '/') : null;
+ }
+
private String getHeapMinProp(Properties properties) {
String value = properties.getProperty("heap_min");
@@ -115,47 +132,14 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport) {
try {
- PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate(jvmOptsFile.getAbsolutePath());
- Properties properties = propertiesUpdater.loadExistingProperties();
-
Configuration config = configurationUpdateReport.getConfiguration();
- String maxHeapSize = config.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 = config.getSimpleValue("heapNewSize");
- if (!StringUtil.isEmpty(heapNewSize)) {
- validateHeapArg("heapNewSize", heapNewSize);
- properties.setProperty("heap_new", "-Xmn" + heapNewSize);
- }
+ updateCassandraJvmProps(config);
- String threadStackSize = config.getSimpleValue("threadStackSize");
- if (!StringUtil.isEmpty(threadStackSize)) {
- validateStackArg(threadStackSize);
- properties.setProperty("thread_stack_size", "-Xss" + threadStackSize + "k");
+ if (isWindows()) {
+ updateWrapperEnv(config);
}
- PropertySimple heapDumpOnOMMError = config.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 = config.getSimpleValue("heapDumpDir");
- if (!StringUtil.isEmpty(heapDumpDir)) {
- properties.setProperty("heap_dump_dir", heapDumpDir);
- }
-
- propertiesUpdater.update(properties);
-
configurationUpdateReport.setStatus(ConfigurationUpdateStatus.SUCCESS);
} catch (IllegalArgumentException e) {
configurationUpdateReport.setErrorMessage("No configuration update was applied: " + e.getMessage());
@@ -164,6 +148,88 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
}
}
+ private void updateCassandraJvmProps(Configuration config) throws IOException {
+ PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate(jvmOptsFile.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("heap_min", "-Xms" + maxHeapSize);
+ properties.setProperty("heap_max", "-Xmx" + maxHeapSize);
+ }
+
+ String heapNewSize = config.getSimpleValue("heapNewSize");
+ if (!StringUtil.isEmpty(heapNewSize)) {
+ validateHeapArg("heapNewSize", heapNewSize);
+ properties.setProperty("heap_new", "-Xmn" + heapNewSize);
+ }
+
+ String threadStackSize = config.getSimpleValue("threadStackSize");
+ if (!StringUtil.isEmpty(threadStackSize)) {
+ validateStackArg(threadStackSize);
+ properties.setProperty("thread_stack_size", "-Xss" + threadStackSize + "k");
+ }
+
+ PropertySimple heapDumpOnOMMError = config.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(config.getSimpleValue("heapDumpDir"));
+ if (!StringUtil.isEmpty(heapDumpDir)) {
+ properties.setProperty("heap_dump_dir", heapDumpDir);
+ }
+
+ propertiesUpdater.update(properties);
+ }
+
+ 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)) {
+ validateStackArg(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", heapDumpDir);
+ }
+
+ propertiesUpdater.update(properties);
+ }
+
private void validateHeapArg(String name, String value) {
if (value.length() < 2) {
throw new IllegalArgumentException(value + " is not a legal value for the property [" + name + "]");
@@ -189,4 +255,8 @@ public class StorageNodeConfigDelegate implements ConfigurationFacet {
throw new IllegalArgumentException(value + " is not a legal value for the property [threadStackSize]");
}
}
+
+ private boolean isWindows() {
+ return File.separatorChar == '\\';
+ }
}
commit 969ea38e7254d61903c699380bd066d6cad3e85e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Jul 22 14:06:39 2013 -0400
When recreating win services make sure they get started appropriately.
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java
index 8c885b0..61c8a9c 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/AbstractInstall.java
@@ -36,12 +36,16 @@ import java.util.Properties;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.ExecuteException;
import org.apache.commons.exec.Executor;
import org.apache.commons.exec.PumpStreamHandler;
+
import org.jboss.as.controller.client.ModelControllerClient;
+
import org.rhq.common.jbossas.client.controller.DeploymentJBossASClient;
import org.rhq.common.jbossas.client.controller.MCCHelper;
import org.rhq.server.control.ControlCommand;
+import org.rhq.server.control.RHQControlException;
/**
* Common code for commands that perform installs. Basically shared code for Install and Upgrade commands.
@@ -55,7 +59,7 @@ public abstract class AbstractInstall extends ControlCommand {
protected final String STORAGE_CONFIG_PROP = "rhqctl.install.storage-config";
- protected void installWindowsService(File workingDir, String batFile) throws Exception {
+ protected void installWindowsService(File workingDir, String batFile, boolean start) throws Exception {
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(workingDir);
executor.setStreamHandler(new PumpStreamHandler());
@@ -69,6 +73,11 @@ public abstract class AbstractInstall extends ControlCommand {
commandLine = getCommandLine(batFile, "install");
executor.execute(commandLine);
+
+ if (start) {
+ commandLine = getCommandLine(batFile, "start");
+ executor.execute(commandLine);
+ }
}
protected void validateCustomStorageDataDirectories(CommandLine commandLine, List<String> errors) {
@@ -100,6 +109,54 @@ public abstract class AbstractInstall extends ControlCommand {
}
}
+ protected void waitForProcessToStop(String pid) throws Exception {
+
+ if (isWindows() || pid == null) {
+ // For the moment we have no better way to just wait some time
+ Thread.sleep(10 * 1000L);
+ } else {
+ int tries = 5;
+ while (tries > 0) {
+ log.debug(".");
+ if (!isUnixPidRunning(pid)) {
+ break;
+ }
+ Thread.sleep(2 * 1000L);
+ tries--;
+ }
+ if (tries == 0) {
+ throw new RHQControlException("Process [" + pid
+ + "] did not finish yet. Terminate it manually and retry.");
+ }
+ }
+
+ }
+
+ protected boolean isUnixPidRunning(String pid) {
+
+ Executor executor = new DefaultExecutor();
+ executor.setWorkingDirectory(getBinDir());
+ executor.setStreamHandler(new PumpStreamHandler());
+ org.apache.commons.exec.CommandLine commandLine;
+
+ commandLine = new org.apache.commons.exec.CommandLine("/bin/kill").addArgument("-0").addArgument(pid);
+
+ try {
+ int code = executor.execute(commandLine);
+ if (code != 0) {
+ return false;
+ }
+ } catch (ExecuteException ee) {
+ if (ee.getExitValue() == 1) {
+ // return code 1 means process does not exist
+ return false;
+ }
+ } catch (IOException e) {
+ log.error("Checking for running process failed: " + e.getMessage());
+ }
+ return true;
+ }
+
protected void waitForRHQServerToInitialize() throws Exception {
try {
final long messageInterval = 30000L;
@@ -287,7 +344,6 @@ public abstract class AbstractInstall extends ControlCommand {
log.debug("Stopping RHQ server...");
-
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(serverBinDir);
executor.setStreamHandler(new PumpStreamHandler());
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
index bb6aa40..0808db2 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
@@ -142,7 +142,7 @@ public class Install extends AbstractInstall {
if (!isStorageInstalled()) {
installStorageNode(getStorageBasedir(), commandLine);
} else if (isWindows()) {
- installWindowsService(getBinDir(), "rhq-storage");
+ installWindowsService(getBinDir(), "rhq-storage", true);
}
if (!isServerInstalled()) {
@@ -150,7 +150,7 @@ public class Install extends AbstractInstall {
runRHQServerInstaller();
waitForRHQServerToInitialize();
} else if (isWindows()) {
- installWindowsService(getBinDir(), "rhq-server");
+ installWindowsService(getBinDir(), "rhq-server", true);
}
if (!isAgentInstalled()) {
@@ -158,13 +158,15 @@ public class Install extends AbstractInstall {
File agentBasedir = getAgentBasedir();
installAgent(agentBasedir);
configureAgent(agentBasedir, commandLine);
- if (Boolean.parseBoolean(commandLine.getOptionValue(AGENT_AUTOSTART_OPTION, "true"))) {
+ boolean start = Boolean.parseBoolean(commandLine.getOptionValue(AGENT_AUTOSTART_OPTION, "true"));
+ if (start) {
startAgent(agentBasedir, true);
} else {
log.info("The agent was installed but was told not to start automatically.");
}
} else if (isWindows()) {
- installWindowsService(new File(getAgentBasedir(), "bin"), "rhq-agent-wrapper");
+ boolean start = Boolean.parseBoolean(commandLine.getOptionValue(AGENT_AUTOSTART_OPTION, "true"));
+ installWindowsService(new File(getAgentBasedir(), "bin"), "rhq-agent-wrapper", start);
}
} else {
@@ -173,7 +175,7 @@ public class Install extends AbstractInstall {
log.info("The RHQ storage node is already installed in " + new File(getBaseDir(), "storage"));
if (isWindows()) {
- installWindowsService(getBinDir(), "rhq-storage");
+ installWindowsService(getBinDir(), "rhq-storage", true);
} else {
log.info("Skipping storage node installation.");
}
@@ -200,7 +202,7 @@ public class Install extends AbstractInstall {
log.warn("The RHQ server is already installed.");
if (isWindows()) {
- installWindowsService(getBinDir(), "rhq-server");
+ installWindowsService(getBinDir(), "rhq-server", true);
} else {
log.info("Skipping server installation.");
}
@@ -217,8 +219,10 @@ public class Install extends AbstractInstall {
if (isAgentInstalled() && !commandLine.hasOption(STORAGE_OPTION)) {
log.info("The RHQ agent is already installed in [" + getAgentBasedir() + "]");
+ boolean start = Boolean
+ .parseBoolean(commandLine.getOptionValue(AGENT_AUTOSTART_OPTION, "true"));
if (isWindows()) {
- installWindowsService(new File(getAgentBasedir(), "bin"), "rhq-agent-wrapper");
+ installWindowsService(new File(getAgentBasedir(), "bin"), "rhq-agent-wrapper", start);
} else {
log.info("Skipping agent installation.");
}
10 years, 10 months
[rhq] 5 commits - modules/core modules/enterprise modules/plugins
by snegrea
modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java | 34 ++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 17 +-
modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java | 45 ++++--
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java | 68 ++++++----
modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml | 6
modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java | 17 ++
6 files changed, 144 insertions(+), 43 deletions(-)
New commits:
commit e1461de493712c30e454fa51f946a72cadf2c257
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 07:47:00 2013 -0500
Fix merge rebase issue.
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 4744e96..3b0aa5b 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -41,8 +41,8 @@ import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
import org.mc4j.ems.connection.bean.operation.EmsOperation;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -116,7 +116,8 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
if (!configurationUpdate.getStatus().equals(ConfigurationUpdateStatus.SUCCESS)) {
result.setErrorMessage(configurationUpdate.getErrorMessage());
-
+ }
+
return result;
}
commit 642421966cbea990df8cf0593e1fb82a4c1a98a8
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 07:40:53 2013 -0500
Attempt to improve the operation trigger for updates on the storage node configuration.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index c77e229..c2a7b46 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -64,6 +64,7 @@ import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
+import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -101,8 +102,8 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
private static final String RHQ_STORAGE_JMX_PORT_PROPERTY = "jmxPort";
private static final String RHQ_STORAGE_ADDRESS_PROPERTY = "host";
- private static final int OPERATION_QUERY_TIMEOUT = 1000;
- private static final int MAX_ITERATIONS = 5;
+ private static final int OPERATION_QUERY_TIMEOUT = 20000;
+ private static final int MAX_ITERATIONS = 6;
private static final String UPDATE_CONFIGURATION_OPERATION = "updateConfiguration";
private static final String RESTART_OPERATION = "restart";
@@ -636,8 +637,16 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
//scheduling the operation
long operationStartTime = System.currentTimeMillis();
- operationManager.scheduleResourceOperation(subject, storageNodeResource.getId(), operationToRun, 0, 0, 0, 0,
- parameters, "Run by StorageNodeManagerBean");
+
+ ResourceOperationSchedule newSchedule = new ResourceOperationSchedule();
+ newSchedule.setJobTrigger(JobTrigger.createNowTrigger());
+ newSchedule.setResource(storageNodeResource);
+ newSchedule.setOperationName(operationToRun);
+ newSchedule.setDescription("Run by StorageNodeManagerBean");
+ newSchedule.setParameters(parameters);
+
+ operationManager.scheduleResourceOperation(subject, newSchedule);
+ entityManager.flush();
//waiting for the operation result then return it
int iteration = 0;
commit a7e279884e1a7ee6c0782c1d5e79a27dcff26b76
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 07:39:55 2013 -0500
Implement the storage node operation for updating jvm options.
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 006dd26..4744e96 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -42,6 +42,7 @@ import org.mc4j.ems.connection.bean.operation.EmsOperation;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -102,7 +103,20 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
private OperationResult updateConfiguration(Configuration params) {
OperationResult result = new OperationResult("Configuration updated.");
- //TODO: implement updates to various sub-resources here
+
+ //update storage node jvm settings
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("minHeapSize", params.getSimpleValue("heapSize")));
+ config.put(new PropertySimple("maxHeapSize", params.getSimpleValue("heapSize")));
+ config.put(new PropertySimple("heapNewSize", params.getSimpleValue("heapNewSize")));
+ config.put(new PropertySimple("threadStackSize", params.getSimpleValue("threadStackSize")));
+
+ ConfigurationUpdateReport configurationUpdate = new ConfigurationUpdateReport(config);
+ this.updateResourceConfiguration(configurationUpdate);
+
+ if (!configurationUpdate.getStatus().equals(ConfigurationUpdateStatus.SUCCESS)) {
+ result.setErrorMessage(configurationUpdate.getErrorMessage());
+
return result;
}
commit 26a7f7f476e03367d52e9e229f2e583c789e7bec
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 07:38:15 2013 -0500
Add two more properties to the list of configurable properties for the storaga node. The new properties are heap new size and thread stack size.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java
index e2c64f9..32d8ab3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeConfigurationComposite.java
@@ -33,6 +33,8 @@ public class StorageNodeConfigurationComposite implements Serializable {
private StorageNode storageNode;
private int jmxPort;
private String heapSize;
+ private String threadStackSize;
+ private String heapNewSize;
public StorageNodeConfigurationComposite() {
// GWT needs this
@@ -85,14 +87,44 @@ public class StorageNodeConfigurationComposite implements Serializable {
this.heapSize = heapSize;
}
+ /**
+ * @return the threadStackSize
+ */
+ public String getThreadStackSize() {
+ return threadStackSize;
+ }
+
+ /**
+ * @param threadStackSize the threadStackSize to set
+ */
+ public void setThreadStackSize(String threadStackSize) {
+ this.threadStackSize = threadStackSize;
+ }
+
+ /**
+ * @return the heapNewSize
+ */
+ public String getHeapNewSize() {
+ return heapNewSize;
+ }
+
+ /**
+ * @param heapNewSize the heapNewSize to set
+ */
+ public void setHeapNewSize(String heapNewSize) {
+ this.heapNewSize = heapNewSize;
+ }
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("storageNode.addresss=").append(storageNode.getAddress()).append(", ");
+ builder.append("jmxPort=").append(jmxPort).append(",");
builder.append("heapSize=").append(heapSize).append(", ");
- builder.append("jmxPort=").append(jmxPort).append("");
+ builder.append("heapNewSize=").append(heapSize).append(", ");
+ builder.append("threadStackSize=").append(threadStackSize).append("");
return builder.toString();
}
}
commit a0285ac83b5b673dab0582f9ff52baaa746fd8cd
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Mon Jul 22 07:37:10 2013 -0500
Update the set of calculated metrics for Cassandra to incorporate latest feedback. There are three metrics now: total system used space percentage, data file disk space used percentage, and free to data disk space ratio.
Also, update the alert definition for disk space to monitor all three metrics.
diff --git a/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java b/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
index 8995ec0..37d10a8 100644
--- a/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
+++ b/modules/enterprise/server/plugins/alertdef-rhq/src/main/java/org/rhq/enterprise/server/plugins/alertdef/AlertDefinitionServerPluginComponent.java
@@ -61,7 +61,9 @@ public class AlertDefinitionServerPluginComponent implements ServerPluginCompone
private final Log log = LogFactory.getLog(AlertDefinitionServerPluginComponent.class);
- private static final String PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.PartitionDiskUsedPercentage";
+ private static final String DATA_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.DataDiskUsedPercentage";
+ private static final String TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.TotalDiskUsedPercentage";
+ private static final String FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME = "Calculated.FreeDiskToDataSizeRatio";
static private final List<InjectedTemplate> injectedTemplates;
static private final InjectedTemplate storageNodeHighHeapTemplate;
@@ -297,23 +299,42 @@ public class AlertDefinitionServerPluginComponent implements ServerPluginCompone
newTemplate.setRecoveryId(0);
newTemplate.setEnabled(true);
- AlertCondition ac = new AlertCondition();
- ac.setCategory(AlertConditionCategory.THRESHOLD);
- ac.setComparator(">");
- ac.setThreshold(0.5D);
+
+ AlertCondition dataDiskUsedAlertCondition = new AlertCondition();
+ dataDiskUsedAlertCondition.setCategory(AlertConditionCategory.THRESHOLD);
+ dataDiskUsedAlertCondition.setComparator(">");
+ dataDiskUsedAlertCondition.setThreshold(0.5D);
+
+ AlertCondition totalDiskUsedAlertCondition = new AlertCondition();
+ totalDiskUsedAlertCondition.setCategory(AlertConditionCategory.THRESHOLD);
+ totalDiskUsedAlertCondition.setComparator(">");
+ totalDiskUsedAlertCondition.setThreshold(0.75D);
+
+ AlertCondition freeSpaveDataRatioAlertCondition = new AlertCondition();
+ freeSpaveDataRatioAlertCondition.setCategory(AlertConditionCategory.THRESHOLD);
+ freeSpaveDataRatioAlertCondition.setComparator("<");
+ freeSpaveDataRatioAlertCondition.setThreshold(1.5D);
List<Integer> measurementDefinitionIds = new ArrayList<Integer>(1);
for (MeasurementDefinition d : resourceType.getMetricDefinitions()) {
- if (PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME.equals(d.getName())) {
+ if (DATA_DISK_USED_PERCENTAGE_METRIC_NAME.equals(d.getName())) {
measurementDefinitionIds.add(d.getId());
- ac.setMeasurementDefinition(d);
- ac.setName(d.getDisplayName());
+ dataDiskUsedAlertCondition.setMeasurementDefinition(d);
+ dataDiskUsedAlertCondition.setName(d.getDisplayName());
+ } else if (TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME.equals(d.getName())) {
+ measurementDefinitionIds.add(d.getId());
+ totalDiskUsedAlertCondition.setMeasurementDefinition(d);
+ totalDiskUsedAlertCondition.setName(d.getDisplayName());
+ } else if (FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME.equals(d.getName())) {
+ measurementDefinitionIds.add(d.getId());
+ freeSpaveDataRatioAlertCondition.setMeasurementDefinition(d);
+ freeSpaveDataRatioAlertCondition.setName(d.getDisplayName());
}
}
- assert null != ac.getMeasurementDefinition() : "Did not find expected measurement definition "
- + PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME + " for "
- + resourceType;
- newTemplate.addCondition(ac);
+
+ newTemplate.addCondition(dataDiskUsedAlertCondition);
+ newTemplate.addCondition(totalDiskUsedAlertCondition);
+ newTemplate.addCondition(freeSpaveDataRatioAlertCondition);
AlertDampening dampener = new AlertDampening(AlertDampening.Category.PARTIAL_COUNT);
dampener.setPeriod(15);
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
index e5a2283..76ce2b2 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
@@ -58,7 +58,9 @@ import org.rhq.plugins.jmx.JMXComponent;
public class StorageServiceComponent extends ComplexConfigurationResourceComponent {
private static final String OWNERSHIP_METRIC_NAME = "Ownership";
- private static final String PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.PartitionDiskUsedPercentage";
+ private static final String DATA_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.DataDiskUsedPercentage";
+ private static final String TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME = "Calculated.TotalDiskUsedPercentage";
+ private static final String FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME = "Calculated.FreeDiskToDataSizeRatio";
private static final String DATA_FILE_LOCATIONS_NAME = "AllDataFileLocations";
private static final String LOAD_NAME = "Load";
@@ -156,6 +158,22 @@ public class StorageServiceComponent extends ComplexConfigurationResourceCompone
@Override
protected void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests, EmsBean bean) {
super.getValues(report, requests, bean);
+
+ EmsAttribute loadAttribute = bean.getAttribute(LOAD_NAME);
+ Object loadValue = loadAttribute.refresh();
+
+ EmsAttribute dataFileLocationAttribute = bean.getAttribute(DATA_FILE_LOCATIONS_NAME);
+ Object dataFileLocationValue = dataFileLocationAttribute.refresh();
+
+ double load = 0;
+ if (loadValue != null && dataFileLocationValue != null && dataFileLocationValue instanceof String[]) {
+ //Please visit for details: https://issues.apache.org/jira/browse/CASSANDRA-2749
+ //The average usage of all partitions with the data will be reported.
+ //Cassandra selects the partition with most free space for SStable flush and compaction.
+ load = Double.parseDouble(loadValue.toString());
+ load = load / 1024d; //transform in MB
+ }
+
for (MeasurementScheduleRequest request : requests) {
if (OWNERSHIP_METRIC_NAME.equals(request.getName()) && host != null) {
EmsAttribute attribute = bean.getAttribute(OWNERSHIP_METRIC_NAME);
@@ -179,49 +197,53 @@ public class StorageServiceComponent extends ComplexConfigurationResourceCompone
report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
}
break;
- } else if (PARTITION_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())) {
-
-
- EmsAttribute loadAttribute = bean.getAttribute(LOAD_NAME);
- Object loadValue = loadAttribute.refresh();
-
- EmsAttribute dataFileLocationAttribute = bean.getAttribute(DATA_FILE_LOCATIONS_NAME);
- Object dataFileLocationValue = dataFileLocationAttribute.refresh();
-
- if (loadValue != null && dataFileLocationValue != null && dataFileLocationValue instanceof String[]) {
- //Please visit for details: https://issues.apache.org/jira/browse/CASSANDRA-2749
- //The average usage of all partitions with the data will be reported.
- //Cassandra selects the partition with most free space for SStable flush and compaction.
- double load = Double.parseDouble(loadValue.toString());
-
- report.addData(new MeasurementDataNumeric(request, getPartitionDiskUsedPercentage(load,
- (String[]) dataFileLocationValue)));
- }
+ } else if (DATA_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())
+ || TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())
+ || FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME.equals(request.getName())) {
+ double metricValue = getDiskUsageMetric(request, load, (String[]) dataFileLocationValue);
+ report.addData(new MeasurementDataNumeric(request, metricValue));
}
}
}
- private double getPartitionDiskUsedPercentage(double dataSize, String[] paths) {
+ private double getDiskUsageMetric(MeasurementScheduleRequest request, double dataSize, String[] paths) {
List<String> visitedMountPoints = new ArrayList<String>();
long totalDiskSpace = 0;
+ long totalFreeDiskSpace = 0;
+ long totalUsedDiskSpace = 0;
for (String path : paths) {
try {
FileSystemInfo fileSystemInfo = this.getResourceContext().getSystemInformation().getFileSystem(path);
if (!visitedMountPoints.contains(fileSystemInfo.getMountPoint())) {
visitedMountPoints.add(fileSystemInfo.getMountPoint());
+
+ //contrary to Sigar documentation this values are reported in MB and not bytes
totalDiskSpace += fileSystemInfo.getFileSystemUsage().getTotal();
+ totalFreeDiskSpace += fileSystemInfo.getFileSystemUsage().getFree();
+ totalUsedDiskSpace += fileSystemInfo.getFileSystemUsage().getUsed();
}
} catch (Exception e) {
log.error("Unable to determine file system usage information for data file location " + path, e);
}
}
+ double metricValue = 0;
+
+
if (totalDiskSpace != 0) {
- double rawPercentage = dataSize / ((double) totalDiskSpace);
- return Math.round(rawPercentage * 100.0) / 100.0;
+ double rawPercentage = 0;
+ if (DATA_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())) {
+ rawPercentage = dataSize / ((double) totalDiskSpace);
+ } else if (TOTAL_DISK_USED_PERCENTAGE_METRIC_NAME.equals(request.getName())) {
+ rawPercentage = ((double) totalUsedDiskSpace) / ((double) totalDiskSpace);
+ } else if (FREE_DISK_TO_DATA_SIZE_RATIO_METRIC_NAME.equals(request.getName())) {
+ rawPercentage = ((double) totalFreeDiskSpace) / (double) dataSize;
+ }
+
+ metricValue = Math.round(rawPercentage * 100d) / 100d;
}
- return 0;
+ return metricValue;
}
}
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index a1b3412..5bbebed 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -186,9 +186,11 @@
</parameters>
</operation>
+ <metric property="Calculated.DataDiskUsedPercentage" displayName="Data File Disk Used Percentage" dataType="measurement" units="percentage" displayType="summary" description="Percentage of disk space used by Cassandra data files. The aggregate accross all the partitions will be reported if multiple data locations are specified. This is a calculated metric derived from system and Cassandra runtime information."/>
+ <metric property="Calculated.TotalDiskUsedPercentage" displayName="Total Disk Used Percentage" dataType="measurement" units="percentage" displayType="summary" description="Percentage of total disk space used. The metric acounts overall disk usage (including system files), not just disk space used by Cassandra. The aggregate accross all the partitions will be reported if multiple data locations are specified. This is a calculated metric derived from system and Cassandra runtime information."/>
+ <metric property="Calculated.FreeDiskToDataSizeRatio" displayName="Free Disk to Data Size Ratio" dataType="measurement" displayType="summary" description="Ratio of (Amount of Free Disk)/(Data File Size). A value below 1 is not recommended since a compaction or repair process could double the amount of disk space used by data files. The aggregate accross all the partitions will be reported if multiple data locations are specified. This is a calculated metric derived from system and Cassandra runtime information."/>
+
<metric property="CurrentGenerationNumber" dataType="trait" displayType="summary" description="Current generation number"/>
- <metric property="Calculated.PartitionDiskUsedPercentage" displayName="Data File Disk Used Percentage" dataType="measurement" units="percentage" displayType="summary" description="Percentage of disk space used by the data files. If multiple data locations are specified then this will report
- the average utilization accross all the partitions that contain data files."/>
<metric property="ExceptionCount" measurementType="trendsup" dataType="measurement" displayType="summary" description="Exception Count"/>
<metric property="Initialized" dataType="trait" displayType="summary" description="Initialized"/>
<metric property="Joined" dataType="trait" displayType="summary" description="Joined"/>
10 years, 10 months
[rhq] modules/plugins
by Jiri Kremser
modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 82d0075ed860dcc2f2aed57191e4fa64806caa97
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon Jul 22 14:39:39 2013 +0200
Entities < and > in the plugin descriptor were interpreted as HTML in the ConfigurationEditor and the content between them wasn't there.
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index e6bc1da..a1b3412 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -159,7 +159,7 @@
<operation name="takeSnapshot"
description="Takes a snapshot of all keyspaces. A snapshot first flushes all in-memory writes to disk and then creates a hard
link of each SSTable file for each keyspace. Note that a column family can have multiple
- SSTables on disk. By default snapshots are stored in the <cassandra_data_dir>/<keyspace_name>/<column_family_name>/snapshots
+ SSTables on disk. By default snapshots are stored in the [cassandra_data_dir]/[keyspace_name]/[column_family_name]/snapshots
directory. On Linux/UNIX systems cassandra_data_dir defaults to /var/lib/cassandra/data">
<parameters>
<c:simple-property name="snapshotName" required="false" type="string" displayName="Snapshot Name"
10 years, 10 months
[rhq] modules/enterprise
by John Sanda
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 1a520b6c33dd2bde09d58ea7e51d04c83622f481
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 22 07:17:20 2013 -0400
comment out exporting test ear
Might be nice to enable exporting test ear with a system property where the
location is also configurable.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index 2fd8624..8010c2b 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -413,7 +413,8 @@ public abstract class AbstractEJB3Test extends Arquillian {
//System.out.println("** The Deployment EAR: " + testEar.toString(true) + "\n");
// Save the test EAR to a zip file for inspection (set file explicitly)
- exportZip(testEar, new File("/Users/jsanda/tmp/test-ear.ear"));
+ //String tmpDir = System.getProperty("java.io.tmpdir");
+ //exportZip(testEar, new File(tmpDir, "test.ear"));
return testEar;
}
10 years, 10 months
[rhq] modules/helpers
by Heiko W. Rupp
modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java | 12 ++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
New commits:
commit df8669222aa3146b71b3252166af6bdd387806cd
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jul 22 10:38:44 2013 +0200
Add more units.
diff --git a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
index 0ae4011..150b9e0 100644
--- a/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
+++ b/modules/helpers/pluginAnnotations/src/main/java/org/rhq/helpers/pluginAnnotations/agent/Units.java
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and
+ * Copyright 2009-2013, Red Hat, Inc. and/or its affiliates, and
* individual contributors as indicated by the @author tags. See the
* copyright.txt file in the distribution for a full listing of
* individual contributors.
@@ -26,10 +26,18 @@ package org.rhq.helpers.pluginAnnotations.agent;
* Metric Units.
*
* @author Galder Zamarreño
+ * @author Heiko W. Rupp
+ * See also org.rhq.core.domain.measurement.MeasurementUnits
* @since 4.0
*/
+@SuppressWarnings("unused")
public enum Units {
- NONE, MILLISECONDS, SECONDS, PERCENTAGE;
+ NONE, PERCENTAGE,
+ BYTES, KILOBYTES, MEGABYTES, GIGABYTES, TERABYTES, PETABYTES,
+ BITS, KILOBITS, MEGABITS, GIGABITS, TERABITS, PETABITS,
+ EPOCH_MILLISECONDS, EPOCH_SECONDS,
+ JIFFYS, NANOSECONDS, MICROSECONDS, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS,
+ CELSIUS, KELVIN, FAHRENHEIT;
@Override
public String toString() {
10 years, 10 months
[rhq] modules/plugins
by John Sanda
modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java | 78 ++++++++++
modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml | 8 +
2 files changed, 86 insertions(+)
New commits:
commit 14edae37060b25ebcfed621deef0281c72b1cea2
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 21 21:22:43 2013 -0400
adding resource operation to update internode auth conf file
The operation updates the file on disk and then invokes the JMX operation to
have the authenticator reload the configuration so that the changes can be
picked up without having to restart the node.
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 380da65..006dd26 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -26,7 +26,12 @@
package org.rhq.plugins.storage;
import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,6 +41,7 @@ import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
import org.mc4j.ems.connection.bean.operation.EmsOperation;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -43,7 +49,10 @@ import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.exception.ThrowableUtil;
+import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.stream.StreamUtil;
import org.rhq.plugins.cassandra.CassandraNodeComponent;
import org.rhq.plugins.cassandra.util.KeyspaceService;
@@ -84,6 +93,8 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
return readRepair();
} else if (name.equals("updateConfiguration")) {
return updateConfiguration(parameters);
+ } else if (name.equals("updateKnownNodes")) {
+ return updateKnownNodes(parameters);
} else {
return super.invokeOperation(name, parameters);
}
@@ -95,6 +106,73 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
return result;
}
+ private OperationResult updateKnownNodes(Configuration params) {
+ OperationResult result = new OperationResult();
+
+ PropertyList propertyList = params.getList("ipAddresses");
+ Set<String> ipAddresses = new HashSet<String>();
+
+ for (Property property : propertyList.getList()) {
+ PropertySimple propertySimple = (PropertySimple) property;
+ ipAddresses.add(propertySimple.getStringValue());
+ }
+
+ log.info("Updating known nodes to " + ipAddresses);
+
+ File confDir = new File(getBasedir(), "conf");
+ File authFile = new File(confDir, "rhq-storage-auth.conf");
+ File authBackupFile = new File(confDir, "." + authFile.getName() + ".bak");
+
+ if (authBackupFile.exists()) {
+ if (log.isDebugEnabled()) {
+ log.debug(authBackupFile + " already exists. Deleting it now in preparation of creating new backup " +
+ "for " + authFile.getName());
+ }
+ if (!authBackupFile.delete()) {
+ String msg = "Failed to delete backup file " + authBackupFile + ". The operation will abort " +
+ "since " + authFile + " cannot reliably be backed up before making changes. Please delete " +
+ authBackupFile + " manually and reschedule the operation once the file has been removed.";
+ log.error(msg);
+ result.setErrorMessage(msg);
+
+ return result;
+ }
+ }
+
+ try {
+ FileUtil.copyFile(authFile, authBackupFile);
+ } catch (IOException e) {
+ String msg = "Failed to backup " + authFile + " prior to making updates. The operation will abort due " +
+ "to unexpected error";
+ log.error(msg, e);
+ result.setErrorMessage(msg + ": " + ThrowableUtil.getRootMessage(e));
+ return result;
+ }
+
+ try {
+ StreamUtil.copy(new StringReader(StringUtil.collectionToString(ipAddresses, "\n")),
+ new FileWriter(authFile), true);
+ } catch (IOException e) {
+ log.error("An error occurred while updating " + authFile, e);
+ try {
+ FileUtil.copyFile(authBackupFile, authFile);
+ } catch (IOException e1) {
+ log.error("Failed to revert backup of " + authFile, e1);
+ }
+ result.setErrorMessage("There was an unexpected error while updating " + authFile + ". Make sure that " +
+ "it matches " + authBackupFile + " and then reschedule the operation.");
+ return result;
+ }
+
+ EmsBean authBean = getEmsConnection().getBean("org.rhq.cassandra.auth:type=RhqInternodeAuthenticator");
+ EmsOperation emsOperation = authBean.getOperation("reloadConfiguration");
+ emsOperation.invoke();
+
+ result.setSimpleResult("Successfully updated the set of known nodes.");
+
+ return result;
+ }
+
private OperationResult nodeAdded(Configuration params) {
boolean runRepair = params.getSimple("runRepair").getBooleanValue();
boolean updateSeedsList = params.getSimple("updateSeedsList").getBooleanValue();
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index 6ed31b7..8156d02 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -93,6 +93,14 @@
</results>
</operation>
+ <operation name="updateKnownNodes">
+ <parameters>
+ <c:list-property name="ipAddresses">
+ <c:simple-property name="ipAddress"/>
+ </c:list-property>
+ </parameters>
+ </operation>
+
<operation name="prepareForUpgrade" description="Prepares the storage node for upgrade (this operation consists of following steps: 1) turning off the RPC server, 2) turning off the gossiper, 3) taking the snapshot (backuping the data), 4) invoking the drain operation">
<parameters>
<c:simple-property name="snapshotName" required="false" type="string" displayName="Snapshot Name"
10 years, 10 months
[rhq] 2 commits - modules/common modules/enterprise
by John Sanda
modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties | 2 +-
modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml | 2 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 38777a49e6b5c5f92c54c3f41511f5f691d2a548
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 21 21:21:45 2013 -0400
update cassandra deployer itest
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
index a90d23c..774a831 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra-jvm.properties
@@ -17,9 +17,9 @@ heap_dump_dir=""
thread_stack_size=-Xss180k
-java_agent=""
# Enable jamm when running on Java 6 patch version 23 or higher.
#java_agent="-javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"
+java_agent=-javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar
# GC tuning options
#
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml
index 15d08f2..b9e490a 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/test/resources/expected.cassandra.yaml
@@ -323,7 +323,7 @@ listen_address: localhost
# Internode authentication backend, implementing IInternodeAuthenticator;
# used to allow/disallow connections from peer nodes.
-# internode_authenticator: org.apache.cassandra.auth.AllowAllInternodeAuthenticator
+internode_authenticator: org.rhq.cassandra.auth.RhqInternodeAuthenticator
# Whether to start the native transport server.
# Currently, only the thrift server is started by default because the native
commit 1750170844f6a68b11256ba001fe6cffb53439f6
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 21 21:14:48 2013 -0400
temporarily disable the quartz job that is kicked off when a new node is added
I need to disable the job while working on the internode authentication stuff.
If the maintenance operations run on the nodes, the cluster can actually get
into a bad state because the nodes' authentication conf files have not been
updated which means the new node is not actually part of the cluster.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index 3f1ec69..c77e229 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -170,7 +170,7 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
entityManager.persist(storageNode);
- scheduleQuartzJob(storageNodes.size());
+// scheduleQuartzJob(storageNodes.size());
}
}
}
10 years, 10 months
[rhq] modules/common
by John Sanda
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java | 19 +++++++-
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java | 23 ++++++++++
modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java | 16 ++++++
3 files changed, 57 insertions(+), 1 deletion(-)
New commits:
commit fe6da9b5511a3b4c97c2421079db04020c33c27f
Author: John Sanda <jsanda(a)redhat.com>
Date: Sun Jul 21 21:11:43 2013 -0400
pre-configure internode auth conf file
From testing I have done thus far it appears that a storage node should have
its own IP address included in the internode authentication config file. The
storage installer updates the auth file to include the node's address as well
as and seeds.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
index edf1430..c8bb2ef 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
@@ -34,6 +34,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
+import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -109,6 +110,13 @@ public class CassandraClusterManager {
List<StorageNode> nodes = new ArrayList<StorageNode>(deploymentOptions.getNumNodes());
String seeds = collectionToString(calculateLocalIPAddresses(deploymentOptions.getNumNodes()));
+ Set<InetAddress> ipAddresses = null;
+
+ try {
+ ipAddresses = getClusterIPAddresses();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to get cluster IP addresses", e);
+ }
for (int i = 0; i < deploymentOptions.getNumNodes(); ++i) {
File basedir = new File(deploymentOptions.getClusterDir(), "node" + i);
@@ -141,7 +149,7 @@ public class CassandraClusterManager {
storageNode.setCqlPort(nodeOptions.getNativeTransportPort());
nodes.add(storageNode);
- updateStorageAuthConf(basedir);
+ deployer.updateStorageAuthConf(ipAddresses);
installedNodeDirs.add(basedir);
} catch (Exception e) {
@@ -193,6 +201,15 @@ public class CassandraClusterManager {
return i <= seedsArray.length ? seedsArray[i - 1] : ("127.0.0." + i);
}
+ private Set<InetAddress> getClusterIPAddresses() throws IOException {
+ Set<InetAddress> ipAddresses = new HashSet<InetAddress>();
+ for (String address : calculateLocalIPAddresses(deploymentOptions.getNumNodes())) {
+ ipAddresses.add(InetAddress.getByName(address));
+ }
+
+ return ipAddresses;
+ }
+
private List<StorageNode> calculateNodes() {
List<StorageNode> nodes = new ArrayList<StorageNode>(deploymentOptions.getNumNodes());
for (int i = 0; i < deploymentOptions.getNumNodes(); ++i) {
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
index b01ebe9..6547043 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
@@ -30,13 +30,18 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
+import java.io.StringReader;
+import java.net.InetAddress;
+import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.rhq.core.util.PropertiesFileUpdate;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.TokenReplacingReader;
import org.rhq.core.util.ZipUtil;
import org.rhq.core.util.stream.StreamUtil;
@@ -171,4 +176,22 @@ public class Deployer {
}
}
+ public void updateStorageAuthConf(Set<InetAddress> ipAddresses) {
+ File confDir = new File(deploymentOptions.getBasedir(), "conf");
+ File authFile = new File(confDir, "rhq-storage-auth.conf");
+
+ Set<String> addresses = new HashSet<String>(ipAddresses.size());
+ for (InetAddress ipAddress : ipAddresses) {
+ addresses.add(ipAddress.getHostAddress());
+ }
+
+ try {
+ authFile.delete();
+ StreamUtil.copy(new StringReader(StringUtil.collectionToString(addresses, "\n")),
+ new FileWriter(authFile), true);
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to update " + authFile);
+ }
+ }
+
}
diff --git a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index 5c5ac4e..113d66b 100644
--- a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++ b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -34,10 +34,12 @@ import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
@@ -386,6 +388,7 @@ public class StorageInstaller {
deployer.unzipDistro();
deployer.applyConfigChanges();
deployer.updateFilePerms();
+ deployer.updateStorageAuthConf(getAddresses(hostname, seeds));
log.info("Finished installing RHQ Storage Node.");
@@ -499,6 +502,19 @@ public class StorageInstaller {
return dir;
}
+ private Set<InetAddress> getAddresses(String hostname, String seeds) throws IOException {
+ Set<InetAddress> addresses = new HashSet<InetAddress>();
+ addresses.add(InetAddress.getByName(hostname));
+
+ if (!StringUtil.isEmpty(seeds)) {
+ for (String seed : seeds.split(",")) {
+ addresses.add(InetAddress.getByName(seed));
+ }
+ }
+
+ return addresses;
+ }
+
private PropertiesFileUpdate getServerProperties() {
String sysprop = System.getProperty("rhq.server.properties-file");
if (sysprop == null) {
10 years, 10 months
[rhq] 3 commits - modules/common
by John Sanda
modules/common/cassandra-auth/pom.xml | 27 +++
modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticator.java | 78 ++++++++++
modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticatorMBean.java | 10 +
modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml | 8 +
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties | 2
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml | 2
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java | 20 ++
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java | 28 +++
modules/common/pom.xml | 1
9 files changed, 174 insertions(+), 2 deletions(-)
New commits:
commit b63c38cb0c19cd062d14c5e025164021f1e946cc
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 20 09:53:10 2013 -0400
turn on internode authentication
This enabled internode authentication in cassandra.yaml and the cassandra-auth
module is packaged with our Cassandra distro. The authentication config file is
automatically updated for integrated tests. There is still work to be done for
multi-node dev-container (and production) deployments.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
index 2bde394..c12c567 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml
@@ -113,6 +113,11 @@
<artifactId>snappy-java</artifactId>
<version>${cassandra.snappy.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-cassandra-auth</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<executions>
<execution>
@@ -166,12 +171,15 @@
<delete file="${cassandra.dir}/lib/snappy-java-1.0.4.1.jar"/>
<copy file="${settings.localRepository}/org/xerial/snappy/snappy-java/${cassandra.snappy.version}/snappy-java-${cassandra.snappy.version}.jar"
todir="${cassandra.dir}/lib"/>
+ <copy file="${settings.localRepository}/org/rhq/rhq-cassandra-auth/${project.version}/rhq-cassandra-auth-${project.version}.jar"
+ todir="${cassandra.dir}/lib"/>
<move file="${project.build.outputDirectory}/cassandra/conf" todir="${cassandra.dir}"/>
<delete file="${cassandra.dir}/bin/cassandra"/>
<move file="${project.build.outputDirectory}/cassandra/bin/cassandra" todir="${cassandra.dir}/bin"/>
<delete dir="${project.build.outputDirectory}/cassandra"/>
<delete dir="${cassandra.dir}/javadoc"/>
<delete file="${cassandra.dir}/conf/cassandra-env.sh"/>
+ <touch file="${cassandra.dir}/conf/rhq-storage-auth.conf"/>
<zip basedir="${cassandra.dir}" destfile="${cassandra.distro.zip}"/>
<delete dir="${cassandra.dir}"/>
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
index 612c65e..1faee9d 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/cassandra-jvm.properties
@@ -17,9 +17,9 @@ heap_dump_dir=""
thread_stack_size="-Xss180k"
-java_agent=""
# Enable jamm when running on Java 6 patch version 23 or higher.
#java_agent="-javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar"
+java_agent=
# GC tuning options
#
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
index 298db9d..da09e92 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
@@ -323,7 +323,7 @@ listen_address: ${rhq.cassandra.listen.address}
# Internode authentication backend, implementing IInternodeAuthenticator;
# used to allow/disallow connections from peer nodes.
-# internode_authenticator: org.apache.cassandra.auth.AllowAllInternodeAuthenticator
+internode_authenticator: org.rhq.cassandra.auth.RhqInternodeAuthenticator
# Whether to start the native transport server.
# Currently, only the thrift server is started by default because the native
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
index 338ef3a..edf1430 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
@@ -30,7 +30,9 @@ import static org.rhq.core.util.StringUtil.collectionToString;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileReader;
+import java.io.FileWriter;
import java.io.IOException;
+import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
@@ -50,6 +52,7 @@ import org.rhq.core.system.ProcessExecution;
import org.rhq.core.system.ProcessExecutionResults;
import org.rhq.core.system.SystemInfo;
import org.rhq.core.system.SystemInfoFactory;
+import org.rhq.core.util.StringUtil;
import org.rhq.core.util.file.FileUtil;
import org.rhq.core.util.stream.StreamUtil;
@@ -138,6 +141,8 @@ public class CassandraClusterManager {
storageNode.setCqlPort(nodeOptions.getNativeTransportPort());
nodes.add(storageNode);
+ updateStorageAuthConf(basedir);
+
installedNodeDirs.add(basedir);
} catch (Exception e) {
log.error("Failed to install node at " + basedir);
@@ -152,6 +157,21 @@ public class CassandraClusterManager {
return nodes;
}
+ private void updateStorageAuthConf(File basedir) {
+ File confDir = new File(basedir, "conf");
+ File authFile = new File(confDir, "rhq-storage-auth.conf");
+ authFile.delete();
+
+ Set<String> addresses = calculateLocalIPAddresses(deploymentOptions.getNumNodes());
+
+ try {
+ StreamUtil.copy(new StringReader(StringUtil.collectionToString(addresses, "\n")),
+ new FileWriter(authFile), true);
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to update " + authFile);
+ }
+ }
+
private Set<String> calculateLocalIPAddresses(int numNodes) {
Set<String> addresses = new HashSet<String>();
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
index b222c82..b01ebe9 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
@@ -160,11 +160,6 @@ public class Deployer {
return Integer.parseInt(javaVersion.substring(startIndex + 1, javaVersion.length()));
}
- private boolean isLaterThanJava1_6() {
- String javaVersion = System.getProperty("java.version");
- return javaVersion.compareTo("1.6.0") > 0;
- }
-
public void updateFilePerms() {
File deployDir = new File(deploymentOptions.getBasedir());
File binDir = new File(deployDir, "bin");
commit 890a378fc11b04f3e7af64babfbfd1a7e306b7cd
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Jul 20 07:56:14 2013 -0400
initial commit for cassandra-auth module
This is the first cut at our IInternodeAuthenticator. It loads IP addresses
from a config file. There is a JMX operation to reload the config file that can
be used after the config file is updated.
diff --git a/modules/common/cassandra-auth/pom.xml b/modules/common/cassandra-auth/pom.xml
new file mode 100644
index 0000000..c53c752
--- /dev/null
+++ b/modules/common/cassandra-auth/pom.xml
@@ -0,0 +1,27 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-common-parent</artifactId>
+ <version>4.9.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>rhq-cassandra-auth</artifactId>
+ <name>RHQ Cassandra Authentication</name>
+
+ <properties>
+ <moduleName>org.rhq.${project.artifactId}</moduleName>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cassandra</groupId>
+ <artifactId>cassandra-all</artifactId>
+ <version>${cassandra.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticator.java b/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticator.java
new file mode 100644
index 0000000..56980f1
--- /dev/null
+++ b/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticator.java
@@ -0,0 +1,78 @@
+package org.rhq.cassandra.auth;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
+import java.net.URISyntaxException;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.cassandra.auth.IInternodeAuthenticator;
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+/**
+ * @author John Sanda
+ */
+public class RhqInternodeAuthenticator implements IInternodeAuthenticator, RhqInternodeAuthenticatorMBean {
+
+ private final String MBEAN_NAME = "org.rhq.cassandra.auth:type=" + RhqInternodeAuthenticator.class.getSimpleName();
+
+ private final String CONF_FILE = "rhq-storage-auth.conf";
+
+ private File authConfFile;
+
+ private Set<InetAddress> addresses = new HashSet<InetAddress>();
+
+ public RhqInternodeAuthenticator() {
+ try {
+ authConfFile = new File(getClass().getResource("/" + CONF_FILE).toURI());
+ if (!authConfFile.exists()) {
+ throw new RuntimeException(authConfFile + " does not exist");
+ }
+
+ reloadConfiguration();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException("Failed to load " + CONF_FILE, e);
+ }
+
+ try {
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ ObjectName nameObj = new ObjectName(MBEAN_NAME);
+ mbs.registerMBean(this, nameObj);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to register MBean " + MBEAN_NAME, e);
+ }
+ }
+
+ @Override
+ public boolean authenticate(InetAddress address, int port) {
+ return addresses.contains(address);
+ }
+
+ @Override
+ public void reloadConfiguration() {
+ try {
+ addresses.clear();
+
+ BufferedReader reader = new BufferedReader(new FileReader(authConfFile));
+ String line = reader.readLine();
+
+ while (line != null) {
+ addresses.add(InetAddress.getByName(line));
+ line = reader.readLine();
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to load addresses from " + authConfFile, e);
+ }
+ }
+
+ @Override
+ public void validateConfiguration() throws ConfigurationException {
+ }
+}
diff --git a/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticatorMBean.java b/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticatorMBean.java
new file mode 100644
index 0000000..5e20389
--- /dev/null
+++ b/modules/common/cassandra-auth/src/main/java/org/rhq/cassandra/auth/RhqInternodeAuthenticatorMBean.java
@@ -0,0 +1,10 @@
+package org.rhq.cassandra.auth;
+
+/**
+ * @author John Sanda
+ */
+public interface RhqInternodeAuthenticatorMBean {
+
+ public void reloadConfiguration();
+
+}
diff --git a/modules/common/pom.xml b/modules/common/pom.xml
index bcbf862..7d12500 100644
--- a/modules/common/pom.xml
+++ b/modules/common/pom.xml
@@ -30,6 +30,7 @@
<module>ant-bundle</module>
<module>drift</module>
<module>jboss-as-dmr-client</module>
+ <module>cassandra-auth</module>
<module>cassandra-util</module>
<module>cassandra-jmx</module>
<module>cassandra-schema</module>
commit 8cf740355dfab9832b904984aaba4e52bf759951
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Jul 19 22:18:23 2013 -0400
add logic to enable jamm java agent, which mirrors logic in cassandra-env.sh
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
index 1e31e14..b222c82 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/Deployer.java
@@ -125,6 +125,13 @@ public class Deployer {
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);
@@ -132,6 +139,32 @@ public class Deployer {
}
}
+ private boolean isOpenJDK() {
+ String javaVMName = System.getProperty("java.vm.name");
+ return javaVMName.startsWith("OpenJDK");
+ }
+
+ private boolean isJava1_6() {
+ String javaVersion = System.getProperty("java.version");
+ return javaVersion.startsWith("1.6.0");
+ }
+
+ private int getJavaPatchVersion() {
+ String javaVersion = System.getProperty("java.version");
+ int startIndex = javaVersion.indexOf('_');
+
+ if (startIndex == -1) {
+ return 0;
+ }
+
+ return Integer.parseInt(javaVersion.substring(startIndex + 1, javaVersion.length()));
+ }
+
+ private boolean isLaterThanJava1_6() {
+ String javaVersion = System.getProperty("java.version");
+ return javaVersion.compareTo("1.6.0") > 0;
+ }
+
public void updateFilePerms() {
File deployDir = new File(deploymentOptions.getBasedir());
File binDir = new File(deployDir, "bin");
10 years, 10 months
[rhq] Branch 'mtho11/consolidated-metrics' - modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java | 259 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java | 58 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/enhanced/Enhanced.java | 2
5 files changed, 320 insertions(+), 3 deletions(-)
New commits:
commit 061d403e65ecee68831b8518022b3954bb276063
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Sat Jul 20 10:24:48 2013 -0700
Refactor out DashboardLinkUtility for 'add to dashboard functionality' in consolidated metrics view.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java
new file mode 100644
index 0000000..e7482fe
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java
@@ -0,0 +1,259 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeSet;
+
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.http.client.RequestException;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.DashboardCriteria;
+import org.rhq.core.domain.criteria.SubjectCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementSchedule;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.Messages;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceD3GraphPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.Log;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences;
+import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
+
+/**
+ * Utility Class to build menus for linking to the Dashboard.
+ * @author Jay Shaughnessy
+ * @author Greg Hinkle
+ * @author Mike Thompson
+ */
+public class DashboardLinkUtility {
+ final static Messages MSG = CoreGUI.getMessages();
+
+ public DashboardLinkUtility getInstance(){
+ return new DashboardLinkUtility();
+ }
+ private DashboardLinkUtility(){ }
+
+ public static MenuItem buildMetricsMenu(final ResourceType type, final Resource resource) {
+ MenuItem measurements = new MenuItem(MSG.view_tree_common_contextMenu_measurements());
+ final Menu measurementsSubMenu = new Menu();
+
+ DashboardCriteria criteria = new DashboardCriteria();
+ GWTServiceLookup.getDashboardService().findDashboardsByCriteria(criteria,
+ new AsyncCallback<PageList<Dashboard>>() {
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_dashboard(),
+ caught);
+ }
+
+ public void onSuccess(PageList<Dashboard> result) {
+ //sort the display items alphabetically
+ TreeSet<String> ordered = new TreeSet<String>();
+ Map<String, MeasurementDefinition> definitionMap = new HashMap<String, MeasurementDefinition>();
+ for (MeasurementDefinition m : type.getMetricDefinitions()) {
+ ordered.add(m.getDisplayName());
+ definitionMap.put(m.getDisplayName(), m);
+ }
+
+ for (String displayName : ordered) {
+ final MeasurementDefinition def = definitionMap.get(displayName);
+ //only add menu items for Measurement
+ if (def.getDataType().equals(DataType.MEASUREMENT)) {
+ MenuItem defItem = new MenuItem(def.getDisplayName());
+ measurementsSubMenu.addItem(defItem);
+ Menu defSubItem = new Menu();
+ defItem.setSubmenu(defSubItem);
+
+ for (final Dashboard d : result) {
+ MenuItem addToDBItem = new MenuItem(MSG
+ .view_tree_common_contextMenu_addChartToDashboard(d.getName()));
+ defSubItem.addItem(addToDBItem);
+
+ addToDBItem.addClickHandler(new ClickHandler() {
+
+ public void onClick(MenuItemClickEvent menuItemClickEvent) {
+ DashboardPortlet p = new DashboardPortlet(MSG
+ .view_tree_common_contextMenu_resourceGraph(), ResourceD3GraphPortlet.KEY,
+ 250);
+ p.getConfiguration()
+ .put(
+ new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resource
+ .getId()));
+ p.getConfiguration().put(
+ new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, def.getId()));
+
+ d.addPortlet(p);
+
+ GWTServiceLookup.getDashboardService().storeDashboard(d,
+ new AsyncCallback<Dashboard>() {
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_tree_common_contextMenu_saveChartToDashboardFailure(),
+ caught);
+ }
+
+ public void onSuccess(Dashboard result) {
+ CoreGUI
+ .getMessageCenter()
+ .notify(
+ new Message(
+ MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result
+ .getName()), Message.Severity.Info));
+ }
+ });
+
+ }
+
+ });
+
+ }//end dashboard iteration
+
+ //add new menu item for adding current graphable element to view if on Monitor/Graphs tab
+ String currentViewPath = History.getToken();
+ if (currentViewPath.contains("Monitoring/Metrics")) {
+ MenuItem addGraphItem = new MenuItem(MSG.common_title_add_graph_to_view());
+ defSubItem.addItem(addGraphItem);
+
+ addGraphItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent menuItemClickEvent) {
+ //generate javascript to call out to.
+ //Ex. menuLayers.hide();addMetric('${metric.resourceId},${metric.scheduleId}')
+ if (getScheduleDefinitionId(resource, def.getName()) > -1) {
+ final String resourceGraphElements = resource.getId() + ","
+ + getScheduleDefinitionId(resource, def.getName());
+
+ //Once, the portal-war will be rewritten to GWT and operations performed
+ //within the iframe + JSF will update the user preferences, the following
+ //2 lines could be uncommented and the lines below them refactorized
+ //MeasurementUserPreferences measurementPreferences = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
+ //String selectedView = measurementPreferences.getSelectedView(String.valueOf(resource.getId()));
+
+ final int sid = UserSessionManager.getSessionSubject().getId();
+ SubjectCriteria c = new SubjectCriteria();
+ c.addFilterId(sid);
+
+ GWTServiceLookup.getSubjectService().findSubjectsByCriteria(c,
+ new AsyncCallback<PageList<Subject>>() {
+ public void onSuccess(PageList<Subject> result) {
+ if (result.size() > 0) {
+ UserPreferences uPreferences = new UserPreferences(result
+ .get(0));
+ MeasurementUserPreferences mPreferences = new MeasurementUserPreferences(
+ uPreferences);
+ String selectedView = mPreferences.getSelectedView(String
+ .valueOf(resource.getId()));
+
+ addNewMetric(String.valueOf(resource.getId()),
+ selectedView, resourceGraphElements);
+ } else {
+ Log.trace("Error obtaining subject with id:" + sid);
+ }
+ }
+
+ public void onFailure(Throwable caught) {
+ Log.trace("Error obtaining subject with id:" + sid, caught);
+ }
+ });
+ }
+ }
+ });
+ } // end add the "add to view" menu item
+ }//end trait exclusion
+ }//end measurement def iteration
+
+ }
+ });
+ measurements.setSubmenu(measurementsSubMenu);
+ return measurements;
+ }
+
+ /** Locate the specific schedule definition using the definition identifier.
+ */
+ private static int getScheduleDefinitionId(Resource resource, String definitionName) {
+ int id = -1;
+ if (resource.getSchedules() != null) {
+ boolean located = false;
+ MeasurementSchedule[] schedules = new MeasurementSchedule[resource.getSchedules().size()];
+ resource.getSchedules().toArray(schedules);
+ for (int i = 0; (!located && i < resource.getSchedules().size()); i++) {
+ MeasurementSchedule schedule = schedules[i];
+ MeasurementDefinition definition = schedule.getDefinition();
+ if ((definition != null) && definition.getName().equals(definitionName)) {
+ located = true;
+ id = schedule.getId();
+ }
+ }
+ }
+ return id;
+ }
+
+ private static void addNewMetric(String id, String selectedView, String resourceGraphElements) {
+ //construct portal.war url to access
+ String baseUrl = "/resource/common/monitor/visibility/IndicatorCharts.do";
+ baseUrl += "?id=" + id;
+ baseUrl += "&view=" + selectedView;
+ baseUrl += "&action=addChart&metric=" + resourceGraphElements;
+ final String url = baseUrl;
+ //initiate HTTP request
+ final RequestBuilder b = new RequestBuilder(RequestBuilder.GET, baseUrl);
+
+ try {
+ b.setCallback(new RequestCallback() {
+ public void onResponseReceived(final Request request, final Response response) {
+ Log.trace("Successfully submitted request to add graph to view:" + url);
+
+ //kick off a page reload.
+ String currentViewPath = History.getToken();
+ CoreGUI.goToView(currentViewPath, true);
+ }
+
+ @Override
+ public void onError(Request request, Throwable t) {
+ Log.trace("Error adding Metric:" + url, t);
+ }
+ });
+ b.send();
+ } catch (RequestException e) {
+ Log.warn("Error adding Metric:" + url, e);
+ }
+
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 08d1fd5..ae51195 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -193,7 +193,7 @@ public class ResourceDetailView extends
monitoringTab = new TwoLevelTab(new ViewName("Monitoring", MSG.view_tabs_common_monitoring()),
IconEnum.SUSPECT_METRICS);
- monitorMetrics = new SubTab(monitoringTab, new ViewName("Metrics", "Metrics"), null);
+ monitorMetrics = new SubTab(monitoringTab, new ViewName("Metrics", MSG.view_tabs_common_metrics()), null);
monitorTraits = new SubTab(monitoringTab, new ViewName("Traits", MSG.view_tabs_common_traits()), null);
monitorSched = new SubTab(monitoringTab, new ViewName("Schedules", MSG.view_tabs_common_schedules()), null);
monitorCallTime = new SubTab(monitoringTab, new ViewName("CallTime", MSG.view_tabs_common_calltime()), null);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 071f831..e305039 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -802,7 +802,7 @@ public class ResourceTreeView extends EnhancedVLayout {
//add new menu item for adding current graphable element to view if on Monitor/Graphs tab
String currentViewPath = History.getToken();
- if (currentViewPath.contains("Monitoring/NewGraphs")) {
+ if (currentViewPath.contains("Monitoring/Metrics")) {
MenuItem addGraphItem = new MenuItem(MSG.common_title_add_graph_to_view());
defSubItem.addItem(addGraphItem);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
index d6bcbaa..31534ed 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
@@ -47,12 +47,18 @@ import com.smartgwt.client.widgets.grid.events.RecordExpandHandler;
import com.smartgwt.client.widgets.grid.events.SortChangedHandler;
import com.smartgwt.client.widgets.grid.events.SortEvent;
import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.criteria.SubjectCriteria;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
@@ -67,6 +73,7 @@ import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences;
+import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional detailed d3 graph.
@@ -240,6 +247,57 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
//@todo: Add to Dashboard
}
+ public void abc(){
+
+ MenuItem addGraphItem = new MenuItem(MSG.common_title_add_graph_to_view());
+ defSubItem.addItem(addGraphItem);
+
+ addGraphItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent menuItemClickEvent) {
+ //generate javascript to call out to.
+ //Ex. menuLayers.hide();addMetric('${metric.resourceId},${metric.scheduleId}')
+ if (getScheduleDefinitionId(resource, def.getName()) > -1) {
+ final String resourceGraphElements = resource.getId() + ","
+ + getScheduleDefinitionId(resource, def.getName());
+
+ //Once, the portal-war will be rewritten to GWT and operations performed
+ //within the iframe + JSF will update the user preferences, the following
+ //2 lines could be uncommented and the lines below them refactorized
+ //MeasurementUserPreferences measurementPreferences = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
+ //String selectedView = measurementPreferences.getSelectedView(String.valueOf(resource.getId()));
+
+ final int sid = UserSessionManager.getSessionSubject().getId();
+ SubjectCriteria c = new SubjectCriteria();
+ c.addFilterId(sid);
+
+ GWTServiceLookup.getSubjectService().findSubjectsByCriteria(c,
+ new AsyncCallback<PageList<Subject>>() {
+ public void onSuccess(PageList<Subject> result) {
+ if (result.size() > 0) {
+ UserPreferences uPreferences = new UserPreferences(result
+ .get(0));
+ MeasurementUserPreferences mPreferences = new MeasurementUserPreferences(
+ uPreferences);
+ String selectedView = mPreferences.getSelectedView(String
+ .valueOf(resource.getId()));
+
+ addNewMetric(String.valueOf(resource.getId()),
+ selectedView, resourceGraphElements);
+ } else {
+ Log.trace("Error obtaining subject with id:" + sid);
+ }
+ }
+
+ public void onFailure(Throwable caught) {
+ Log.trace("Error obtaining subject with id:" + sid, caught);
+ }
+ });
+ }
+ }
+ });
+
+ }
+
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/enhanced/Enhanced.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/enhanced/Enhanced.java
index 10505e9..a069a5d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/enhanced/Enhanced.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/enhanced/Enhanced.java
@@ -31,5 +31,5 @@ import org.rhq.enterprise.gui.coregui.client.Messages;
*/
public interface Enhanced {
- Messages MSG = CoreGUI.getMessages();
+ final static Messages MSG = CoreGUI.getMessages();
}
10 years, 10 months