[rhq] modules/plugins
by mazz
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit fabce7666b08f73ea113807ec42b47a3d3eb5929
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 29 11:15:34 2013 -0400
BZ 957282 957288 add bundle target of "Install Directory"
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 5a30ec3..45f4e05 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -1333,6 +1333,10 @@
</drift-definition>
<bundle-target>
+ <destination-base-dir name="Install Directory" description="The top directory where the application server is installed. (i.e. the value found in the 'Home Directory' connection property)">
+ <value-context>pluginConfiguration</value-context>
+ <value-name>homeDir</value-name>
+ </destination-base-dir>
<destination-base-dir name="Deploy Directory" description="The deployment directory for a standalone server">
<value-context>measurementTrait</value-context>
<value-name>deployDir</value-name>
11 years
[rhq] Branch 'feature/cassandra-backend' - 11 commits - .classpath etc/eclipse-tools modules/common modules/enterprise
by Jay Shaughnessy
.classpath | 22
etc/eclipse-tools/RHQ | 1
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/bundle/deploy.xml | 2
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptions.java | 4
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties | 2
modules/common/cassandra-installer/pom.xml | 58 ++
modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java | 225 ++++++---
modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java | 6
modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-installer.bat | 2
modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.bat | 48 -
modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.sh | 18
modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-storage-installer.bat | 199 ++++++++
modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-storage.bat | 232 +++++++++
modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl | 241 ++++++++++
modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl.bat | 193 ++++++++
modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl.sh | 241 ----------
modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.conf | 202 ++++++++
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java | 34 -
modules/enterprise/server/server-control/pom.xml | 58 ++
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java | 40 +
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java | 4
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Console.java | 63 +-
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java | 156 ++++--
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Start.java | 21
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Status.java | 21
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Stop.java | 24
27 files changed, 1588 insertions(+), 531 deletions(-)
New commits:
commit 4c6fb2d7667bd2605f2a07f1fcddd785c36ea07c
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 26 17:30:23 2013 -0400
Fix issues in install marker file placement.
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
index 50dad87..b68cf12 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
@@ -1237,12 +1237,11 @@ public class InstallerServiceImpl implements InstallerService {
}
private void writeInstalledFileMarker() throws Exception {
- File basedir = new File(getAppServerDataDir());
- File standalonedir = new File(basedir, "jbossas/standalone");
- if (!standalonedir.isDirectory()) {
- throw new IOException("Directory Not Found: [" + standalonedir.getPath() + "]");
+ File datadir = new File(getAppServerDataDir());
+ if (!datadir.isDirectory()) {
+ throw new IOException("Directory Not Found: [" + datadir.getPath() + "]");
}
- File markerFile = new File(standalonedir, "data/rhq.installed");
+ File markerFile = new File(datadir, "rhq.installed");
markerFile.createNewFile();
}
}
commit f293cea87eb89c77749118c4fac49b6eb52fbd73
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 26 17:23:21 2013 -0400
On windows default the cassandra data to HOMEDRIVE:/rhq/storage/...
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 c123b96..ce63dff 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
@@ -100,11 +100,13 @@ public class StorageInstaller {
private File logDir;
- private String commitLogDir = "/var/lib/rhq/storage/commitlog";
+ private String dirPrefix = (isWindows()) ? "" : "var/lib";
- private String dataDir = "/var/lib/rhq/storage/data";
+ private String commitLogDir = dirPrefix + "/rhq/storage/commitlog";
- private String savedCachesDir = "/var/lib/rhq/storage/saved_caches";
+ private String dataDir = dirPrefix + "/rhq/storage/data";
+
+ private String savedCachesDir = dirPrefix + "/rhq/storage/saved_caches";
public StorageInstaller() {
String basedir = System.getProperty("rhq.server.basedir");
commit 86a0d9ae8c8aaf13d0dd8f51e6e3a8b0f8678067
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 26 15:02:39 2013 -0400
Working towards rhqctl install support on windows...
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
index dd53968..50dad87 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
@@ -19,9 +19,7 @@
package org.rhq.enterprise.server.installer;
import java.io.File;
-import java.io.FileWriter;
import java.io.IOException;
-import java.io.StringReader;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.HashMap;
@@ -42,7 +40,6 @@ import org.rhq.common.jbossas.client.controller.WebJBossASClient;
import org.rhq.core.db.DatabaseTypeFactory;
import org.rhq.core.util.PropertiesFileUpdate;
import org.rhq.core.util.exception.ThrowableUtil;
-import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.server.installer.ServerInstallUtil.ExistingSchemaOption;
import org.rhq.enterprise.server.installer.ServerInstallUtil.SupportedDatabaseType;
@@ -482,8 +479,8 @@ public class InstallerServiceImpl implements InstallerService {
if (cassandraSchemaManager.schemaExists()) {
log("Cassandra schema exists.");
if (ExistingSchemaOption.OVERWRITE == existingSchemaOptionEnum) {
- log("Cassandra schema exists but installer was told to overwrite it - a new schema will be " +
- "created now.");
+ log("Cassandra schema exists but installer was told to overwrite it - a new schema will be "
+ + "created now.");
cassandraSchemaManager.dropSchema();
cassandraSchemaManager.createSchema();
@@ -784,6 +781,18 @@ public class InstallerServiceImpl implements InstallerService {
}
}
+ private String getAppServerDataDir() throws Exception {
+ ModelControllerClient mcc = null;
+ try {
+ mcc = getModelControllerClient();
+ final CoreJBossASClient client = new CoreJBossASClient(mcc);
+ final String dir = client.getAppServerDataDir();
+ return dir;
+ } finally {
+ safeClose(mcc);
+ }
+ }
+
private String getAppServerConfigDir() throws Exception {
ModelControllerClient mcc = null;
try {
@@ -1227,13 +1236,13 @@ public class InstallerServiceImpl implements InstallerService {
return new SchemaManager(username, password, hosts);
}
- private void writeInstalledFileMarker() throws IOException {
- File basedir = new File(System.getProperty("rhq.server.basedir"));
- File modulesDir = new File(basedir, "modules");
- File metaInfDir = new File(modulesDir,
- "org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/rhq.ear/META-INF/");
- File markerFile = new File(metaInfDir, ".installed");
-
- StreamUtil.copy(new StringReader(""), new FileWriter(markerFile));
+ private void writeInstalledFileMarker() throws Exception {
+ File basedir = new File(getAppServerDataDir());
+ File standalonedir = new File(basedir, "jbossas/standalone");
+ if (!standalonedir.isDirectory()) {
+ throw new IOException("Directory Not Found: [" + standalonedir.getPath() + "]");
+ }
+ File markerFile = new File(standalonedir, "data/rhq.installed");
+ markerFile.createNewFile();
}
}
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java
index d64cfed..851dd2d 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java
@@ -26,13 +26,11 @@
package org.rhq.server.control;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
-import java.util.Properties;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
@@ -45,7 +43,6 @@ import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.rhq.core.util.PropertiesFileUpdate;
import org.rhq.core.util.stream.StreamUtil;
/**
@@ -146,10 +143,7 @@ public abstract class ControlCommand {
}
protected boolean isServerInstalled() {
- File modulesDir = new File(basedir, "modules");
- File metaInfDir = new File(modulesDir,
- "org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/rhq.ear/META-INF/");
- File markerFile = new File(metaInfDir, ".installed");
+ File markerFile = new File(basedir, "jbossas/standalone/data/rhq.installed");
return markerFile.exists();
}
@@ -224,7 +218,7 @@ public abstract class ControlCommand {
result = new org.apache.commons.exec.CommandLine("cmd.exe");
result.addArgument("/C");
result.addArgument(scriptName + ".bat");
- return result;
+
} else {
result = new org.apache.commons.exec.CommandLine("./" + scriptName + ".sh");
}
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 c5c871d..4970a2a 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
@@ -334,17 +334,35 @@ public class Install extends ControlCommand {
}
private void startRHQServerForInstallation() throws Exception {
- org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-server", "start");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(binDir);
executor.setStreamHandler(new PumpStreamHandler());
+ org.apache.commons.exec.CommandLine commandLine;
- executor.execute(commandLine, new DefaultExecuteResultHandler());
+ if (isWindows()) {
+ // For windows we will [re-]install the server as a windows service, then start the service.
+
+ commandLine = getCommandLine("rhq-server", "stop");
+ executor.execute(commandLine);
+
+ commandLine = getCommandLine("rhq-server", "remove");
+ executor.execute(commandLine);
+
+ commandLine = getCommandLine("rhq-server", "install");
+ executor.execute(commandLine);
+
+ commandLine = getCommandLine("rhq-server", "start");
+ executor.execute(commandLine);
+ } else {
+ // For *nix, just start the server in the background
+ commandLine = getCommandLine("rhq-server", "start");
+ executor.execute(commandLine, new DefaultExecuteResultHandler());
+ }
+
+ // Wait for the server to complete it's startup
commandLine = getCommandLine("rhq-installer", "--test");
- executor = new DefaultExecutor();
- executor.setWorkingDirectory(binDir);
int exitCode = executor.execute(commandLine);
while (exitCode != 0) {
@@ -371,15 +389,30 @@ public class Install extends ControlCommand {
private boolean isRHQServerInitialized() throws Exception {
File logDir = new File(basedir, "logs");
- BufferedReader reader = new BufferedReader(new FileReader(new File(logDir, "server.log")));
- String line = reader.readLine();
- while (line != null) {
- if (line.contains("Server started")) {
- return true;
+
+ BufferedReader reader = null;
+
+ try {
+ reader = new BufferedReader(new FileReader(new File(logDir, "server.log")));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.contains("Server started")) {
+ return true;
+ }
+ line = reader.readLine();
+ }
+
+ return false;
+
+ } finally {
+ if (null != reader) {
+ try {
+ reader.close();
+ } catch (Exception e) {
+ // best effort
+ }
}
- line = reader.readLine();
}
- return false;
}
private void installAgent(File agentBasedir) throws Exception {
commit c2aedee12d71d14d8987993b524d5071e87aba66
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 26 15:01:33 2013 -0400
fix a small issue in the rhq-installer.bat
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-installer.bat b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-installer.bat
index 811aa17..2f69194 100644
--- a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-installer.bat
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-installer.bat
@@ -120,7 +120,7 @@ if not defined RHQ_SERVER_DEBUG set _RHQ_LOGLEVEL=INFO
set RHQ_SERVER_INSTALLER_JAVA_OPTS=%RHQ_SERVER_INSTALLER_JAVA_OPTS% -Djava.awt.headless=true -Di18nlog.logger-type=commons -Drhq.server.properties-file=%RHQ_SERVER_HOME%\bin\rhq-server.properties -Drhq.server.installer.logdir=%RHQ_SERVER_HOME%\logs -Drhq.server.installer.loglevel=%_RHQ_LOGLEVEL%
rem Sample JPDA settings for remote socket debugging
-rem RHQ_SERVER_INSTALLER_JAVA_OPTS=%RHQ_SERVER_INSTALLER_JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
+rem set RHQ_SERVER_INSTALLER_JAVA_OPTS=%RHQ_SERVER_INSTALLER_JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_INSTALLER_JAVA_OPTS: %RHQ_SERVER_INSTALLER_JAVA_OPTS%
if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_INSTALLER_ADDITIONAL_JAVA_OPTS: %RHQ_SERVER_INSTALLER_ADDITIONAL_JAVA_OPTS%
commit 23e651bd2a7381e41ffb364aead5a0e409a039bb
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 26 15:01:00 2013 -0400
this is a manual cherry-pick of a master commit addinga convenience method
to the ASClient.
diff --git a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java
index 4521b35..7d7095d 100644
--- a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java
+++ b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/CoreJBossASClient.java
@@ -92,6 +92,12 @@ public class CoreJBossASClient extends JBossASClient {
return dir;
}
+ public String getAppServerDataDir() throws Exception {
+ final String[] address = { CORE_SERVICE, SERVER_ENVIRONMENT };
+ final String dir = getStringAttribute(true, "data-dir", Address.root().add(address));
+ return dir;
+ }
+
public String getAppServerBaseDir() throws Exception {
final String[] address = { CORE_SERVICE, SERVER_ENVIRONMENT };
final String dir = getStringAttribute(true, "base-dir", Address.root().add(address));
commit 5e4c9fb7fea8339953b084ca117f3975d9deb635
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 26 13:23:39 2013 -0400
The cassandra log filename was huge, I don't think we want the whole path
in the name, do we?
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 5a20097..c123b96 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
@@ -211,7 +211,8 @@ public class StorageInstaller {
deploymentOptions.setCommitLogDir(commitLogDir);
deploymentOptions.setDataDir(dataDir);
deploymentOptions.setSavedCachesDir(savedCachesDir);
- deploymentOptions.setLogFileName(logFile.getPath());
+ // deploymentOptions.setLogFileName(logFile.getPath());
+ deploymentOptions.setLogFileName(logFile.getName());
deploymentOptions.setLoggingLevel("INFO");
deploymentOptions.setRpcPort(rpcPort);
deploymentOptions.setJmxPort(getPort(cmdLine, "jmx-port", jmxPort));
commit bdb8fe4fccab4cb81fd8d3026ec988bcbb9cd9cf
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 26 13:22:32 2013 -0400
Fix property name typo
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 6ed76a5..23218ca 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
@@ -335,7 +335,7 @@ native_transport_port: ${rhq.cassandra.native_transport_port}
# rpc_min_threads and rpc_max_threads, though the default differ slightly and
# are the ones below:
# native_transport_min_threads: 16
-native_transport_max_threads: ${rhq.casandra.native_transport_max_threads}
+native_transport_max_threads: ${rhq.cassandra.native_transport_max_threads}
# Whether to start the thrift rpc server.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties
index ce1df3a..e17520d 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/resources/cassandra.properties
@@ -42,7 +42,7 @@ rhq.cassandra.listen.address=localhost
rhq.cassandra.rpc.address=localhost
# The maximum number of threads handling native CQL requests.
-rhq.casandra.native-transport-max-threads=64
+rhq.cassandra.native-transport-max-threads=64
# The port for the CQL native transport to listen for clients on.
rhq.cassandra.native-transport-port=9042
commit 1416cd575dee66ef46cf9166d4dddc8b2916ab0f
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Apr 26 13:21:26 2013 -0400
More eclipse tweeks
diff --git a/.classpath b/.classpath
index d2d09be..8010bae 100644
--- a/.classpath
+++ b/.classpath
@@ -384,5 +384,8 @@
<classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/aggregate/jetty-all/8.1.8.v20121106/jetty-all-8.1.8.v20121106.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="var" path="JDK_HOME/lib/tools.jar"/>
+ <classpathentry exported="true" kind="var" path="JDK_HOME/jre/lib/rt.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-configuration/commons-configuration/1.6/commons-configuration-1.6.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/maven/plugin-tools/maven-plugin-annotations/3.2/maven-plugin-annotations-3.2.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
diff --git a/etc/eclipse-tools/RHQ Remote Debugging - Test.launch b/etc/eclipse-tools/RHQ Remote Debugging - Test.launch
index 7b57371..971736b 100644
--- a/etc/eclipse-tools/RHQ Remote Debugging - Test.launch
+++ b/etc/eclipse-tools/RHQ Remote Debugging - Test.launch
@@ -15,7 +15,6 @@
<mapAttribute key="org.eclipse.jdt.launching.CONNECT_MAP">
<mapEntry key="hostname" value="localhost"/>
<mapEntry key="port" value="8797"/>
-<mapEntry key="timeout" value="20000"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="rhq"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_CONNECTOR_ID" value="org.eclipse.jdt.launching.socketAttachConnector"/>
commit ba2cb5b68412c47e2ff2bdae0f0055ca7a86c0f6
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 24 16:13:24 2013 -0400
- handle executor command lines for windows
- use windows service for hosting cassandra
- use tanuki java service wrapper and introduce rhq-storage.bat, analogous to
rhq-server.bat. And rhq-storage-wrapper.conf.
- change rhqctl.sh to rhqctl
- log exception cause for RHQControl
- add rhqctl.bat and rhq-storage-installer.bat for windows , to match
rhqctl and rhq-storage-installer.sh
- storage installer changes for windows and some fixes
- some fixes to rhq-server.sh|bat scripts
- come .classpath changes for eclipse
diff --git a/.classpath b/.classpath
index 86c5ab2..d2d09be 100644
--- a/.classpath
+++ b/.classpath
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="modules/common/ant-bundle/src/main/java"/>
+ <classpathentry kind="src" path="modules/common/cassandra-ccm/cassandra-ccm-maven-plugin/src/main/java"/>
+ <classpathentry kind="src" path="modules/common/cassandra-ccm/cassandra-ccm-core/src/test/java"/>
+ <classpathentry kind="src" path="modules/common/cassandra-ccm/cassandra-ccm-arquillian/src/main/java"/>
+ <classpathentry kind="src" path="modules/common/cassandra-installer/src/main/java"/>
+ <classpathentry kind="src" path="modules/enterprise/server/server-control/src/main/java"/>
<classpathentry kind="src" path="modules/enterprise/server/jar/src/test/java"/>
<classpathentry kind="src" path="modules/enterprise/server/itests-2/src/test/java"/>
<classpathentry kind="src" path="modules/enterprise/scripting/javascript/src/main/java"/>
@@ -361,12 +366,11 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/python/jython-standalone/2.5.2/jython-standalone-2.5.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/com/wordnik/swagger-annotations_2.9.1/1.1.1-SNAPSHOT/swagger-annotations_2.9.1-1.1.1-20121031.024335-6.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/joda-time/joda-time/2.1/joda-time-2.1.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman-install/1.5.2/byteman-install-1.5.2.jar" sourcepath="M2_REPO/org/jboss/byteman/byteman-install/1.5.2/byteman-install-1.5.2-sources.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman-submit/1.5.2/byteman-submit-1.5.2.jar" sourcepath="M2_REPO/org/jboss/byteman/byteman-submit/1.5.2/byteman-submit-1.5.2-sources.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman-bmunit/1.5.2/byteman-bmunit-1.5.2.jar" sourcepath="M2_REPO/org/jboss/byteman/byteman-bmunit/1.5.2/byteman-bmunit-1.5.2-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/cassandra/cassandra-thrift/1.2.0-beta2/cassandra-thrift-1.2.0-beta2.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman-install/1.5.2/byteman-install-1.5.2.jar" sourcepath="M2_REPO/org/jboss/byteman/byteman-install/1.5.2/byteman-install-1.5.2-sources.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman-submit/1.5.2/byteman-submit-1.5.2.jar" sourcepath="M2_REPO/org/jboss/byteman/byteman-submit/1.5.2/byteman-submit-1.5.2-sources.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman-bmunit/1.5.2/byteman-bmunit-1.5.2.jar" sourcepath="M2_REPO/org/jboss/byteman/byteman-bmunit/1.5.2/byteman-bmunit-1.5.2-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/hectorclient/hector-core/1.1-1/hector-core-1.1-1.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/cassandra/cassandra-all/1.2.0-beta2/cassandra-all-1.2.0-beta2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/cassandra/cassandra-all/1.2.2/cassandra-all-1.2.2.jar"/>
<classpathentry kind="var" path="M2_REPO/com/datastax/cassandra/cassandra-driver-core/1.0.0-beta2-rhq-1.2.2-2/cassandra-driver-core-1.0.0-beta2-rhq-1.2.2-2.jar"/>
<classpathentry kind="var" path="M2_REPO/org/apache/thrift/libthrift/0.7.0/libthrift-0.7.0.jar"/>
<classpathentry kind="var" path="M2_REPO/commons-cli/commons-cli/1.2/commons-cli-1.2.jar"/>
@@ -375,5 +379,10 @@
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/xmlgraphics/batik-util/1.7/batik-util-1.7.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/xmlgraphics/batik-svg-dom/1.7/batik-svg-dom-1.7.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/xmlgraphics/batik-dom/1.7/batik-dom-1.7.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/cassandra/cassandra-thrift/1.2.2/cassandra-thrift-1.2.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-exec/1.1/commons-exec-1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/aggregate/jetty-all/8.1.8.v20121106/jetty-all-8.1.8.v20121106.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry exported="true" kind="var" path="JDK_HOME/lib/tools.jar"/>
<classpathentry kind="output" path="eclipse-classes"/>
</classpath>
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 ae2869b..5a20097 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
@@ -28,6 +28,7 @@ package org.rhq.storage.installer;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -111,68 +112,62 @@ public class StorageInstaller {
storageBasedir = new File(basedir, "rhq-storage");
logDir = new File(serverBasedir, "logs");
- Option hostname = new Option("n", "hostname", true, "The hostname or IP address on which the node will listen for " +
- "requests. If not specified, defaults to the hostname for localhost.");
- hostname.setArgName("HOSTNAME");
+ Option hostname = new Option("n", "hostname", true,
+ "The hostname or IP address on which the node will listen for "
+ + "requests. If not specified, defaults to the hostname for localhost.");
+ hostname.setArgName("HOSTNAME");
- Option seeds = new Option("s", "seeds", true, "A comma-delimited list of hostnames or IP addresses that " +
- "serve as contact points. Nodes use this list to find each other and to learn the cluster topology. " +
- "It does not need to specify all nodes in the cluster. Defaults to this node's hostname.");
+ Option seeds = new Option("s", "seeds", true, "A comma-delimited list of hostnames or IP addresses that "
+ + "serve as contact points. Nodes use this list to find each other and to learn the cluster topology. "
+ + "It does not need to specify all nodes in the cluster. Defaults to this node's hostname.");
seeds.setArgName("SEEDS");
- Option jmxPortOption = new Option("j", "jmx-port", true, "The port on which to listen for JMX connections. " +
- "Defaults to " + jmxPort + ".");
+ Option jmxPortOption = new Option("j", "jmx-port", true, "The port on which to listen for JMX connections. "
+ + "Defaults to " + jmxPort + ".");
jmxPortOption.setArgName("PORT");
- Option nativeTransportPortOption = new Option("c", "client-port", true, "The port on which to " +
- "listen for client requests. Defaults to " + nativeTransportPort);
+ Option nativeTransportPortOption = new Option("c", "client-port", true, "The port on which to "
+ + "listen for client requests. Defaults to " + nativeTransportPort);
nativeTransportPortOption.setArgName("PORT");
- Option storagePortOption = new Option(null, "storage-port", true, "The port on which to listen for requests " +
- " from other nodes. Defaults to " + storagePort);
+ Option storagePortOption = new Option(null, "storage-port", true, "The port on which to listen for requests "
+ + " from other nodes. Defaults to " + storagePort);
storagePortOption.setArgName("PORT");
- Option sslStoragePortOption = new Option(null, "ssl-storage-port", true, "The port on which to listen for " +
- "encrypted requests from other nodes. Only used when encryption is enabled. Defaults to " + sslStoragePort);
+ Option sslStoragePortOption = new Option(null, "ssl-storage-port", true, "The port on which to listen for "
+ + "encrypted requests from other nodes. Only used when encryption is enabled. Defaults to "
+ + sslStoragePort);
sslStoragePortOption.setArgName("PORT");
- Option startOption = new Option(null, "start", true, "Start the storage node after installing it on disk. " +
- "Defaults to true.");
+ Option startOption = new Option(null, "start", true, "Start the storage node after installing it on disk. "
+ + "Defaults to true.");
startOption.setArgName("true|false");
- Option checkStatus = new Option(null, "check-status", true, "Check the node status to verify that it is up " +
- "after starting it. This option is ignored if the start option is not set. Defaults to true.");
+ Option checkStatus = new Option(null, "check-status", true, "Check the node status to verify that it is up "
+ + "after starting it. This option is ignored if the start option is not set. Defaults to true.");
checkStatus.setArgName("true|false");
- Option commitLogOption = new Option(null, "commitlog", true, "The directory where the storage node keeps " +
- "commit log files. Defaults to " + commitLogDir + ".");
+ Option commitLogOption = new Option(null, "commitlog", true, "The directory where the storage node keeps "
+ + "commit log files. Defaults to " + commitLogDir + ".");
commitLogOption.setArgName("DIR");
- Option dataDirOption = new Option(null, "data", true, "The directory where the storage node keeps data files. " +
- "Defaults to " + dataDir + ".");
+ Option dataDirOption = new Option(null, "data", true, "The directory where the storage node keeps data files. "
+ + "Defaults to " + dataDir + ".");
dataDirOption.setArgName("DIR");
- Option savedCachesDirOption = new Option(null, "saved-caches", true, "The directory where the storage node " +
- "keeps saved cache files. Defaults to " + savedCachesDir + ".");
+ Option savedCachesDirOption = new Option(null, "saved-caches", true, "The directory where the storage node "
+ + "keeps saved cache files. Defaults to " + savedCachesDir + ".");
savedCachesDirOption.setArgName("DIR");
- Option basedirOption = new Option(null, "dir", true, "The directory where the storage node will be installed " +
- "The default directory will be " + storageBasedir);
+ Option basedirOption = new Option(null, "dir", true, "The directory where the storage node will be installed "
+ + "The default directory will be " + storageBasedir);
- options = new Options()
- .addOption(new Option("h", "help", false, "Show this message."))
+ options = new Options().addOption(new Option("h", "help", false, "Show this message."))
.addOption(hostname)
//.addOption(seeds)
- .addOption(jmxPortOption)
- .addOption(startOption)
- .addOption(checkStatus)
- .addOption(commitLogOption)
- .addOption(dataDirOption)
- .addOption(savedCachesDirOption)
- .addOption(nativeTransportPortOption)
- .addOption(storagePortOption)
- .addOption(sslStoragePortOption)
- .addOption(basedirOption);
+ .addOption(jmxPortOption).addOption(startOption).addOption(checkStatus).addOption(commitLogOption)
+ .addOption(dataDirOption).addOption(savedCachesDirOption).addOption(nativeTransportPortOption)
+ .addOption(storagePortOption).addOption(sslStoragePortOption).addOption(basedirOption);
}
public int run(CommandLine cmdLine) throws Exception {
@@ -231,8 +226,8 @@ public class StorageInstaller {
checkPerms(options.getOption("data"), dataDir, errors);
if (!errors.isEmpty()) {
- log.error("Problems have been detected with one or more of the directories in which the storage " +
- "node will need to store data");
+ log.error("Problems have been detected with one or more of the directories in which the storage "
+ + "node will need to store data");
for (String error : errors) {
log.error(error);
}
@@ -252,7 +247,7 @@ public class StorageInstaller {
PropertiesFileUpdate serverPropertiesUpdater = getServerProperties();
try {
serverPropertiesUpdater.update("rhq.cassandra.seeds", getSeedsProperty(seeds));
- } catch (IOException e) {
+ } catch (IOException e) {
throw new RuntimeException("An error occurred while trying to update RHQ server properties", e);
}
@@ -262,7 +257,7 @@ public class StorageInstaller {
String startupErrors = startNode(deploymentOptions);
if (startupErrors == null) {
boolean checkStatus = Boolean.parseBoolean(cmdLine.getOptionValue("check-status", "true"));
- if (checkStatus) {
+ if (checkStatus || isWindows()) { // no reliable pid file on windows
if (verifyNodeIsUp(jmxPort, 5, 3000)) {
log.info("RHQ Storage Node is up and running and ready to service client requests");
log.info("Installation of the storage node has completed successfully.");
@@ -275,24 +270,24 @@ public class StorageInstaller {
}
} else {
if (isRunning()) {
- log.info("Installation of the storage node is complete. The node should be up and " +
- "running");
+ log.info("Installation of the storage node is complete. The node should be up and "
+ + "running");
return STATUS_NO_ERRORS;
} else {
- log.warn("Installation of the storage node is complete, but the node does not appear to " +
- "be running. No start up errors were reported. Check the log file at " + logFile +
- " for any other possible errors.");
+ log.warn("Installation of the storage node is complete, but the node does not appear to "
+ + "be running. No start up errors were reported. Check the log file at " + logFile
+ + " for any other possible errors.");
return STATUS_STORAGE_NOT_RUNNING;
}
}
} else {
- log.error("The storage node reported the following errors while trying to start:\n\n" +
- startupErrors + "\n\n");
+ log.error("The storage node reported the following errors while trying to start:\n\n"
+ + startupErrors + "\n\n");
if (startupErrors.contains("java.net.BindException: Address already in use")) {
log.error("This error may indicate a conflict for the JMX port.");
}
- log.error("Please review your configuration for possible sources of errors such as port " +
- "conflicts or invalid arguments/options passed to the java executable.");
+ log.error("Please review your configuration for possible sources of errors such as port "
+ + "conflicts or invalid arguments/options passed to the java executable.");
log.error("The installer will now exit.");
return STATUS_STORAGE_NOT_RUNNING;
}
@@ -317,9 +312,9 @@ public class StorageInstaller {
} else {
File parent = findParentDir(new File(path));
if (!parent.canWrite()) {
- errors.add("The user running this installer does not appear to have write permissions to " + parent +
- ". Either make sure that the user running the storage node has write permissions or use the --" +
- option.getLongOpt() + " to change this value.");
+ errors.add("The user running this installer does not appear to have write permissions to " + parent
+ + ". Either make sure that the user running the storage node has write permissions or use the --"
+ + option.getLongOpt() + " to change this value.");
}
}
}
@@ -356,31 +351,98 @@ public class StorageInstaller {
}
private String startNode(DeploymentOptions deploymentOptions) throws Exception {
- File basedir = new File(deploymentOptions.getBasedir());
- File binDir = new File(basedir, "bin");
+ org.apache.commons.exec.CommandLine cmdLine;
+ String errOutput;
- File startScript;
if (isWindows()) {
- startScript = new File(binDir, "cassandra.bat");
+ File basedir = new File(System.getProperty("rhq.server.basedir"));
+ basedir = (null == basedir) ? new File(deploymentOptions.getBasedir()).getParentFile() : basedir;
+ File binDir = new File(basedir, "bin");
+
+ // First, stop the service if it exists
+ cmdLine = new org.apache.commons.exec.CommandLine("cmd.exe");
+ cmdLine.addArgument("/C");
+ cmdLine.addArgument("rhq-storage.bat");
+ cmdLine.addArgument("stop");
+ errOutput = exec(binDir, cmdLine);
+
+ if (!errOutput.isEmpty()) {
+ return errOutput;
+ }
+
+ // Second, remove it if it exists
+ cmdLine = new org.apache.commons.exec.CommandLine("cmd.exe");
+ cmdLine.addArgument("/C");
+ cmdLine.addArgument("rhq-storage.bat");
+ cmdLine.addArgument("remove");
+ errOutput = exec(binDir, cmdLine);
+
+ if (!errOutput.isEmpty()) {
+ return errOutput;
+ }
+
+ // Third installer the service
+ cmdLine = new org.apache.commons.exec.CommandLine("cmd.exe");
+ cmdLine.addArgument("/C");
+ cmdLine.addArgument("rhq-storage.bat");
+ cmdLine.addArgument("install");
+ errOutput = exec(binDir, cmdLine);
+
+ if (!errOutput.isEmpty()) {
+ return errOutput;
+ }
+
+ // Fourth, start the service
+ cmdLine = new org.apache.commons.exec.CommandLine("cmd.exe");
+ cmdLine.addArgument("/C");
+ cmdLine.addArgument("rhq-storage.bat");
+ cmdLine.addArgument("start");
+ errOutput = exec(binDir, cmdLine);
+
+ if (!errOutput.isEmpty()) {
+ return errOutput;
+ }
+
} else {
- startScript = new File(binDir, "cassandra");
+ File basedir = new File(deploymentOptions.getBasedir());
+ File binDir = new File(basedir, "bin");
+
+ cmdLine = new org.apache.commons.exec.CommandLine("cassandra");
+ cmdLine.addArgument("--PidFile");
+ cmdLine.addArgument("cassandra.pid");
+ errOutput = exec(binDir, cmdLine);
+
+ if (!errOutput.isEmpty()) {
+ return errOutput;
+ }
}
- org.apache.commons.exec.CommandLine cmdLine = new org.apache.commons.exec.CommandLine(startScript)
- .addArgument("-p")
- .addArgument(new File(binDir, "cassandra.pid").getAbsolutePath());
+ return null;
+ }
+ private String exec(File workingDir, org.apache.commons.exec.CommandLine cmdLine) throws Exception {
Executor executor = new DefaultExecutor();
- org.apache.commons.io.output.ByteArrayOutputStream buffer =
- new org.apache.commons.io.output.ByteArrayOutputStream();
+ org.apache.commons.io.output.ByteArrayOutputStream buffer = new org.apache.commons.io.output.ByteArrayOutputStream();
+ NullOutputStream nullOs = new NullOutputStream();
PumpStreamHandler streamHandler = new PumpStreamHandler(new NullOutputStream(), buffer);
+ executor.setWorkingDirectory(workingDir);
executor.setStreamHandler(streamHandler);
- executor.execute(cmdLine);
+ String result = "";
- if (buffer.size() > 0) {
- return buffer.toString();
+ try {
+ executor.execute(cmdLine);
+ result = buffer.toString();
+
+ } finally {
+ try {
+ buffer.close();
+ nullOs.close();
+ } catch (Exception e) {
+ // best effort
+ }
}
- return null;
+
+ return result;
}
private boolean isWindows() {
@@ -394,7 +456,13 @@ public class StorageInstaller {
}
private boolean verifyNodeIsUp(int jmxPort, int retries, long timeout) throws Exception {
- String url = "service:jmx:rmi:///jndi/rmi://localhost:" + jmxPort + "/jmxrmi";
+ String address;
+ try {
+ address = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e) {
+ address = "localhost";
+ }
+ String url = "service:jmx:rmi:///jndi/rmi://" + address + ":" + jmxPort + "/jmxrmi";
JMXServiceURL serviceURL = new JMXServiceURL(url);
JMXConnector connector = null;
MBeanServerConnection serverConnection = null;
@@ -405,7 +473,7 @@ public class StorageInstaller {
} catch (InterruptedException e) {
}
- Map<String, String> env = new HashMap<String, String>();
+ Map<String, String> env = new HashMap<String, String>();
env.put("java.naming.factory.initial", RMIContextFactory.class.getName());
for (int i = 0; i < retries; ++i) {
@@ -423,8 +491,8 @@ public class StorageInstaller {
log.debug("The storage node is not up.", e);
} else {
Throwable rootCause = ThrowableUtil.getRootCause(e);
- log.info("The storage node is not up: " + rootCause.getClass().getName() + ": " +
- rootCause.getMessage());
+ log.info("The storage node is not up: " + rootCause.getClass().getName() + ": "
+ + rootCause.getMessage());
}
log.info("Checking storage node status again in " + (timeout * (i + 1)) + " ms...");
}
@@ -437,7 +505,7 @@ public class StorageInstaller {
public void printUsage() {
Options options = getOptions();
HelpFormatter helpFormatter = new HelpFormatter();
- String syntax = "rhq-storage-installer.sh [options]";
+ String syntax = "rhq-storage-installer.sh|bat [options]";
String header = "";
helpFormatter.printHelp(syntax, header, options, null);
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.bat b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.bat
index 4277d74..63cc162 100644
--- a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.bat
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.bat
@@ -23,16 +23,14 @@ rem RHQ_SERVER_JAVA_HOME - The location of the JRE that the Server will
rem use. This will be ignored if
rem RHQ_SERVER_JAVA_EXE_FILE_PATH is set.
rem If this and RHQ_SERVER_JAVA_EXE_FILE_PATH are
-rem not set, the Server's embedded JRE will be used.
+rem not set, JAVA_HOME will be used.
rem
rem RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java
rem executable to use. If this is set,
rem RHQ_SERVER_JAVA_HOME is ignored.
rem If this is not set, then
rem %RHQ_SERVER_JAVA_HOME%\bin\java.exe
-rem is used. If this and
-rem RHQ_SERVER_JAVA_HOME are not set, the
-rem Server's embedded JRE will be used.
+rem is used.
rem
rem RHQ_SERVER_INSTANCE_NAME - The name of the Windows Service; it must
rem conform to the Windows Service naming
@@ -56,9 +54,6 @@ rem Note that you cannot define custom Java VM parameters or command line
rem arguments to pass to the RHQ Server standalone.sh. If you wish to pass in
rem specific arguments, modify the rhq-server-wrapper.conf file.
rem
-rem If the embedded JRE is to be used but is not available, the fallback
-rem JRE to be used will be determined by the JAVA_HOME environment variable.
-rem
rem This script does not use the built-in JBossAS run.bat.
rem ===========================================================================
@@ -89,17 +84,21 @@ set RHQ_SERVER_HOME=%CD%
if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_HOME: %RHQ_SERVER_HOME%
rem ----------------------------------------------------------------------
-rem Find the Java executable and verify we have a VM available.
+rem Find the Java executable and verify we have a VM available
rem ----------------------------------------------------------------------
if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH (
- if not defined RHQ_SERVER_JAVA_HOME call :prepare_embedded_jre
+ if not defined RHQ_SERVER_JAVA_HOME (
+ if defined RHQ_STORAGE_DEBUG echo No JRE found - will try to use JAVA_HOME: %JAVA_HOME%
+ set RHQ_SERVER_JAVA_HOME=%JAVA_HOME%
+ )
+)
+if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH (
+ set RHQ_SERVER_JAVA_EXE_FILE_PATH=%RHQ_SERVER_JAVA_HOME%\bin\java.exe
)
-if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH set RHQ_SERVER_JAVA_EXE_FILE_PATH=%RHQ_SERVER_JAVA_HOME%\bin\java.exe
-
-if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_JAVA_HOME: %RHQ_SERVER_JAVA_HOME%
-if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_JAVA_EXE_FILE_PATH: %RHQ_SERVER_JAVA_EXE_FILE_PATH%
+if defined RHQ_STORAGE_DEBUG echo RHQ_SERVER_JAVA_HOME: %RHQ_SERVER_JAVA_HOME%
+if defined RHQ_STORAGE_DEBUG echo RHQ_SERVER_JAVA_EXE_FILE_PATH: %RHQ_SERVER_JAVA_EXE_FILE_PATH%
if not exist "%RHQ_SERVER_JAVA_EXE_FILE_PATH%" (
echo There is no JVM available.
@@ -112,7 +111,7 @@ rem Define the name used for the name of the Windows Service.
rem If this is not defined, the name of the computer is used.
rem ----------------------------------------------------------------------
-if "%RHQ_SERVER_INSTANCE_NAME%"=="" (
+if not defined RHQ_SERVER_INSTANCE_NAME (
set RHQ_SERVER_INSTANCE_NAME=rhqserver-%COMPUTERNAME%
)
if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_INSTANCE_NAME: %RHQ_SERVER_INSTANCE_NAME%
@@ -149,12 +148,13 @@ rem ----------------------------------------------------------------------
rem Create and configure the wrapper log directory.
rem ----------------------------------------------------------------------
-if "%RHQ_SERVER_WRAPPER_LOG_DIR_PATH%" == "" (
- if not exist "%RHQ_SERVER_HOME%\logs" (
- mkdir "%RHQ_SERVER_HOME%\logs"
- )
+if not defined %RHQ_SERVER_WRAPPER_LOG_DIR_PATH (
set RHQ_SERVER_WRAPPER_LOG_DIR_PATH=%RHQ_SERVER_HOME%\logs
)
+if not exist "RHQ_SERVER_WRAPPER_LOG_DIR_PATH" (
+ mkdir "%RHQ_SERVER_WRAPPER_LOG_DIR_PATH%"
+)
+
if defined RHQ_SERVER_DEBUG echo RHQ_SERVER_WRAPPER_LOG_DIR_PATH: %RHQ_SERVER_WRAPPER_LOG_DIR_PATH%
rem ----------------------------------------------------------------------
@@ -204,18 +204,6 @@ if /i "%1"=="status" (
echo Usage: %0 { install ^| start ^| stop ^| remove ^| status ^| console }
goto :done
-rem ----------------------------------------------------------------------
-rem CALL subroutine that prepares to use the embedded JRE
-rem ----------------------------------------------------------------------
-
-:prepare_embedded_jre
-set RHQ_SERVER_JAVA_HOME=%RHQ_SERVER_HOME%\jre
-if defined RHQ_SERVER_DEBUG echo Using the embedded JRE
-if not exist "%RHQ_SERVER_JAVA_HOME%" (
- if defined RHQ_SERVER_DEBUG echo No embedded JRE found - will try to use JAVA_HOME: %JAVA_HOME%
- set RHQ_SERVER_JAVA_HOME=%JAVA_HOME%
-)
-goto :eof
rem ----------------------------------------------------------------------
rem CALL subroutine that exits this script normally
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.sh b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.sh
index 42c8e45..38b45df 100755
--- a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.sh
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-server.sh
@@ -36,16 +36,14 @@
# use. This will be ignored if
# RHQ_SERVER_JAVA_EXE_FILE_PATH is set.
# If this and RHQ_SERVER_JAVA_EXE_FILE_PATH are
-# not set, the Server's embedded JRE will be used.
+# not set, JAVA_HOME will be used.
#
# RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java
# executable to use. If this is set,
# RHQ_SERVER_JAVA_HOME is ignored.
# If this is not set, then
# $RHQ_SERVER_JAVA_HOME/bin/java
-# is used. If this and
-# RHQ_SERVER_JAVA_HOME are not set, the
-# Server's embedded JRE will be used.
+# is used.
#
# RHQ_SERVER_JAVA_OPTS - Java VM command line options to be
# passed into the Server's VM. If this is not defined
@@ -82,9 +80,6 @@
# If not defined, this defaults to the Server's
# bin directory.
#
-# If the embedded JRE is to be used but is not available, the fallback
-# JRE to be used will be determined by the JAVA_HOME environment variable.
-#
# This script calls standalone.sh when starting the underlying JBossAS server.
# =============================================================================
@@ -309,13 +304,8 @@ fi
if [ -z "$RHQ_SERVER_JAVA_EXE_FILE_PATH" ]; then
if [ -z "$RHQ_SERVER_JAVA_HOME" ]; then
- RHQ_SERVER_JAVA_HOME="${RHQ_SERVER_HOME}/jre"
- if [ -d "$RHQ_SERVER_JAVA_HOME" ]; then
- debug_msg "Using the embedded JRE"
- else
- debug_msg "No embedded JRE found - will try to use JAVA_HOME: $JAVA_HOME"
- RHQ_SERVER_JAVA_HOME="$JAVA_HOME"
- fi
+ debug_msg "No JRE found - will try to use JAVA_HOME: $JAVA_HOME"
+ RHQ_SERVER_JAVA_HOME="$JAVA_HOME"
fi
debug_msg "RHQ_SERVER_JAVA_HOME: $RHQ_SERVER_JAVA_HOME"
RHQ_SERVER_JAVA_EXE_FILE_PATH="${RHQ_SERVER_JAVA_HOME}/bin/java"
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-storage-installer.bat b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-storage-installer.bat
new file mode 100644
index 0000000..c9fd2ff
--- /dev/null
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-storage-installer.bat
@@ -0,0 +1,199 @@
+@echo off
+
+rem =============================================================================
+rem RHQ Storage Installer Script
+rem
+rem This file is used to complete the installation of the RHQ storage Server on a
+rem UNIX platform.
+rem
+rem This script is customizable by setting the following environment variables:
+rem
+rem RHQ_STORAGE_DEBUG - If this is defined, the script will emit debug
+rem messages. If this is not defined or set to "false"
+rem debug messages are not emitted.
+rem
+rem RHQ_SERVER_HOME - Defines where the server's home install directory is.
+rem If not defined, it will be assumed to be the parent
+rem directory of the directory where this script lives.
+rem
+rem RHQ_SERVER_JBOSS_HOME - The location of the AS instance that will
+rem host RHQ. If this is set, it overrides any
+rem JBOSS_HOME that might be set. If this not
+rem set, JBOSS_HOME is used as a fallback. If
+rem neither is set, it is assumed the AS bundled
+rem under RHQ_SERVER_HOME\jbossas is to be used.
+rem
+rem RHQ_SERVER_JAVA_HOME - The location of the JRE that the server will
+rem use. This will be ignored if
+rem RHQ_SERVER_JAVA_EXE_FILE_PATH is set.
+rem If this and RHQ_SERVER_JAVA_EXE_FILE_PATH are
+rem not set, JAVA_HOME will be used.
+rem
+rem RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java
+rem executable to use. If this is set,
+rem RHQ_SERVER_JAVA_HOME is ignored.
+rem If this is not set, then
+rem $RHQ_SERVER_JAVA_HOME\bin\java
+rem is used.
+rem
+rem RHQ_STORAGE_INSTALLER_JAVA_OPTS - Java VM command line options to be
+rem passed into the Java VM. If this is not defined
+rem this script will pass in a default set of options.
+rem If you only want to add options to the defaults,
+rem then you will want to use
+rem RHQ_STORAGE_ADDITIONAL_JAVA_OPTS instead.
+rem
+rem RHQ_STORAGE_INSTALLER_ADDITIONAL_JAVA_OPTS - additional Java VM command
+rem line options to be passed into the VM.
+rem This is added to RHQ_STORAGE_JAVA_OPTS; it
+rem is mainly used to augment the
+rem default set of options. This can be
+rem left unset if it is not needed.
+rem
+rem =============================================================================
+
+setlocal
+
+rem if debug variable is set, it is assumed to be on, unless its value is false
+if "%RHQ_STORAGE_DEBUG%" == "false" (
+ set RHQ_STORAGE_DEBUG=
+)
+
+rem ----------------------------------------------------------------------
+rem Change directory so the current directory is the Server home.
+rem ----------------------------------------------------------------------
+
+set RHQ_SERVER_BIN_DIR_PATH=%~dp0
+
+if not defined RHQ_SERVER_HOME (
+ cd "%RHQ_SERVER_BIN_DIR_PATH%\.."
+) else (
+ cd "%RHQ_SERVER_HOME%" || (
+ echo Cannot go to the RHQ_SERVER_HOME directory: %RHQ_SERVER_HOME%
+ exit /B 1
+ )
+)
+
+set RHQ_SERVER_HOME=%CD%
+
+if defined RHQ_STORAGE_DEBUG echo RHQ_SERVER_HOME: %RHQ_SERVER_HOME%
+
+rem ----------------------------------------------------------------------
+rem Determine what JBossAS instance to use.
+rem If RHQ_SERVER_JBOSS_HOME and JBOSS_HOME are both not defined, we will
+rem assume we are to run the embedded AS instance from the RHQ
+rem installation directory - RHQ_SERVER_HOME\jbossas
+rem ----------------------------------------------------------------------
+
+if not defined RHQ_SERVER_JBOSS_HOME (
+ if not defined JBOSS_HOME (
+ set RHQ_SERVER_JBOSS_HOME=%RHQ_SERVER_HOME%\jbossas
+ ) else (
+ if not exist "%JBOSS_HOME%" (
+ echo ERROR! JBOSS_HOME is not pointing to a valid AS directory
+ echo JBOSS_HOME: "%JBOSS_HOME%"
+ exit /B 1
+ )
+ set RHQ_SERVER_JBOSS_HOME=%JBOSS_HOME%
+ )
+) else (
+ cd %RHQ_SERVER_JBOSS_HOME% || (
+ echo ERROR! RHQ_SERVER_JBOSS_HOME is not pointing to a valid AS directory
+ echo RHQ_SERVER_JBOSS_HOME: "%RHQ_SERVER_JBOSS_HOME%"
+ exit /B 1
+ )
+)
+
+cd %RHQ_SERVER_JBOSS_HOME%
+set RHQ_SERVER_JBOSS_HOME=%CD%
+
+if defined RHQ_STORAGE_DEBUG echo RHQ_SERVER_JBOSS_HOME: %RHQ_SERVER_JBOSS_HOME%
+
+
+if not exist "%RHQ_SERVER_JBOSS_HOME%\jboss-modules.jar" (
+ echo ERROR! RHQ_SERVER_JBOSS_HOME is not pointing to a valid AS instance
+ echo Missing "%RHQ_SERVER_JBOSS_HOME%\jboss-modules.jar"
+ exit /B 1
+)
+
+rem we want the rest of this script to be able to assume cwd is the RHQ install dir
+cd "%RHQ_SERVER_HOME%"
+
+
+rem ----------------------------------------------------------------------
+rem Create the logs directory
+rem ----------------------------------------------------------------------
+
+set _LOG_DIR_PATH=%RHQ_SERVER_HOME%\logs
+if not exist "%_LOG_DIR_PATH%" (
+ mkdir "%_LOG_DIR_PATH%"
+)
+
+
+rem ----------------------------------------------------------------------
+rem Find the Java executable and verify we have a VM available
+rem ----------------------------------------------------------------------
+
+if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH (
+ if not defined RHQ_SERVER_JAVA_HOME (
+ if defined RHQ_STORAGE_DEBUG echo No JRE found - will try to use JAVA_HOME: %JAVA_HOME%
+ set RHQ_SERVER_JAVA_HOME=%JAVA_HOME%
+ )
+)
+if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH (
+ set RHQ_SERVER_JAVA_EXE_FILE_PATH=%RHQ_SERVER_JAVA_HOME%\bin\java.exe
+)
+
+if defined RHQ_STORAGE_DEBUG echo RHQ_SERVER_JAVA_HOME: %RHQ_SERVER_JAVA_HOME%
+if defined RHQ_STORAGE_DEBUG echo RHQ_SERVER_JAVA_EXE_FILE_PATH: %RHQ_SERVER_JAVA_EXE_FILE_PATH%
+
+if not exist "%RHQ_SERVER_JAVA_EXE_FILE_PATH%" (
+ echo There is no JVM available.
+ echo Please set RHQ_SERVER_JAVA_HOME or RHQ_SERVER_JAVA_EXE_FILE_PATH appropriately.
+ exit /B 1
+)
+
+
+rem ----------------------------------------------------------------------
+rem Prepare the VM command line options to be passed in
+rem ----------------------------------------------------------------------
+
+if not defined RHQ_STORAGE_INSTALLER_JAVA_OPTS (
+ set RHQ_STORAGE_INSTALLER_JAVA_OPTS=-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=128M -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true
+)
+
+rem Add the JVM opts that we always want to specify, whether or not the user set RHQ_CCM_JAVA_OPTS.
+if defined RHQ_STORAGE_DEBUG (
+ set _RHQ_LOGLEVEL=DEBUG
+) else (
+ set _RHQ_LOGLEVEL=INFO
+)
+
+
+rem debugging the logging level now for development/testing
+set RHQ_STORAGE_INSTALLER_JAVA_OPTS=%RHQ_STORAGE_INSTALLER_JAVA_OPTS% -Djava.awt.headless=true -Drhq.server.properties-file=%RHQ_SERVER_HOME%\bin\rhq-server.properties -Drhq.storage.installer.logdir=%RHQ_SERVER_HOME%\logs -Drhq.storage.installer.loglevel=%_RHQ_LOGLEVEL% -Drhq.server.basedir=%RHQ_SERVER_HOME%
+
+rem Sample JPDA settings for remote socket debugging
+rem set RHQ_STORAGE_INSTALLER_JAVA_OPTS=%RHQ_STORAGE_INSTALLER_JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
+
+if defined RHQ_STORAGE_DEBUG echo "RHQ_STORAGE_INSTALLER_JAVA_OPTS: %RHQ_STORAGE_INSTALLER_JAVA_OPTS%"
+if defined RHQ_STORAGE_DEBUG echo "RHQ_STORAGE_INSTALLER_ADDITIONAL_JAVA_OPTS: %RHQ_STORAGE_INSTALLER_ADDITIONAL_JAVA_OPTS%"
+
+
+rem ----------------------------------------------------------------------
+rem We need to add our own modules to the core set of JBossAS modules.
+rem ----------------------------------------------------------------------
+set _RHQ_MODULES_PATH=%RHQ_SERVER_HOME%\modules
+set _INTERNAL_MODULES_PATH=%RHQ_SERVER_JBOSS_HOME%\modules
+set _JBOSS_MODULEPATH=%_RHQ_MODULES_PATH%;%_INTERNAL_MODULES_PATH%
+
+if defined RHQ_STORAGE_DEBUG echo _JBOSS_MODULEPATH: %_JBOSS_MODULEPATH%
+
+
+echo "Starting RHQ Storage Installer ..."
+
+rem start the AS instance with our main installer module
+"%RHQ_SERVER_JAVA_EXE_FILE_PATH%" %RHQ_STORAGE_INSTALLER_JAVA_OPTS% %RHQ_STORAGE_INSTALLER_ADDITIONAL_JAVA_OPTS% -jar "%RHQ_SERVER_JBOSS_HOME%\jboss-modules.jar" -mp "%_JBOSS_MODULEPATH%" org.rhq.rhq-cassandra-installer %*
+
+:done
+endlocal
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-storage.bat b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-storage.bat
new file mode 100644
index 0000000..5058874
--- /dev/null
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhq-storage.bat
@@ -0,0 +1,232 @@
+@echo off
+
+rem ===========================================================================
+rem RHQ Storage Node (Cassandra) Windows Startup Script
+rem
+rem This file is used to install, start, stop and remove the RHQ Storage Node
+rem (cassandra) Windows Service for the Windows platform. The RHQ Storage node
+rem is actually wrapped by the Java Service Wrapper (JSW) and it is the JSW that
+rem is the actual executable that is registered as the Windows Service.
+rem
+rem This script is customizable by setting the following environment variables:
+rem
+
+rem RHQ_STORAGE_DEBUG - If this is defined, the script will emit debug
+rem messages. If unset or "false", debug is turned off.
+rem
+rem RHQ_SERVER_HOME - Defines where the Server's home install directory is.
+rem If not defined, it will be assumed to be the parent
+rem directory of the directory where this script lives.
+rem
+rem RHQ_STORAGE_HOME - Defines where the Storage Node's home install directory
+rem is. If not defined, it will be assumed to be
+rem %RHQ_SERVER_HOME%\rhq-storage.
+rem
+rem RHQ_SERVER_JAVA_HOME - The location of the JRE that the Server will
+rem use. This will be ignored if
+rem RHQ_SERVER_JAVA_EXE_FILE_PATH is set. If this and
+rem RHQ_SERVER_JAVA_EXE_FILE_PATH are not set, JAVA_HOME
+rem will be used.
+rem
+rem RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java
+rem executable to use. If this is set, RHQ_SERVER_JAVA_HOME
+rem is ignored. If this is not set, then
+rem %RHQ_SERVER_JAVA_HOME%\bin\java.exe is used.
+rem
+rem RHQ_STORAGE_INSTANCE_NAME - The name of the Windows Service; it must
+rem conform to the Windows Service naming conventions. By
+rem default, this is the name "rhqstorage-%COMPUTERNAME%"
+rem
+rem RHQ_STORAGE_WRAPPER_LOG_DIR_PATH - The full path to the location where
+rem the wrapper log file will go.
+rem
+rem RHQ_STORAGE_RUN_AS - if defined, then when the Windows Service is
+rem installed, the value is the domain\username of the
+rem user that the Windows Service will run as
+rem
+rem RHQ_STORAGE_RUN_AS_ME - if defined, then when the Windows Service is
+rem installed, the domain\username of the user that the Windows
+rem Service will run as will be the current user (.\%USERNAME%).
+rem This takes precedence over RHQ_STORAGE_RUN_AS.
+rem
+rem Note that you cannot define custom Java VM parameters or command line
+rem arguments to pass to Cassandra. If you wish to pass in specific arguments,
+rem modify the rhq-storage-wrapper.conf file.
+rem
+rem This script does not use the built-in cassandra.bat.
+rem ===========================================================================
+
+setlocal
+
+rem if debug variable is set, it is assumed to be on, unless its value is false
+if "%RHQ_STORAGE_DEBUG%" == "false" (
+ set RHQ_STORAGE_DEBUG=
+)
+
+rem ----------------------------------------------------------------------
+rem Change directory so the current directory is the Server home.
+rem ----------------------------------------------------------------------
+
+set RHQ_SERVER_BIN_DIR_PATH=%~dp0
+
+if not defined RHQ_SERVER_HOME (
+ cd "%RHQ_SERVER_BIN_DIR_PATH%\.."
+) else (
+ cd "%RHQ_SERVER_HOME%" || (
+ echo Cannot go to the RHQ_SERVER_HOME directory: %RHQ_SERVER_HOME%
+ exit /B 1
+ )
+)
+
+set RHQ_SERVER_HOME=%CD%
+
+if defined RHQ_STORAGE_DEBUG echo RHQ_SERVER_HOME: %RHQ_SERVER_HOME%
+
+rem ----------------------------------------------------------------------
+rem Change directory so the current directory is the Server home.
+rem ----------------------------------------------------------------------
+
+set RHQ_STORAGE_BIN_DIR_PATH=%~dp0
+
+if not defined RHQ_STORAGE_HOME (
+ set RHQ_STORAGE_HOME=%RHQ_SERVER_HOME%\rhq-storage
+)
+set RHQ_STORAGE_BIN_DIR_PATH=%RHQ_STORAGE_HOME%\bin
+
+if not exist %RHQ_STORAGE_BIN_DIR_PATH% (
+ echo Cannot find the RHQ_STORAGE bin directory: %RHQ_STORAGE_BIN_DIR_PATH%
+ exit /B 1
+)
+
+if defined RHQ_STORAGE_DEBUG echo RHQ_STORAGE_HOME: %RHQ_STORAGE_HOME%
+
+rem ----------------------------------------------------------------------
+rem Find the Java executable and verify we have a VM available
+
+rem ----------------------------------------------------------------------
+
+if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH (
+ if not defined RHQ_SERVER_JAVA_HOME (
+ if defined RHQ_STORAGE_DEBUG echo No JRE found - will try to use JAVA_HOME: %JAVA_HOME%
+ set RHQ_SERVER_JAVA_HOME=%JAVA_HOME%
+ )
+)
+if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH (
+ set RHQ_SERVER_JAVA_EXE_FILE_PATH=%RHQ_SERVER_JAVA_HOME%\bin\java.exe
+)
+
+if defined RHQ_STORAGE_DEBUG echo RHQ_SERVER_JAVA_HOME: %RHQ_SERVER_JAVA_HOME%
+if defined RHQ_STORAGE_DEBUG echo RHQ_SERVER_JAVA_EXE_FILE_PATH: %RHQ_SERVER_JAVA_EXE_FILE_PATH%
+
+if not exist "%RHQ_SERVER_JAVA_EXE_FILE_PATH%" (
+ echo There is no JVM available.
+ echo Please set RHQ_SERVER_JAVA_HOME or RHQ_SERVER_JAVA_EXE_FILE_PATH appropriately.
+ exit /B 1
+)
+
+
+rem ----------------------------------------------------------------------
+rem Define the name used for the name of the Windows Service.
+rem If this is not defined, the name of the computer is used.
+rem ----------------------------------------------------------------------
+
+if not defined RHQ_STORAGE_INSTANCE_NAME (
+ set RHQ_STORAGE_INSTANCE_NAME=rhqstorage-%COMPUTERNAME%
+)
+if defined RHQ_STORAGE_DEBUG echo RHQ_STORAGE_INSTANCE_NAME: %RHQ_STORAGE_INSTANCE_NAME%
+
+rem ----------------------------------------------------------------------
+rem Determine the wrapper directory.
+rem ----------------------------------------------------------------------
+
+set RHQ_STORAGE_WRAPPER_DIR_PATH=%RHQ_SERVER_BIN_DIR_PATH%\wrapper
+if defined RHQ_STORAGE_DEBUG echo RHQ_STORAGE_WRAPPER_DIR_PATH: %RHQ_STORAGE_WRAPPER_DIR_PATH%
+
+rem ----------------------------------------------------------------------
+rem The Windows OS platform name is also the wrapper subdirectory name.
+rem ----------------------------------------------------------------------
+
+set RHQ_STORAGE_OS_PLATFORM=windows-x86_32
+if defined RHQ_STORAGE_DEBUG echo RHQ_STORAGE_OS_PLATFORM: %RHQ_STORAGE_OS_PLATFORM%
+
+rem ----------------------------------------------------------------------
+rem Determine the wrapper executable that this script will run.
+rem ----------------------------------------------------------------------
+
+set RHQ_STORAGE_WRAPPER_EXE_FILE_PATH=%RHQ_STORAGE_WRAPPER_DIR_PATH%\%RHQ_STORAGE_OS_PLATFORM%\wrapper.exe
+if defined RHQ_STORAGE_DEBUG echo RHQ_STORAGE_WRAPPER_EXE_FILE_PATH: %RHQ_STORAGE_WRAPPER_EXE_FILE_PATH%
+
+rem ----------------------------------------------------------------------
+rem Determine the Storage wrapper configuration file.
+rem ----------------------------------------------------------------------
+
+set RHQ_STORAGE_WRAPPER_CONF_FILE_PATH=%RHQ_STORAGE_WRAPPER_DIR_PATH%\rhq-storage-wrapper.conf
+if defined RHQ_STORAGE_DEBUG echo RHQ_STORAGE_WRAPPER_CONF_FILE_PATH: %RHQ_STORAGE_WRAPPER_CONF_FILE_PATH%
+
+rem ----------------------------------------------------------------------
+rem Create and configure the wrapper log directory.
+rem ----------------------------------------------------------------------
+
+if not defined RHQ_STORAGE_WRAPPER_LOG_DIR_PATH (
+ set RHQ_STORAGE_WRAPPER_LOG_DIR_PATH=%RHQ_SERVER_HOME%\logs
+)
+if not exist "%RHQ_STORAGE_WRAPPER_LOG_DIR_PATH%" (
+ mkdir "%RHQ_STORAGE_WRAPPER_LOG_DIR_PATH%"
+)
+
+if defined RHQ_STORAGE_DEBUG echo RHQ_STORAGE_WRAPPER_LOG_DIR_PATH: %RHQ_STORAGE_WRAPPER_LOG_DIR_PATH%
+
+rem ----------------------------------------------------------------------
+rem Determine what to do and do it.
+rem ----------------------------------------------------------------------
+
+rem Determine if there should be debug VM options passed into it.
+rem For some reason, this can't go inside another if statement.
+if defined RHQ_STORAGE_DEBUG set _DEBUG_OPTS=wrapper.debug=true
+
+rem Determine what user the Windows Service will run as.
+if defined RHQ_STORAGE_RUN_AS set _WRAPPER_NTSERVICE_ACCOUNT="wrapper.ntservice.account=%RHQ_STORAGE_RUN_AS%"
+if defined RHQ_STORAGE_RUN_AS_ME set _WRAPPER_NTSERVICE_ACCOUNT="wrapper.ntservice.account=.\%USERNAME%"
+
+if /i "%1"=="console" (
+ rem START STORAGE NODE
+ start "%RHQ_STORAGE_WRAPPER_EXE_FILE_PATH%" -c "%RHQ_STORAGE_WRAPPER_CONF_FILE_PATH%" "set.RHQ_SERVER_HOME=%RHQ_SERVER_HOME%" "set.RHQ_STORAGE_HOME=%RHQ_STORAGE_HOME%" "set.RHQ_STORAGE_INSTANCE_NAME=%RHQ_STORAGE_INSTANCE_NAME%" "set.RHQ_SERVER_JAVA_EXE_FILE_PATH=%RHQ_SERVER_JAVA_EXE_FILE_PATH%" "set.RHQ_STORAGE_OS_PLATFORM=%RHQ_STORAGE_OS_PLATFORM%" "set.RHQ_STORAGE_WRAPPER_LOG_DIR_PATH=%RHQ_STORAGE_WRAPPER_LOG_DIR_PATH%" %_WRAPPER_NTSERVICE_ACCOUNT% %_DEBUG_OPTS%
+ goto done
+)
+
+if /i "%1"=="install" (
+ "%RHQ_STORAGE_WRAPPER_EXE_FILE_PATH%" -i "%RHQ_STORAGE_WRAPPER_CONF_FILE_PATH%" "set.RHQ_SERVER_HOME=%RHQ_SERVER_HOME%" "set.RHQ_STORAGE_HOME=%RHQ_STORAGE_HOME%" "set.RHQ_STORAGE_INSTANCE_NAME=%RHQ_STORAGE_INSTANCE_NAME%" "set.RHQ_SERVER_JAVA_EXE_FILE_PATH=%RHQ_SERVER_JAVA_EXE_FILE_PATH%" "set.RHQ_STORAGE_OS_PLATFORM=%RHQ_STORAGE_OS_PLATFORM%" "set.RHQ_STORAGE_WRAPPER_LOG_DIR_PATH=%RHQ_STORAGE_WRAPPER_LOG_DIR_PATH%" %_WRAPPER_NTSERVICE_ACCOUNT% %_DEBUG_OPTS%
+ goto done
+)
+
+if /i "%1"=="start" (
+ rem START STORAGE NODE
+ "%RHQ_STORAGE_WRAPPER_EXE_FILE_PATH%" -t "%RHQ_STORAGE_WRAPPER_CONF_FILE_PATH%"
+ goto done
+)
+
+if /i "%1"=="stop" (
+ "%RHQ_STORAGE_WRAPPER_EXE_FILE_PATH%" -p "%RHQ_STORAGE_WRAPPER_CONF_FILE_PATH%"
+ goto done
+)
+
+if /i "%1"=="remove" (
+ "%RHQ_STORAGE_WRAPPER_EXE_FILE_PATH%" -r "%RHQ_STORAGE_WRAPPER_CONF_FILE_PATH%"
+ goto done
+)
+
+if /i "%1"=="status" (
+ "%RHQ_STORAGE_WRAPPER_EXE_FILE_PATH%" -q "%RHQ_STORAGE_WRAPPER_CONF_FILE_PATH%"
+ goto done
+)
+
+echo Usage: %0 { install ^| start ^| stop ^| remove ^| status ^| console }
+goto :done
+
+
+rem ----------------------------------------------------------------------
+rem CALL subroutine that exits this script normally
+rem ----------------------------------------------------------------------
+
+:done
+endlocal
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl
new file mode 100644
index 0000000..89ac456
--- /dev/null
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl
@@ -0,0 +1,241 @@
+#!/bin/sh
+
+# =============================================================================
+# RHQ Storage Installer Script
+#
+# This file is used to complete the installation of the RHQ storage Server on a
+# UNIX platform.
+#
+# This script is customizable by setting the following environment variables:
+#
+# RHQ_CONTROL_DEBUG - If this is defined, the script will emit debug
+# messages. If this is not defined or set to "false"
+# debug messages are not emitted.
+#
+# RHQ_SERVER_HOME - Defines where the server's home install directory is.
+# If not defined, it will be assumed to be the parent
+# directory of the directory where this script lives.
+#
+# RHQ_SERVER_JBOSS_HOME - The location of the AS instance that will
+# host RHQ. If this is set, it overrides any
+# JBOSS_HOME that might be set. If this not
+# set, JBOSS_HOME is used as a fallback. If
+# neither is set, it is assumed the AS bundled
+# under RHQ_SERVER_HOME/jbossas is to be used.
+#
+# RHQ_SERVER_JAVA_HOME - The location of the JRE that the server will
+# use. This will be ignored if
+# RHQ_SERVER_JAVA_EXE_FILE_PATH is set.
+# If this and RHQ_SERVER_JAVA_EXE_FILE_PATH are
+# not set, the Server's embedded JRE will be used.
+#
+# RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java
+# executable to use. If this is set,
+# RHQ_SERVER_JAVA_HOME is ignored.
+# If this is not set, then
+# $RHQ_SERVER_JAVA_HOME/bin/java
+# is used. If this and
+# RHQ_SERVER_JAVA_HOME are not set, the
+# Server's embedded JRE will be used.
+#
+# RHQ_CONTROL_JAVA_OPTS - Java VM command line options to be
+# passed into the Java VM. If this is not defined
+# this script will pass in a default set of options.
+# If you only want to add options to the defaults,
+# then you will want to use
+# RHQ_CONTROL_ADDITIONAL_JAVA_OPTS instead.
+#
+# RHQ_CONTROL_ADDITIONAL_JAVA_OPTS - additional Java VM command
+# line options to be passed into the VM.
+# This is added to RHQ_CONTROL_JAVA_OPTS; it
+# is mainly used to augment the
+# default set of options. This can be
+# left unset if it is not needed.
+#
+# If the embedded JRE is to be used but is not available, the fallback
+# JRE to be used will be determined by the JAVA_HOME environment variable.
+# =============================================================================
+
+debug_msg ()
+{
+ # if debug variable is set, it is assumed to be on, unless its value is false
+ if [ -n "$RHQ_CONTROL_DEBUG" ] && [ "$RHQ_CONTROL_DEBUG" != "false" ]; then
+ echo $1
+ fi
+}
+
+# ----------------------------------------------------------------------
+# Determine what specific platform we are running on.
+# Set some platform-specific variables.
+# ----------------------------------------------------------------------
+
+case "`uname`" in
+ CYGWIN*) _CYGWIN=true
+ ;;
+ Linux*) _LINUX=true
+ ;;
+ Darwin*) _DARWIN=true
+ ;;
+ SunOS*) _SOLARIS=true
+ ;;
+ AIX*) _AIX=true
+ ;;
+esac
+
+# only certain platforms support the -e argument for readlink
+if [ -n "${_LINUX}${_SOLARIS}${_CYGWIN}" ]; then
+ _READLINK_ARG="-e"
+fi
+
+# ----------------------------------------------------------------------
+# Determine the RHQ Server installation directory.
+# If RHQ_SERVER_HOME is not defined, we will assume we are running
+# directly from the server installation's bin directory.
+# ----------------------------------------------------------------------
+
+if [ -z "$RHQ_SERVER_HOME" ]; then
+ _DOLLARZERO=`readlink $_READLINK_ARG "$0" 2>/dev/null || echo "$0"`
+ RHQ_SERVER_HOME=`dirname "$_DOLLARZERO"`/..
+else
+ if [ ! -d "$RHQ_SERVER_HOME" ]; then
+ echo "ERROR! RHQ_SERVER_HOME is not pointing to a valid directory"
+ echo "RHQ_SERVER_HOME: $RHQ_SERVER_HOME"
+ exit 1
+ fi
+fi
+
+cd "$RHQ_SERVER_HOME"
+RHQ_SERVER_HOME=`pwd`
+
+debug_msg "RHQ_SERVER_HOME: $RHQ_SERVER_HOME"
+
+# ----------------------------------------------------------------------
+# Determine what JBossAS instance to use.
+# If RHQ_SERVER_JBOSS_HOME and JBOSS_HOME are both not defined, we will
+# assume we are to run the embedded AS instance from the RHQ
+# installation directory - RHQ_SERVER_HOME/jbossas
+# ----------------------------------------------------------------------
+
+if [ -z "$RHQ_SERVER_JBOSS_HOME" ]; then
+ if [ -z "$JBOSS_HOME" ]; then
+ RHQ_SERVER_JBOSS_HOME="${RHQ_SERVER_HOME}/jbossas"
+ else
+ if [ ! -d "$JBOSS_HOME" ]; then
+ echo "ERROR! JBOSS_HOME is not pointing to a valid AS directory"
+ echo "JBOSS_HOME: $JBOSS_HOME"
+ exit 1
+ fi
+ RHQ_SERVER_JBOSS_HOME="${JBOSS_HOME}"
+ fi
+else
+ if [ ! -d "$RHQ_SERVER_JBOSS_HOME" ]; then
+ echo "ERROR! RHQ_SERVER_JBOSS_HOME is not pointing to a valid AS directory"
+ echo "RHQ_SERVER_JBOSS_HOME: $RHQ_SERVER_JBOSS_HOME"
+ exit 1
+ fi
+fi
+
+cd "$RHQ_SERVER_JBOSS_HOME"
+RHQ_SERVER_JBOSS_HOME=`pwd`
+
+debug_msg "RHQ_SERVER_JBOSS_HOME: $RHQ_SERVER_JBOSS_HOME"
+
+if [ ! -f "${RHQ_SERVER_JBOSS_HOME}/jboss-modules.jar" ]; then
+ echo "ERROR! RHQ_SERVER_JBOSS_HOME is not pointing to a valid AS instance"
+ echo "Missing ${RHQ_SERVER_JBOSS_HOME}/jboss-modules.jar"
+ exit 1
+fi
+
+# we want the rest of this script to be able to assume cwd is the RHQ install dir
+cd "$RHQ_SERVER_HOME"
+
+# ----------------------------------------------------------------------
+# if we are on a Mac and JAVA_HOME is not set, then set it to /usr
+# as this is the default location.
+# ----------------------------------------------------------------------
+
+if [ -z "$JAVA_HOME" ]; then
+ if [ -n "$_DARWIN" ]; then
+ debug_msg "Running on Mac OS X, setting JAVA_HOME to /usr"
+ JAVA_HOME=/usr
+ fi
+fi
+
+# ----------------------------------------------------------------------
+# Create the logs directory
+# ----------------------------------------------------------------------
+
+_LOG_DIR_PATH="${RHQ_SERVER_HOME}/logs"
+if [ -n "$_CYGWIN" ]; then
+ _LOG_DIR_PATH=`cygpath --windows --path "$_LOG_DIR_PATH"`
+fi
+if [ ! -d "${_LOG_DIR_PATH}" ]; then
+ mkdir "${_LOG_DIR_PATH}"
+fi
+
+# ----------------------------------------------------------------------
+# Find the Java executable and verify we have a VM available
+# ----------------------------------------------------------------------
+
+if [ -z "$RHQ_SERVER_JAVA_EXE_FILE_PATH" ]; then
+ if [ -z "$RHQ_SERVER_JAVA_HOME" ]; then
+ RHQ_SERVER_JAVA_HOME="${RHQ_SERVER_HOME}/jre"
+ if [ -d "$RHQ_SERVER_JAVA_HOME" ]; then
+ debug_msg "Using the embedded JRE"
+ else
+ debug_msg "No embedded JRE found - will try to use JAVA_HOME: $JAVA_HOME"
+ RHQ_SERVER_JAVA_HOME="$JAVA_HOME"
+ fi
+ fi
+ debug_msg "RHQ_SERVER_JAVA_HOME: $RHQ_SERVER_JAVA_HOME"
+ RHQ_SERVER_JAVA_EXE_FILE_PATH="${RHQ_SERVER_JAVA_HOME}/bin/java"
+fi
+debug_msg "RHQ_SERVER_JAVA_EXE_FILE_PATH: $RHQ_SERVER_JAVA_EXE_FILE_PATH"
+
+if [ ! -f "$RHQ_SERVER_JAVA_EXE_FILE_PATH" ]; then
+ echo "There is no JVM available."
+ echo "Please set RHQ_SERVER_JAVA_HOME or RHQ_SERVER_JAVA_EXE_FILE_PATH appropriately."
+ exit 1
+fi
+
+# ----------------------------------------------------------------------
+# Prepare the VM command line options to be passed in
+# ----------------------------------------------------------------------
+
+if [ -z "$RHQ_CONTROL_JAVA_OPTS" ]; then
+ RHQ_CONTROL_JAVA_OPTS="-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=128M -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true"
+fi
+
+# Add the JVM opts that we always want to specify, whether or not the user set RHQ_CCM_JAVA_OPTS.
+if [ -n "$RHQ_CONTROL_DEBUG" ] && [ "$RHQ_CONTROL_DEBUG" != "false" ]; then
+ _RHQ_LOGLEVEL="DEBUG"
+else
+ _RHQ_LOGLEVEL="INFO"
+fi
+
+# debugging the logging level now for development/testing
+RHQ_CONTROL_JAVA_OPTS="${RHQ_CONTROL_JAVA_OPTS} -Djava.awt.headless=true -Drhq.server.properties-file=${RHQ_SERVER_HOME}/bin/rhq-server.properties -Drhq.control.logdir=${RHQ_SERVER_HOME}/logs -Drhq.control.loglevel=${_RHQ_LOGLEVEL} -Drhq.server.basedir=${RHQ_SERVER_HOME} -Drhqctl.properties-file=$RHQ_SERVER_HOME/bin/rhqctl.properties"
+
+# Sample JPDA settings for remote socket debugging
+#RHQ_CONTROL_JAVA_OPTS="${RHQ_CONTROL_JAVA_OPTS} -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"
+
+debug_msg "RHQ_CONTROL_JAVA_OPTS: $RHQ_CONTROL_JAVA_OPTS"
+debug_msg "RHQ_CONTROL_ADDITIONAL_JAVA_OPTS: $RHQ_CONTROL_ADDITIONAL_JAVA_OPTS"
+
+# ----------------------------------------------------------------------
+# We need to add our own modules to the core set of JBossAS modules.
+# ----------------------------------------------------------------------
+_RHQ_MODULES_PATH="${RHQ_SERVER_HOME}/modules"
+_INTERNAL_MODULES_PATH="${RHQ_SERVER_JBOSS_HOME}/modules"
+if [ -n "$_CYGWIN" ]; then
+ _RHQ_MODULES_PATH=`cygpath --windows --path "$_RHQ_MODULES_PATH"`
+ _INTERNAL_MODULES_PATH=`cygpath --windows --path "$_INTERNAL_MODULES_PATH"`
+fi
+_JBOSS_MODULEPATH="${_RHQ_MODULES_PATH}:${_INTERNAL_MODULES_PATH}"
+debug_msg "_JBOSS_MODULEPATH: $_JBOSS_MODULEPATH"
+
+# start the AS instance with our main installer module
+"$RHQ_SERVER_JAVA_EXE_FILE_PATH" ${RHQ_CONTROL_JAVA_OPTS} ${RHQ_CONTROL_ADDITIONAL_JAVA_OPTS} -jar "${RHQ_SERVER_JBOSS_HOME}/jboss-modules.jar" -mp "$_JBOSS_MODULEPATH" org.rhq.rhq-server-control "$@"
+
+_EXIT_STATUS=$?
+exit $_EXIT_STATUS
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl.bat b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl.bat
new file mode 100644
index 0000000..2047e5b
--- /dev/null
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl.bat
@@ -0,0 +1,193 @@
+@echo off
+
+rem =============================================================================
+rem RHQ Storage Installer Script
+
+rem This file is used to control the RHQ components on a Windows machine.
+
+rem This script is customizable by setting the following environment variables:
+
+rem RHQ_CONTROL_DEBUG - If this is defined, the script will emit debug
+rem messages. If this is not defined or set to "false"
+rem debug messages are not emitted.
+
+rem RHQ_SERVER_HOME - Defines where the server's home install directory is.
+rem If not defined, it will be assumed to be the parent
+rem directory of the directory where this script lives.
+
+rem RHQ_SERVER_JBOSS_HOME - The location of the AS instance that will
+rem host RHQ. If this is set, it overrides any
+rem JBOSS_HOME that might be set. If this not
+rem set, JBOSS_HOME is used as a fallback. If
+rem neither is set, it is assumed the AS bundled
+rem under RHQ_SERVER_HOME\jbossas is to be used.
+
+rem RHQ_SERVER_JAVA_HOME - The location of the JRE that the server will
+rem use. This will be ignored if
+rem RHQ_SERVER_JAVA_EXE_FILE_PATH is set.
+rem If this and RHQ_SERVER_JAVA_EXE_FILE_PATH are
+rem not set, JAVA_HOME will be used.
+
+rem RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java
+rem executable to use. If this is set,
+rem RHQ_SERVER_JAVA_HOME is ignored.
+rem If this is not set, then
+rem $RHQ_SERVER_JAVA_HOME\bin\java
+rem is used.
+
+rem RHQ_CONTROL_JAVA_OPTS - Java VM command line options to be
+rem passed into the Java VM. If this is not defined
+rem this script will pass in a default set of options.
+rem If you only want to add options to the defaults,
+rem then you will want to use
+rem RHQ_CONTROL_ADDITIONAL_JAVA_OPTS instead.
+
+rem RHQ_CONTROL_ADDITIONAL_JAVA_OPTS - additional Java VM command
+rem line options to be passed into the VM.
+rem This is added to RHQ_CONTROL_JAVA_OPTS; it
+rem is mainly used to augment the
+rem default set of options. This can be
+rem left unset if it is not needed.
+
+rem =============================================================================
+
+setlocal
+
+rem if debug variable is set, it is assumed to be on, unless its value is false
+if "%RHQ_CONTROL_DEBUG%" == "false" (
+ set RHQ_CONTROL_DEBUG=
+)
+
+rem ----------------------------------------------------------------------
+rem Change directory so the current directory is the Server home.
+rem ----------------------------------------------------------------------
+
+set RHQ_SERVER_BIN_DIR_PATH=%~dp0
+
+if not defined RHQ_SERVER_HOME (
+ cd "%RHQ_SERVER_BIN_DIR_PATH%\.."
+) else (
+ cd "%RHQ_SERVER_HOME%" || (
+ echo Cannot go to the RHQ_SERVER_HOME directory: %RHQ_SERVER_HOME%
+ exit /B 1
+ )
+)
+
+set RHQ_SERVER_HOME=%CD%
+
+if defined RHQ_CONTROL_DEBUG echo RHQ_SERVER_HOME: %RHQ_SERVER_HOME%
+
+rem ----------------------------------------------------------------------
+rem Determine what JBossAS instance to use.
+rem If RHQ_SERVER_JBOSS_HOME and JBOSS_HOME are both not defined, we will
+rem assume we are to run the embedded AS instance from the RHQ
+rem installation directory - RHQ_SERVER_HOME\jbossas
+rem ----------------------------------------------------------------------
+
+if not defined RHQ_SERVER_JBOSS_HOME (
+ if not defined JBOSS_HOME (
+ set RHQ_SERVER_JBOSS_HOME=%RHQ_SERVER_HOME%\jbossas
+ ) else (
+ if not exist "%JBOSS_HOME%" (
+ echo ERROR! JBOSS_HOME is not pointing to a valid AS directory
+ echo JBOSS_HOME: "%JBOSS_HOME%"
+ exit /B 1
+ )
+ set RHQ_SERVER_JBOSS_HOME=%JBOSS_HOME%
+ )
+) else (
+ cd %RHQ_SERVER_JBOSS_HOME% || (
+ echo ERROR! RHQ_SERVER_JBOSS_HOME is not pointing to a valid AS directory
+ echo RHQ_SERVER_JBOSS_HOME: "%RHQ_SERVER_JBOSS_HOME%"
+ exit /B 1
+ )
+)
+
+cd %RHQ_SERVER_JBOSS_HOME%
+set RHQ_SERVER_JBOSS_HOME=%CD%
+
+if defined RHQ_CONTROL_DEBUG echo RHQ_SERVER_JBOSS_HOME: %RHQ_SERVER_JBOSS_HOME%
+
+
+if not exist "%RHQ_SERVER_JBOSS_HOME%\jboss-modules.jar" (
+ echo ERROR! RHQ_SERVER_JBOSS_HOME is not pointing to a valid AS instance
+ echo Missing "%RHQ_SERVER_JBOSS_HOME%\jboss-modules.jar"
+ exit /B 1
+)
+
+rem we want the rest of this script to be able to assume cwd is the RHQ install dir
+cd "%RHQ_SERVER_HOME%"
+
+
+rem ----------------------------------------------------------------------
+rem Create the logs directory
+rem ----------------------------------------------------------------------
+
+set _LOG_DIR_PATH=%RHQ_SERVER_HOME%\logs
+if not exist "%_LOG_DIR_PATH%" (
+ mkdir "%_LOG_DIR_PATH%"
+)
+
+
+rem ----------------------------------------------------------------------
+rem Find the Java executable and verify we have a VM available
+rem ----------------------------------------------------------------------
+
+if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH (
+ if not defined RHQ_SERVER_JAVA_HOME (
+ if defined RHQ_CONTROL_DEBUG echo No JRE found - will try to use JAVA_HOME: %JAVA_HOME%
+ set RHQ_SERVER_JAVA_HOME=%JAVA_HOME%
+ )
+)
+if not defined RHQ_SERVER_JAVA_EXE_FILE_PATH (
+ set RHQ_SERVER_JAVA_EXE_FILE_PATH=%RHQ_SERVER_JAVA_HOME%\bin\java.exe
+)
+
+if defined RHQ_CONTROL_DEBUG echo RHQ_SERVER_JAVA_HOME: %RHQ_SERVER_JAVA_HOME%
+if defined RHQ_CONTROL_DEBUG echo RHQ_SERVER_JAVA_EXE_FILE_PATH: %RHQ_SERVER_JAVA_EXE_FILE_PATH%
+
+if not exist "%RHQ_SERVER_JAVA_EXE_FILE_PATH%" (
+ echo There is no JVM available.
+ echo Please set RHQ_SERVER_JAVA_HOME or RHQ_SERVER_JAVA_EXE_FILE_PATH appropriately.
+ exit /B 1
+)
+
+
+rem ----------------------------------------------------------------------
+rem Prepare the VM command line options to be passed in
+rem ----------------------------------------------------------------------
+
+if not defined RHQ_CONTROL_JAVA_OPTS (
+ set RHQ_CONTROL_JAVA_OPTS=-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=128M -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true
+)
+
+rem Add the JVM opts that we always want to specify, whether or not the user set RHQ_CCM_JAVA_OPTS.
+if defined RHQ_CONTROL_DEBUG (
+ set _RHQ_LOGLEVEL=DEBUG
+) else (
+ set _RHQ_LOGLEVEL=INFO
+)
+
+rem debugging the logging level now for development/testing
+set RHQ_CONTROL_JAVA_OPTS=%RHQ_CONTROL_JAVA_OPTS% -Djava.awt.headless=true -Drhq.server.properties-file=%RHQ_SERVER_HOME%\bin\rhq-server.properties -Drhq.control.logdir=%RHQ_SERVER_HOME%\logs -Drhq.control.loglevel=%_RHQ_LOGLEVEL% -Drhq.server.basedir=%RHQ_SERVER_HOME% -Drhqctl.properties-file=%RHQ_SERVER_HOME%\bin\rhqctl.properties
+
+rem Sample JPDA settings for remote socket debugging
+rem set RHQ_CONTROL_JAVA_OPTS=%RHQ_CONTROL_JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
+
+if defined RHQ_CONTROL_DEBUG echo RHQ_CONTROL_JAVA_OPTS: %RHQ_CONTROL_JAVA_OPTS%
+if defined RHQ_CONTROL_DEBUG echo RHQ_CONTROL_ADDITIONAL_JAVA_OPTS: %RHQ_CONTROL_ADDITIONAL_JAVA_OPTS%
+
+rem ----------------------------------------------------------------------
+rem We need to add our own modules to the core set of JBossAS modules.
+rem ----------------------------------------------------------------------
+set _RHQ_MODULES_PATH=%RHQ_SERVER_HOME%\modules
+set _INTERNAL_MODULES_PATH=%RHQ_SERVER_JBOSS_HOME%\modules
+set _JBOSS_MODULEPATH=%_RHQ_MODULES_PATH%;%_INTERNAL_MODULES_PATH%
+
+if defined RHQ_CONTROL_DEBUG echo _JBOSS_MODULEPATH: %_JBOSS_MODULEPATH%
+
+rem start the AS instance with our main installer module
+"%RHQ_SERVER_JAVA_EXE_FILE_PATH%" %RHQ_CONTROL_JAVA_OPTS% %RHQ_CONTROL_ADDITIONAL_JAVA_OPTS% -jar "%RHQ_SERVER_JBOSS_HOME%\jboss-modules.jar" -mp "%_JBOSS_MODULEPATH%" org.rhq.rhq-server-control %*
+
+:done
+endlocal
diff --git a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl.sh b/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl.sh
deleted file mode 100755
index 89ac456..0000000
--- a/modules/enterprise/server/appserver/src/main/bin-resources/bin/rhqctl.sh
+++ /dev/null
@@ -1,241 +0,0 @@
-#!/bin/sh
-
-# =============================================================================
-# RHQ Storage Installer Script
-#
-# This file is used to complete the installation of the RHQ storage Server on a
-# UNIX platform.
-#
-# This script is customizable by setting the following environment variables:
-#
-# RHQ_CONTROL_DEBUG - If this is defined, the script will emit debug
-# messages. If this is not defined or set to "false"
-# debug messages are not emitted.
-#
-# RHQ_SERVER_HOME - Defines where the server's home install directory is.
-# If not defined, it will be assumed to be the parent
-# directory of the directory where this script lives.
-#
-# RHQ_SERVER_JBOSS_HOME - The location of the AS instance that will
-# host RHQ. If this is set, it overrides any
-# JBOSS_HOME that might be set. If this not
-# set, JBOSS_HOME is used as a fallback. If
-# neither is set, it is assumed the AS bundled
-# under RHQ_SERVER_HOME/jbossas is to be used.
-#
-# RHQ_SERVER_JAVA_HOME - The location of the JRE that the server will
-# use. This will be ignored if
-# RHQ_SERVER_JAVA_EXE_FILE_PATH is set.
-# If this and RHQ_SERVER_JAVA_EXE_FILE_PATH are
-# not set, the Server's embedded JRE will be used.
-#
-# RHQ_SERVER_JAVA_EXE_FILE_PATH - Defines the full path to the Java
-# executable to use. If this is set,
-# RHQ_SERVER_JAVA_HOME is ignored.
-# If this is not set, then
-# $RHQ_SERVER_JAVA_HOME/bin/java
-# is used. If this and
-# RHQ_SERVER_JAVA_HOME are not set, the
-# Server's embedded JRE will be used.
-#
-# RHQ_CONTROL_JAVA_OPTS - Java VM command line options to be
-# passed into the Java VM. If this is not defined
-# this script will pass in a default set of options.
-# If you only want to add options to the defaults,
-# then you will want to use
-# RHQ_CONTROL_ADDITIONAL_JAVA_OPTS instead.
-#
-# RHQ_CONTROL_ADDITIONAL_JAVA_OPTS - additional Java VM command
-# line options to be passed into the VM.
-# This is added to RHQ_CONTROL_JAVA_OPTS; it
-# is mainly used to augment the
-# default set of options. This can be
-# left unset if it is not needed.
-#
-# If the embedded JRE is to be used but is not available, the fallback
-# JRE to be used will be determined by the JAVA_HOME environment variable.
-# =============================================================================
-
-debug_msg ()
-{
- # if debug variable is set, it is assumed to be on, unless its value is false
- if [ -n "$RHQ_CONTROL_DEBUG" ] && [ "$RHQ_CONTROL_DEBUG" != "false" ]; then
- echo $1
- fi
-}
-
-# ----------------------------------------------------------------------
-# Determine what specific platform we are running on.
-# Set some platform-specific variables.
-# ----------------------------------------------------------------------
-
-case "`uname`" in
- CYGWIN*) _CYGWIN=true
- ;;
- Linux*) _LINUX=true
- ;;
- Darwin*) _DARWIN=true
- ;;
- SunOS*) _SOLARIS=true
- ;;
- AIX*) _AIX=true
- ;;
-esac
-
-# only certain platforms support the -e argument for readlink
-if [ -n "${_LINUX}${_SOLARIS}${_CYGWIN}" ]; then
- _READLINK_ARG="-e"
-fi
-
-# ----------------------------------------------------------------------
-# Determine the RHQ Server installation directory.
-# If RHQ_SERVER_HOME is not defined, we will assume we are running
-# directly from the server installation's bin directory.
-# ----------------------------------------------------------------------
-
-if [ -z "$RHQ_SERVER_HOME" ]; then
- _DOLLARZERO=`readlink $_READLINK_ARG "$0" 2>/dev/null || echo "$0"`
- RHQ_SERVER_HOME=`dirname "$_DOLLARZERO"`/..
-else
- if [ ! -d "$RHQ_SERVER_HOME" ]; then
- echo "ERROR! RHQ_SERVER_HOME is not pointing to a valid directory"
- echo "RHQ_SERVER_HOME: $RHQ_SERVER_HOME"
- exit 1
- fi
-fi
-
-cd "$RHQ_SERVER_HOME"
-RHQ_SERVER_HOME=`pwd`
-
-debug_msg "RHQ_SERVER_HOME: $RHQ_SERVER_HOME"
-
-# ----------------------------------------------------------------------
-# Determine what JBossAS instance to use.
-# If RHQ_SERVER_JBOSS_HOME and JBOSS_HOME are both not defined, we will
-# assume we are to run the embedded AS instance from the RHQ
-# installation directory - RHQ_SERVER_HOME/jbossas
-# ----------------------------------------------------------------------
-
-if [ -z "$RHQ_SERVER_JBOSS_HOME" ]; then
- if [ -z "$JBOSS_HOME" ]; then
- RHQ_SERVER_JBOSS_HOME="${RHQ_SERVER_HOME}/jbossas"
- else
- if [ ! -d "$JBOSS_HOME" ]; then
- echo "ERROR! JBOSS_HOME is not pointing to a valid AS directory"
- echo "JBOSS_HOME: $JBOSS_HOME"
- exit 1
- fi
- RHQ_SERVER_JBOSS_HOME="${JBOSS_HOME}"
- fi
-else
- if [ ! -d "$RHQ_SERVER_JBOSS_HOME" ]; then
- echo "ERROR! RHQ_SERVER_JBOSS_HOME is not pointing to a valid AS directory"
- echo "RHQ_SERVER_JBOSS_HOME: $RHQ_SERVER_JBOSS_HOME"
- exit 1
- fi
-fi
-
-cd "$RHQ_SERVER_JBOSS_HOME"
-RHQ_SERVER_JBOSS_HOME=`pwd`
-
-debug_msg "RHQ_SERVER_JBOSS_HOME: $RHQ_SERVER_JBOSS_HOME"
-
-if [ ! -f "${RHQ_SERVER_JBOSS_HOME}/jboss-modules.jar" ]; then
- echo "ERROR! RHQ_SERVER_JBOSS_HOME is not pointing to a valid AS instance"
- echo "Missing ${RHQ_SERVER_JBOSS_HOME}/jboss-modules.jar"
- exit 1
-fi
-
-# we want the rest of this script to be able to assume cwd is the RHQ install dir
-cd "$RHQ_SERVER_HOME"
-
-# ----------------------------------------------------------------------
-# if we are on a Mac and JAVA_HOME is not set, then set it to /usr
-# as this is the default location.
-# ----------------------------------------------------------------------
-
-if [ -z "$JAVA_HOME" ]; then
- if [ -n "$_DARWIN" ]; then
- debug_msg "Running on Mac OS X, setting JAVA_HOME to /usr"
- JAVA_HOME=/usr
- fi
-fi
-
-# ----------------------------------------------------------------------
-# Create the logs directory
-# ----------------------------------------------------------------------
-
-_LOG_DIR_PATH="${RHQ_SERVER_HOME}/logs"
-if [ -n "$_CYGWIN" ]; then
- _LOG_DIR_PATH=`cygpath --windows --path "$_LOG_DIR_PATH"`
-fi
-if [ ! -d "${_LOG_DIR_PATH}" ]; then
- mkdir "${_LOG_DIR_PATH}"
-fi
-
-# ----------------------------------------------------------------------
-# Find the Java executable and verify we have a VM available
-# ----------------------------------------------------------------------
-
-if [ -z "$RHQ_SERVER_JAVA_EXE_FILE_PATH" ]; then
- if [ -z "$RHQ_SERVER_JAVA_HOME" ]; then
- RHQ_SERVER_JAVA_HOME="${RHQ_SERVER_HOME}/jre"
- if [ -d "$RHQ_SERVER_JAVA_HOME" ]; then
- debug_msg "Using the embedded JRE"
- else
- debug_msg "No embedded JRE found - will try to use JAVA_HOME: $JAVA_HOME"
- RHQ_SERVER_JAVA_HOME="$JAVA_HOME"
- fi
- fi
- debug_msg "RHQ_SERVER_JAVA_HOME: $RHQ_SERVER_JAVA_HOME"
- RHQ_SERVER_JAVA_EXE_FILE_PATH="${RHQ_SERVER_JAVA_HOME}/bin/java"
-fi
-debug_msg "RHQ_SERVER_JAVA_EXE_FILE_PATH: $RHQ_SERVER_JAVA_EXE_FILE_PATH"
-
-if [ ! -f "$RHQ_SERVER_JAVA_EXE_FILE_PATH" ]; then
- echo "There is no JVM available."
- echo "Please set RHQ_SERVER_JAVA_HOME or RHQ_SERVER_JAVA_EXE_FILE_PATH appropriately."
- exit 1
-fi
-
-# ----------------------------------------------------------------------
-# Prepare the VM command line options to be passed in
-# ----------------------------------------------------------------------
-
-if [ -z "$RHQ_CONTROL_JAVA_OPTS" ]; then
- RHQ_CONTROL_JAVA_OPTS="-Xms512M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=128M -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true"
-fi
-
-# Add the JVM opts that we always want to specify, whether or not the user set RHQ_CCM_JAVA_OPTS.
-if [ -n "$RHQ_CONTROL_DEBUG" ] && [ "$RHQ_CONTROL_DEBUG" != "false" ]; then
- _RHQ_LOGLEVEL="DEBUG"
-else
- _RHQ_LOGLEVEL="INFO"
-fi
-
-# debugging the logging level now for development/testing
-RHQ_CONTROL_JAVA_OPTS="${RHQ_CONTROL_JAVA_OPTS} -Djava.awt.headless=true -Drhq.server.properties-file=${RHQ_SERVER_HOME}/bin/rhq-server.properties -Drhq.control.logdir=${RHQ_SERVER_HOME}/logs -Drhq.control.loglevel=${_RHQ_LOGLEVEL} -Drhq.server.basedir=${RHQ_SERVER_HOME} -Drhqctl.properties-file=$RHQ_SERVER_HOME/bin/rhqctl.properties"
-
-# Sample JPDA settings for remote socket debugging
-#RHQ_CONTROL_JAVA_OPTS="${RHQ_CONTROL_JAVA_OPTS} -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"
-
-debug_msg "RHQ_CONTROL_JAVA_OPTS: $RHQ_CONTROL_JAVA_OPTS"
-debug_msg "RHQ_CONTROL_ADDITIONAL_JAVA_OPTS: $RHQ_CONTROL_ADDITIONAL_JAVA_OPTS"
-
-# ----------------------------------------------------------------------
-# We need to add our own modules to the core set of JBossAS modules.
-# ----------------------------------------------------------------------
-_RHQ_MODULES_PATH="${RHQ_SERVER_HOME}/modules"
-_INTERNAL_MODULES_PATH="${RHQ_SERVER_JBOSS_HOME}/modules"
-if [ -n "$_CYGWIN" ]; then
- _RHQ_MODULES_PATH=`cygpath --windows --path "$_RHQ_MODULES_PATH"`
- _INTERNAL_MODULES_PATH=`cygpath --windows --path "$_INTERNAL_MODULES_PATH"`
-fi
-_JBOSS_MODULEPATH="${_RHQ_MODULES_PATH}:${_INTERNAL_MODULES_PATH}"
-debug_msg "_JBOSS_MODULEPATH: $_JBOSS_MODULEPATH"
-
-# start the AS instance with our main installer module
-"$RHQ_SERVER_JAVA_EXE_FILE_PATH" ${RHQ_CONTROL_JAVA_OPTS} ${RHQ_CONTROL_ADDITIONAL_JAVA_OPTS} -jar "${RHQ_SERVER_JBOSS_HOME}/jboss-modules.jar" -mp "$_JBOSS_MODULEPATH" org.rhq.rhq-server-control "$@"
-
-_EXIT_STATUS=$?
-exit $_EXIT_STATUS
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
new file mode 100644
index 0000000..306df82
--- /dev/null
+++ b/modules/enterprise/server/appserver/src/main/bin-resources/bin/wrapper/rhq-storage-wrapper.conf
@@ -0,0 +1,202 @@
+#*****************************************************************************
+# RHQ Storage Node Java Service Wrapper Configuration File
+#
+# If you wish to modify these settings or add additional ones, it is
+# recommended that you do not modify this file; instead, create your own
+# override include file named "rhq-storage-wrapper.inc" and place it in the
+# same directory where this file is located.
+#
+# See http://wrapper.tanukisoftware.org/doc/english/properties.html
+# for full documentation on all available wrapper.* settings
+#*****************************************************************************
+
+#*****************************************************************************
+# Environment Variables Required
+#
+# All of the below environment variables may be either specified in the
+# process environment or in the wrapper environment configuration file or on
+# the command line. The wrapper environment configuration file must be
+# named "rhq-storage-wrapper.env" and must be placed in the same directory
+# where this file is located.
+#
+# Note that all paths must be full, absolute paths unless noted otherwise.
+#
+# set.RHQ_SERVER_HOME - RHQ Server installation directory
+# set.RHQ_STORAGE_HOME - RHQ Storage Node installation directory
+# set.RHQ_STORAGE_INSTANCE_NAME - A name to identify the RHQ Storage Node
+# set.RHQ_SERVER_JAVA_EXE_FILE_PATH - Java executable
+# set.RHQ_STORAGE_OS_PLATFORM - The operating system platform name
+# set.RHQ_STORAGE_WRAPPER_LOG_DIR_PATH - The Java Service Wrapper's log file (helpful if installing, uninstalling or starting fails)
+#*****************************************************************************
+
+# Load in the specific environment for the RHQ Storage Node instance to start
+#include %RHQ_SERVER_HOME%/bin/wrapper/rhq-storage-wrapper.env
+
+#*****************************************************************************
+# Start Properties
+#*****************************************************************************
+# Java JVM Executable (quotes not needed)
+wrapper.java.command=%RHQ_SERVER_JAVA_EXE_FILE_PATH%
+
+# Java Main class. This class must implement the WrapperListener interface. (quotes not needed)
+wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
+
+# Java Classpath (include wrapper.jar). Add classpath elements starting at 1 (quotes not needed)
+wrapper.java.classpath.1=%RHQ_SERVER_HOME%\bin\wrapper\%RHQ_STORAGE_OS_PLATFORM%\wrapper.jar
+wrapper.java.classpath.2=%RHQ_STORAGE_HOME%\conf
+wrapper.java.classpath.3=%RHQ_STORAGE_HOME%\lib\*.jar
+
+
+# Java Library Path (location of wrapper.dll/libwrapper.so and other JNI libs) (quotes not needed)
+wrapper.java.library.path.1=%RHQ_SERVER_HOME%\bin\wrapper\%RHQ_STORAGE_OS_PLATFORM%
+
+# The RHQ Storage Node starts Cassandra
+wrapper.app.parameter.1=org.apache.cassandra.service.CassandraDaemon
+
+# Additional command line arguments to be passed to Cassandra (quotes ARE needed)
+wrapper.app.parameter.2="-Dcassandra"
+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.working.dir=%RHQ_STORAGE_HOME%/bin
+
+#*****************************************************************************
+# Wrapper Logging Properties
+#*****************************************************************************
+# if TRUE, this will turn logging level immediately to DEBUG
+wrapper.debug=FALSE
+
+# Format of output for the console. (See docs for formats)
+wrapper.console.format=M
+
+# Log Level for console output. (NONE,DEBUG,STATUS,INFO,ERROR,FATAL)
+wrapper.console.loglevel=INFO
+
+# Log file to use for wrapper output logging. (quotes not needed)
+wrapper.logfile=%RHQ_STORAGE_WRAPPER_LOG_DIR_PATH%/rhq-storage-wrapper.log
+
+# Format of output for the log file. (See docs for formats)
+wrapper.logfile.format=LPTM
+
+# Log Level for log file output. (NONE,DEBUG,STATUS,INFO,ERROR,FATAL)
+wrapper.logfile.loglevel=ERROR
+
+# Maximum size that the log file will be allowed to grow to before
+# the log is rolled. Size is specified in bytes. The default value
+# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
+# 'm' (mb) suffix. For example: 10m = 10 megabytes.
+wrapper.logfile.maxsize=1m
+
+# Maximum number of rolled log files which will be allowed before old
+# files are deleted. The default value of 0 implies no limit.
+wrapper.logfile.maxfiles=1
+
+# Log Level for sys/event log output. (See docs for log levels)
+wrapper.syslog.loglevel=NONE
+
+# if JVM hangs, this tries to get a thread dump
+# (if TRUE, then ntservice.console is forced to TRUE as well)
+wrapper.request_thread_dump_on_failed_jvm_exit=FALSE
+
+#*****************************************************************************
+# Wrapper Windows Properties
+#*****************************************************************************
+# Title to use when running as a console
+wrapper.console.title=RHQ Storage [%RHQ_STORAGE_INSTANCE_NAME%]
+
+#*****************************************************************************
+# Wrapper Windows XP Service Properties
+#*****************************************************************************
+# WARNING - Do not modify any of these properties when an application
+# using this configuration file has been installed as a service.
+# Please uninstall the service before modifying this section. The
+# service can then be reinstalled.
+
+# Name of the service
+wrapper.ntservice.name=%RHQ_STORAGE_INSTANCE_NAME%
+
+# Display name of the service
+wrapper.ntservice.displayname=RHQ Storage [%RHQ_STORAGE_INSTANCE_NAME%]
+
+# Description of the service
+wrapper.ntservice.description=RHQ Storage Node instance named %RHQ_STORAGE_INSTANCE_NAME%
+
+# Service dependencies. Add dependencies as needed starting from 1
+wrapper.ntservice.dependency.1=
+
+# Mode in which the service is installed. AUTO_START or DEMAND_START
+wrapper.ntservice.starttype=AUTO_START
+
+# Allow service to interact with desktop (must be FALSE if account is specified)
+wrapper.ntservice.interactive=FALSE
+
+# Show a console - only takes effect if interactive is TRUE
+wrapper.ntservice.console=FALSE
+
+# The service runs as this user; Local System account is used if not specified
+# If prompt is true, the user will be prompted for the password. If false,
+# the password configuration property will be used.
+#wrapper.ntservice.account=.\username
+wrapper.ntservice.password.prompt=TRUE
+#wrapper.ntservice.password=xyz
+
+#*****************************************************************************
+# Wrapper UNIX Service Properties
+#*****************************************************************************
+# For UNIX, make sure it is daemonized
+wrapper.daemonize=TRUE
+
+#*****************************************************************************
+# Wrapper Shutdown Monitoring Properties
+#*****************************************************************************
+# File to be monitored - when anchor file is deleted, the instance will shutdown
+#wrapper.anchorfile=%RHQ_SERVER_HOME%\bin\anchor
+#wrapper.anchor.poll_interval=5
+
+# auto-restart on weird exit status - if exiting normally, just shutdown
+wrapper.on_exit.default=RESTART
+wrapper.on_exit.0=SHUTDOWN
+
+# immediately restart the JVM when java.lang.OutOfMemoryError is detected in its output
+wrapper.filter.trigger.1=java.lang.OutOfMemoryError
+wrapper.filter.action.1=RESTART
+
+# Determine when to restart or if an invocation simply failed on startup
+wrapper.max_failed_invocations=2
+wrapper.successful_invocation_time=300
+wrapper.startup.timeout=30
+
+# How to poll the VM to make sure it is not hung
+wrapper.ping.interval=30
+wrapper.ping.timeout=45
+wrapper.cpu.timeout=10
+
+# Allow our server some extra time to shutdown, since it may take a while to clear the comm repo
+wrapper.shutdown.timeout=180
+wrapper.jvm_exit.timeout=180
+
+#*****************************************************************************
+# Wrapper Override Properties
+# wrapper.XXX properties defined in this included file override any
+# properties previously defined above.
+#*****************************************************************************
+#include %RHQ_SERVER_HOME%/bin/wrapper/rhq-storage-wrapper.inc
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java
index d85a3b2..d64cfed 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/ControlCommand.java
@@ -116,9 +116,9 @@ public abstract class ControlCommand {
String syntax;
if (options.getOptions().isEmpty()) {
- syntax = "rhqctl.sh " + getName();
+ syntax = "rhqctl " + getName();
} else {
- syntax = "rhqctl.sh " + getName() + " [options]";
+ syntax = "rhqctl " + getName() + " [options]";
}
helpFormatter.setNewLine("\n");
@@ -158,7 +158,7 @@ public abstract class ControlCommand {
return getAgentBasedir().exists();
}
- protected boolean isStorageInstalled() {
+ protected boolean isStorageInstalled() {
return getStorageBasedir().exists();
}
@@ -217,11 +217,31 @@ public abstract class ControlCommand {
return file;
}
- protected String getExtension() {
+ protected org.apache.commons.exec.CommandLine getCommandLine(String scriptName, String... args) {
+ org.apache.commons.exec.CommandLine result;
+
if (isWindows()) {
- return "bat";
+ result = new org.apache.commons.exec.CommandLine("cmd.exe");
+ result.addArgument("/C");
+ result.addArgument(scriptName + ".bat");
+ return result;
+ } else {
+ result = new org.apache.commons.exec.CommandLine("./" + scriptName + ".sh");
+ }
+
+ for (String arg : args) {
+ result.addArgument(arg);
}
- return "sh";
+
+ return result;
+ }
+
+ protected String getScript(String scriptName) {
+ if (isWindows()) {
+ return scriptName + ".bat";
+ }
+
+ return "./" + scriptName + ".sh";
}
protected boolean isWindows() {
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java
index 8a6dd8f..54dc98e 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/RHQControl.java
@@ -45,7 +45,7 @@ public class RHQControl {
public void printUsage() {
HelpFormatter helpFormatter = new HelpFormatter();
- String syntax = "rhqctl.sh <cmd> [options]";
+ String syntax = "rhqctl <cmd> [options]";
String header = "\nwhere <cmd> is one of:";
helpFormatter.setOptPrefix("");
@@ -65,7 +65,7 @@ public class RHQControl {
} catch(UsageException e) {
printUsage();
} catch (RHQControlException e) {
- log.error(e);
+ log.error(e.getMessage() + " [Cause: " + e.getCause() + "]");
}
}
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Console.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Console.java
index 31cd6ff..cbecd46 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Console.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Console.java
@@ -48,8 +48,7 @@ public class Console extends ControlCommand {
private Options options;
public Console() {
- options = new Options()
- .addOption(null, "storage", false, "Start the RHQ storage node in the foreground")
+ options = new Options().addOption(null, "storage", false, "Start the RHQ storage node in the foreground")
.addOption(null, "server", false, "Start the RHQ server in the foreground")
.addOption(null, "agent", false, "Start the RHQ agent in the foreground");
}
@@ -80,22 +79,22 @@ public class Console extends ControlCommand {
if (isStorageInstalled()) {
startStorageInForeground();
} else {
- log.warn("It appears that the storage node is not installed. The --" + STORAGE_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the storage node is not installed. The --" + STORAGE_OPTION
+ + " option will be ignored.");
}
} else if (option.equals(SERVER_OPTION)) {
if (isServerInstalled()) {
startServerInForeground();
} else {
- log.warn("It appears that the server is not installed. The --" + SERVER_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the server is not installed. The --" + SERVER_OPTION
+ + " option will be ignored.");
}
} else if (option.equals(AGENT_OPTION)) {
if (isAgentInstalled()) {
startAgentInForeground();
} else {
- log.warn("It appears that the agent is not installed. The --" + AGENT_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the agent is not installed. The --" + AGENT_OPTION
+ + " option will be ignored.");
}
} else {
throw new IllegalArgumentException(option + " is not a supported option");
@@ -129,8 +128,7 @@ public class Console extends ControlCommand {
private void startServerInForeground() throws Exception {
log.debug("Starting RHQ server in foreground");
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-server." + getExtension()).addArgument("console");
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-server", "console");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(binDir);
executor.setStreamHandler(new PumpStreamHandler());
@@ -145,33 +143,34 @@ public class Console extends ControlCommand {
File confDir = new File(agentHomeDir, "conf");
File agentConfigFile = new File(confDir, "agent-configuration.xml");
- Process process = new ProcessBuilder("./rhq-agent." + getExtension(), "-c", agentConfigFile.getPath())
- .directory(agentBinDir)
-// .redirectOutput(ProcessBuilder.Redirect.INHERIT)
-// .redirectInput(ProcessBuilder.Redirect.INHERIT)
-// .redirectError(ProcessBuilder.Redirect.INHERIT)
+ //TODO: fix for windows
+ Process process = new ProcessBuilder(getScript("rhq-agent"), "-c", agentConfigFile.getPath()).directory(
+ agentBinDir)
+ // .redirectOutput(ProcessBuilder.Redirect.INHERIT)
+ // .redirectInput(ProcessBuilder.Redirect.INHERIT)
+ // .redirectError(ProcessBuilder.Redirect.INHERIT)
.start();
-// .waitFor();
+ // .waitFor();
AgentInputStreamPipe pipe = new AgentInputStreamPipe(process.getInputStream());
pipe.start();
pipe.join();
-// final InputStream inputStream = process.getInputStream();
-// final CountDownLatch doneSignal = new CountDownLatch(1);
-// Thread agentThread = new Thread(new Runnable() {
-// @Override
-// public void run() {
-// InputStreamReader reader = new InputStreamReader(inputStream);
-// Scanner scanner = new Scanner(reader);
-// while (scanner.hasNextLine()) {
-// System.out.println(scanner.nextLine());
-// }
-// doneSignal.countDown();
-// }
-// });
-// agentThread.start();
-// doneSignal.await();
-// agentThread.join();
+ // final InputStream inputStream = process.getInputStream();
+ // final CountDownLatch doneSignal = new CountDownLatch(1);
+ // Thread agentThread = new Thread(new Runnable() {
+ // @Override
+ // public void run() {
+ // InputStreamReader reader = new InputStreamReader(inputStream);
+ // Scanner scanner = new Scanner(reader);
+ // while (scanner.hasNextLine()) {
+ // System.out.println(scanner.nextLine());
+ // }
+ // doneSignal.countDown();
+ // }
+ // });
+ // agentThread.start();
+ // doneSignal.await();
+ // agentThread.join();
}
private class AgentInputStreamPipe extends Thread {
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 2db81ce..c5c871d 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
@@ -74,20 +74,32 @@ public class Install extends ControlCommand {
public Install() {
options = new Options()
- .addOption(null, "storage", false, "Install RHQ storage node. The default install directory will be " +
- DEFAULT_STORAGE_BASEDIR + ". Use the --storage-dir option to choose an alternate directory.")
+ .addOption(
+ null,
+ "storage",
+ false,
+ "Install RHQ storage node. The default install directory will be " + DEFAULT_STORAGE_BASEDIR
+ + ". Use the --storage-dir option to choose an alternate directory.")
.addOption(null, "server", false, "Install RHQ server")
- .addOption(null, "agent", false, "Install RHQ agent. The default install directory will be " +
- DEFAULT_AGENT_BASEDIR + ". Use the --agent-dir option to choose an alternate directory.")
+ .addOption(
+ null,
+ "agent",
+ false,
+ "Install RHQ agent. The default install directory will be " + DEFAULT_AGENT_BASEDIR
+ + ". Use the --agent-dir option to choose an alternate directory.")
.addOption(null, "storage-dir", true, "The directory where the storage node will be installed.")
.addOption(null, "agent-dir", true, "The directory where the agent will be installed.")
- .addOption(null, SERVER_CONFIG_OPTION, true, "An alternate properties file to use in place of the default " +
- "rhq-server.properties")
- .addOption(null, AGENT_CONFIG_OPTION, true, "An alternate XML file to use in place of the default " +
- "agent-configuration.xml")
- .addOption(null, STORAGE_CONFIG_OPTION, true, "A properties file with keys that correspond to option names " +
- "of the storage installer. Each property will be translated into an option that is passed to the " +
- " storage installer. See example.storage.properties for examples.");
+ .addOption(null, SERVER_CONFIG_OPTION, true,
+ "An alternate properties file to use in place of the default " + "rhq-server.properties")
+ .addOption(null, AGENT_CONFIG_OPTION, true,
+ "An alternate XML file to use in place of the default " + "agent-configuration.xml")
+ .addOption(
+ null,
+ STORAGE_CONFIG_OPTION,
+ true,
+ "A properties file with keys that correspond to option names "
+ + "of the storage installer. Each property will be translated into an option that is passed to the "
+ + " storage installer. See example.storage.properties for examples.");
}
@Override
@@ -118,8 +130,8 @@ public class Install extends ControlCommand {
}
// if no options specified, then install whatever is installed
- if (!(commandLine.hasOption(STORAGE_OPTION) || commandLine.hasOption(SERVER_OPTION) ||
- commandLine.hasOption(AGENT_OPTION))) {
+ if (!(commandLine.hasOption(STORAGE_OPTION) || commandLine.hasOption(SERVER_OPTION) || commandLine
+ .hasOption(AGENT_OPTION))) {
replaceServerPropertiesIfNecessary(commandLine);
@@ -190,8 +202,8 @@ public class Install extends ControlCommand {
private List<String> validateOptions(CommandLine commandLine) {
List<String> errors = new LinkedList<String>();
- if (!(commandLine.hasOption(STORAGE_OPTION) || commandLine.hasOption(SERVER_OPTION) ||
- commandLine.hasOption(AGENT_OPTION))) {
+ if (!(commandLine.hasOption(STORAGE_OPTION) || commandLine.hasOption(SERVER_OPTION) || commandLine
+ .hasOption(AGENT_OPTION))) {
if (commandLine.hasOption(SERVER_CONFIG_OPTION) && !isServerInstalled()) {
File serverConfig = new File(commandLine.getOptionValue(SERVER_CONFIG_OPTION));
validateServerConfigOption(serverConfig, errors);
@@ -219,14 +231,14 @@ public class Install extends ControlCommand {
}
}
- if (commandLine.hasOption(SERVER_OPTION) && !isStorageInstalled() &&
- commandLine.hasOption(SERVER_CONFIG_OPTION)) {
+ if (commandLine.hasOption(SERVER_OPTION) && !isStorageInstalled()
+ && commandLine.hasOption(SERVER_CONFIG_OPTION)) {
File serverConfig = new File(commandLine.getOptionValue(SERVER_CONFIG_OPTION));
validateServerConfigOption(serverConfig, errors);
}
- if (commandLine.hasOption(AGENT_OPTION) && !isAgentInstalled() &&
- commandLine.hasOption(AGENT_CONFIG_OPTION)) {
+ if (commandLine.hasOption(AGENT_OPTION) && !isAgentInstalled()
+ && commandLine.hasOption(AGENT_CONFIG_OPTION)) {
File agentConfig = new File(commandLine.getOptionValue(AGENT_CONFIG_OPTION));
validateAgentConfigOption(agentConfig, errors);
}
@@ -237,34 +249,34 @@ public class Install extends ControlCommand {
private void validateServerConfigOption(File serverConfig, List<String> errors) {
if (!serverConfig.exists()) {
- errors.add("The --server-config option has as its value a file that does not exist [" +
- serverConfig.getAbsolutePath() + "]");
+ errors.add("The --server-config option has as its value a file that does not exist ["
+ + serverConfig.getAbsolutePath() + "]");
} else if (serverConfig.isDirectory()) {
- errors.add("The --server-config option has as its value a path that is a directory [" +
- serverConfig.getAbsolutePath() + "]. It should be a properties file that replaces the " +
- "default rhq-server.properties");
+ errors.add("The --server-config option has as its value a path that is a directory ["
+ + serverConfig.getAbsolutePath() + "]. It should be a properties file that replaces the "
+ + "default rhq-server.properties");
}
}
private void validateAgentConfigOption(File agentConfig, List<String> errors) {
if (!agentConfig.exists()) {
- errors.add("The --agent-config option has as its value a file that does not exist [" +
- agentConfig.getAbsolutePath() + "]");
+ errors.add("The --agent-config option has as its value a file that does not exist ["
+ + agentConfig.getAbsolutePath() + "]");
} else if (agentConfig.isDirectory()) {
- errors.add("The --agent-config option has as its value a path that is a directory [" +
- agentConfig.getAbsolutePath() + "]. It should be an XML file that replaces the default " +
- "agent-configuration.xml");
+ errors.add("The --agent-config option has as its value a path that is a directory ["
+ + agentConfig.getAbsolutePath() + "]. It should be an XML file that replaces the default "
+ + "agent-configuration.xml");
}
}
private void validateStorageConfigOption(File storageConfig, List<String> errors) {
if (!storageConfig.exists()) {
- errors.add("The --storage-config option has as its value a file that does not exist [" +
- storageConfig.getAbsolutePath() + "]");
+ errors.add("The --storage-config option has as its value a file that does not exist ["
+ + storageConfig.getAbsolutePath() + "]");
} else if (storageConfig.isDirectory()) {
- errors.add("The --storage-config option has as its value a path that is a directory [" +
- storageConfig.getAbsolutePath() + "]. It should be a properties file with keys that " +
- "correspond to options for the storage installer.");
+ errors.add("The --storage-config option has as its value a path that is a directory ["
+ + storageConfig.getAbsolutePath() + "]. It should be a properties file with keys that "
+ + "correspond to options for the storage installer.");
}
}
@@ -289,9 +301,8 @@ public class Install extends ControlCommand {
putProperty(RHQ_STORAGE_BASEDIR_PROP, storageBasedir.getAbsolutePath());
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-storage-installer." + getExtension()).addArgument("--dir")
- .addArgument(storageBasedir.getAbsolutePath());
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-storage-installer", "--dir",
+ storageBasedir.getAbsolutePath());
if (rhqctlCommandLine.hasOption(STORAGE_CONFIG_OPTION)) {
String[] args = toArray(loadStorageProperties(rhqctlCommandLine.getOptionValue(STORAGE_CONFIG_OPTION)));
@@ -323,8 +334,7 @@ public class Install extends ControlCommand {
}
private void startRHQServerForInstallation() throws Exception {
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-server." + getExtension()).addArgument("start");
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-server", "start");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(binDir);
@@ -332,8 +342,7 @@ public class Install extends ControlCommand {
executor.execute(commandLine, new DefaultExecuteResultHandler());
- commandLine = new org.apache.commons.exec.CommandLine("./rhq-installer." + getExtension())
- .addArgument("--test");
+ commandLine = getCommandLine("rhq-installer", "--test");
executor = new DefaultExecutor();
executor.setWorkingDirectory(binDir);
@@ -346,8 +355,7 @@ public class Install extends ControlCommand {
private void installRHQServer() throws Exception {
log.debug("Installing RHQ server");
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-installer." + getExtension());
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-installer");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(binDir);
executor.setStreamHandler(new PumpStreamHandler());
@@ -382,8 +390,7 @@ public class Install extends ControlCommand {
putProperty(RHQ_AGENT_BASEDIR_PROP, agentBasedir.getAbsolutePath());
org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine("java")
- .addArgument("-jar")
- .addArgument(agentInstallerJar.getAbsolutePath())
+ .addArgument("-jar").addArgument(agentInstallerJar.getAbsolutePath())
.addArgument("--install=" + agentBasedir.getParentFile().getAbsolutePath());
Executor executor = new DefaultExecutor();
@@ -435,8 +442,7 @@ public class Install extends ControlCommand {
private void startAgent(File agentBasedir) throws Exception {
File agentBinDir = new File(agentBasedir, "bin");
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-agent-wrapper." + getExtension()).addArgument("start");
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-agent-wrapper", "start");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(agentBinDir);
@@ -456,8 +462,7 @@ public class Install extends ControlCommand {
try {
StreamUtil.copy(new FileReader(newServerProperties), new FileWriter(defaultServerProps));
} catch (IOException e) {
- throw new RHQControlException("Failed to replace " + defaultServerProps + " with " + newServerProperties,
- e);
+ throw new RHQControlException("Failed to replace " + defaultServerProps + " with " + newServerProperties, e);
}
}
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Start.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Start.java
index f58ac4c..942f6ee 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Start.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Start.java
@@ -46,8 +46,7 @@ public class Start extends ControlCommand {
private Options options;
public Start() {
- options = new Options()
- .addOption(null, STORAGE_OPTION, false, "Start RHQ storage node")
+ options = new Options().addOption(null, STORAGE_OPTION, false, "Start RHQ storage node")
.addOption(null, SERVER_OPTION, false, "Start RHQ server")
.addOption(null, AGENT_OPTION, false, "Start RHQ agent");
}
@@ -86,24 +85,24 @@ public class Start extends ControlCommand {
if (isStorageInstalled()) {
startStorage();
} else {
- log.warn("It appears that the storage node is not installed. The --" + STORAGE_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the storage node is not installed. The --" + STORAGE_OPTION
+ + " option will be ignored.");
}
}
if (commandLine.hasOption(SERVER_OPTION)) {
if (isServerInstalled()) {
startRHQServer();
} else {
- log.warn("It appears that the server is not installed. The --" + SERVER_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the server is not installed. The --" + SERVER_OPTION
+ + " option will be ignored.");
}
}
if (commandLine.hasOption(AGENT_OPTION)) {
if (isAgentInstalled()) {
startAgent();
} else {
- log.warn("It appears that the agent is not installed. The --" + AGENT_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the agent is not installed. The --" + AGENT_OPTION
+ + " option will be ignored.");
}
}
}
@@ -143,8 +142,7 @@ public class Start extends ControlCommand {
private void startRHQServer() throws Exception {
log.debug("Starting RHQ server");
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-server." + getExtension()).addArgument("start");
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-server", "start");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(binDir);
executor.setStreamHandler(new PumpStreamHandler());
@@ -156,8 +154,7 @@ public class Start extends ControlCommand {
File agentBinDir = new File(getAgentBasedir(), "bin");
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-agent-wrapper." + getExtension()).addArgument("start");
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-agent-wrapper", "start");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(agentBinDir);
executor.setStreamHandler(new PumpStreamHandler());
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Status.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Status.java
index 32344c9..0aa054c 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Status.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Status.java
@@ -46,8 +46,7 @@ public class Status extends ControlCommand {
private Options options;
public Status() {
- options = new Options()
- .addOption(null, STORAGE_OPTION, false, "Check status of RHQ storage node")
+ options = new Options().addOption(null, STORAGE_OPTION, false, "Check status of RHQ storage node")
.addOption(null, SERVER_OPTION, false, "Check status of RHQ server")
.addOption(null, AGENT_OPTION, false, "Check status of RHQ agent");
}
@@ -86,24 +85,24 @@ public class Status extends ControlCommand {
if (isStorageInstalled()) {
checkStorageStatus();
} else {
- log.warn("It appears that the storage node is not installed. The --" + STORAGE_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the storage node is not installed. The --" + STORAGE_OPTION
+ + " option will be ignored.");
}
}
if (commandLine.hasOption(SERVER_OPTION)) {
if (isServerInstalled()) {
checkServerStatus();
} else {
- log.warn("It appears that the server is not installed. The --" + SERVER_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the server is not installed. The --" + SERVER_OPTION
+ + " option will be ignored.");
}
}
if (commandLine.hasOption(AGENT_OPTION)) {
if (isAgentInstalled()) {
checkAgentStatus();
} else {
- log.warn("It appears that the agent is not installed. The --" + AGENT_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the agent is not installed. The --" + AGENT_OPTION
+ + " option will be ignored.");
}
}
}
@@ -129,8 +128,7 @@ public class Status extends ControlCommand {
private void checkServerStatus() throws Exception {
log.debug("Checking RHQ server status");
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-server." + getExtension()).addArgument("status");
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-server", "status");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(binDir);
executor.setStreamHandler(new PumpStreamHandler());
@@ -142,8 +140,7 @@ public class Status extends ControlCommand {
File agentBinDir = new File(getAgentBasedir(), "bin");
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-agent-wrapper." + getExtension()).addArgument("status");
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-agent-wrapper", "status");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(agentBinDir);
executor.setStreamHandler(new PumpStreamHandler());
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Stop.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Stop.java
index 13fb1f2..5c5355a 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Stop.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Stop.java
@@ -44,10 +44,8 @@ public class Stop extends ControlCommand {
private Options options;
public Stop() {
- options = new Options()
- .addOption(null, "storage", false, "Stop RHQ storage node")
- .addOption(null, "server", false, "Stop RHQ server")
- .addOption(null, "agent", false, "Stop RHQ agent");
+ options = new Options().addOption(null, "storage", false, "Stop RHQ storage node")
+ .addOption(null, "server", false, "Stop RHQ server").addOption(null, "agent", false, "Stop RHQ agent");
}
@Override
@@ -84,24 +82,24 @@ public class Stop extends ControlCommand {
if (isStorageInstalled()) {
stopStorage();
} else {
- log.warn("It appears that the storage node is not installed. The --" + STORAGE_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the storage node is not installed. The --" + STORAGE_OPTION
+ + " option will be ignored.");
}
}
if (commandLine.hasOption(SERVER_OPTION)) {
if (isServerInstalled()) {
stopRHQServer();
} else {
- log.warn("It appears that the server is not installed. The --" + SERVER_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the server is not installed. The --" + SERVER_OPTION
+ + " option will be ignored.");
}
}
if (commandLine.hasOption(AGENT_OPTION)) {
if (isAgentInstalled()) {
stopAgent();
} else {
- log.warn("It appears that the agent is not installed. The --" + AGENT_OPTION +
- " option will be ignored.");
+ log.warn("It appears that the agent is not installed. The --" + AGENT_OPTION
+ + " option will be ignored.");
}
}
}
@@ -133,8 +131,7 @@ public class Stop extends ControlCommand {
String pid = getServerPid();
if (pid != null) {
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-server." + getExtension()).addArgument("stop");
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-server", "stop");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(binDir);
executor.setStreamHandler(new PumpStreamHandler());
@@ -149,8 +146,7 @@ public class Stop extends ControlCommand {
String pid = getAgentPid();
if (pid != null) {
- org.apache.commons.exec.CommandLine commandLine = new org.apache.commons.exec.CommandLine(
- "./rhq-agent-wrapper." + getExtension()).addArgument("stop");
+ org.apache.commons.exec.CommandLine commandLine = getCommandLine("rhq-agent-wrapper", "stop");
Executor executor = new DefaultExecutor();
executor.setWorkingDirectory(agentBinDir);
executor.setStreamHandler(new PumpStreamHandler());
commit f7b452cf67032d94cce347662888f5b79587c0fa
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 24 15:59:52 2013 -0400
Add -Pdev copy of jars to dev-container
diff --git a/modules/common/cassandra-installer/pom.xml b/modules/common/cassandra-installer/pom.xml
index 17a87f5..6563d2b 100644
--- a/modules/common/cassandra-installer/pom.xml
+++ b/modules/common/cassandra-installer/pom.xml
@@ -104,4 +104,62 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/modules/org/rhq/rhq-cassandra-installer/main</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <target>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <target>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
</project>
diff --git a/modules/enterprise/server/server-control/pom.xml b/modules/enterprise/server/server-control/pom.xml
index d0724f6..11c1f92 100644
--- a/modules/enterprise/server/server-control/pom.xml
+++ b/modules/enterprise/server/server-control/pom.xml
@@ -97,4 +97,62 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>${rhq.containerDir}/modules/org/rhq/rhq-server-control/main</rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <target>
+ <mkdir dir="${rhq.deploymentDir}" />
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <target>
+ <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}" />
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
</project>
commit 3a2810993619af282b6e5aeb7a7d0e48772c0119
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 24 15:55:39 2013 -0400
Fix typo in property name
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/deploy.xml b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/deploy.xml
index 8369389..19d5647 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/deploy.xml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/deploy.xml
@@ -114,7 +114,7 @@
defaultValue=""
type="string"/>
- <rhq:input-property name="rhq.casandra.native_transport_max_threads"
+ <rhq:input-property name="rhq.cassandra.native_transport_max_threads"
description="The maximum number of threads handling native CQL requests."
required="false"
defaultValue="64"
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptions.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptions.java
index f2c14ce..1e7d1b8 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptions.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptions.java
@@ -141,7 +141,7 @@ public class DeploymentOptions {
setNumTokens(Integer.valueOf(loadProperty("rhq.cassandra.num-tokens", properties)));
setNativeTransportPort(Integer.valueOf(loadProperty("rhq.cassandra.native-transport-port", properties)));
setRpcPort(Integer.valueOf(loadProperty("rhq.cassandra.rpc-port", properties)));
- setNativeTransportMaxThreads(Integer.valueOf(loadProperty("rhq.casandra.native-transport-max-threads",
+ setNativeTransportMaxThreads(Integer.valueOf(loadProperty("rhq.cassandra.native-transport-max-threads",
properties)));
setUsername(loadProperty("rhq.cassandra.username", properties));
setPassword(loadProperty("rhq.cassandra.password", properties));
@@ -365,7 +365,7 @@ public class DeploymentOptions {
/**
* @return The max number of threads to handle CQL requests
*/
- @DeploymentProperty(name = "rhq.casandra.native_transport_max_threads")
+ @DeploymentProperty(name = "rhq.cassandra.native_transport_max_threads")
public Integer getNativeTransportMaxThreads() {
return nativeTransportMaxThreads;
}
11 years
[rhq] Branch 'tsegismont/data-migrator' - modules/enterprise
by Thomas Segismont
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/ExistingDataJPABulkExportSource.java | 124 ++++++++++
1 file changed, 124 insertions(+)
New commits:
commit bff26bcb36bc88728bd99bb005f4e445d277e717
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Mon Apr 29 15:23:46 2013 +0200
Add JPA bulk export source
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/ExistingDataJPABulkExportSource.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/ExistingDataJPABulkExportSource.java
new file mode 100644
index 0000000..d61fdf1
--- /dev/null
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/ExistingDataJPABulkExportSource.java
@@ -0,0 +1,124 @@
+package org.rhq.server.metrics;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.List;
+import java.util.Properties;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.commons.lang.time.StopWatch;
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.hibernate.ejb.Ejb3Configuration;
+
+import org.rhq.core.util.jdbc.JDBCUtil;
+import org.rhq.core.util.stream.StreamUtil;
+
+/**
+ * @author Thomas Segismont
+ */
+public class ExistingDataJPABulkExportSource extends ExistingDataBulkExportSource {
+
+ public ExistingDataJPABulkExportSource(EntityManager entityManager, String selectNativeQuery, File workDirectory,
+ String fileName) {
+ super(entityManager, selectNativeQuery, workDirectory, fileName);
+ }
+
+ public void exportExistingData() throws Exception {
+ BufferedWriter fileWriter = null;
+ Connection connection = null;
+ PreparedStatement statement = null;
+ ResultSet resultSet = null;
+ try {
+ fileWriter = new BufferedWriter(new FileWriter(getExistingDataFile()), IO_BUFFER_SIZE);
+ connection = getConnection();
+ statement = connection.prepareStatement(getSelectNativeQuery());
+ int columnCount = resultSet.getMetaData().getColumnCount();
+ resultSet = statement.executeQuery();
+ while (resultSet.next()) {
+ for (int i = 1; i < columnCount + 1; i++) {
+ if (i > 1) {
+ fileWriter.write(DELIMITER);
+ }
+ fileWriter.write(resultSet.getString(i));
+ }
+ fileWriter.write("\n");
+ }
+ } finally {
+ StreamUtil.safeClose(fileWriter);
+ JDBCUtil.safeClose(connection, statement, resultSet);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ BasicConfigurator.configure();
+ Logger.getRootLogger().setLevel(Level.INFO);
+ Logger.getLogger("org.rhq").setLevel(Level.DEBUG);
+ EntityManagerFactory entityManagerFactory = null;
+ EntityManager entityManager = null;
+ ExistingDataBulkExportSource source = null;
+ try {
+ entityManagerFactory = createEntityManager();
+ entityManager = entityManagerFactory.createEntityManager();
+ source = new ExistingPostgresDataBulkExportSource(entityManager,
+ "SELECT schedule_id, time_stamp, value, minvalue, maxvalue FROM RHQ_MEASUREMENT_DATA_NUM_1D",
+ // "SELECT count(*) FROM RHQ_MEASUREMENT_DATA_NUM_1D limit 1"
+ new File(System.getProperty("java.io.tmpdir")), "poupoupidou.txt");
+ StopWatch stopWatch = new StopWatch();
+ stopWatch.start();
+ source.exportExistingData();
+ source.startReading();
+ int rowIndex = 0;
+ int maxResults = 30000;
+ for (;;) {
+ List<Object[]> existingData = source.getExistingData(rowIndex, maxResults);
+ if (existingData.size() < maxResults) {
+ break;
+ } else {
+ rowIndex += maxResults;
+ }
+ }
+ stopWatch.stop();
+ System.out.println("Execution: " + stopWatch);
+ } finally {
+ if (source != null) {
+ source.stopReading();
+ }
+ if (entityManager != null) {
+ entityManager.close();
+ }
+ if (entityManagerFactory != null) {
+ entityManagerFactory.close();
+ }
+ }
+ }
+
+ private static EntityManagerFactory createEntityManager() throws Exception {
+ Properties properties = new Properties();
+ properties.put("javax.persistence.provider", "org.hibernate.ejb.HibernatePersistence");
+ properties.put("hibernate.connection.username", "rhqadmin");
+ properties.put("hibernate.connection.password", "rhqadmin");
+ properties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
+ String driverClassName = "org.postgresql.Driver";
+ try {
+ //Required to preload the driver manually.
+ //Without this the driver load will fail due to the packaging.
+ Class.forName(driverClassName);
+ } catch (ClassNotFoundException e) {
+ throw new Exception("Postgres SQL Driver class could not be loaded. Missing class: " + driverClassName);
+ }
+ properties.put("hibernate.driver_class", driverClassName);
+ properties.put("hibernate.connection.url", "jdbc:postgresql://localhost:5432/rhqdev");
+ Ejb3Configuration configuration = new Ejb3Configuration();
+ configuration.setProperties(properties);
+ return configuration.buildEntityManagerFactory();
+ }
+
+}
11 years
[rhq] Branch 'feature/snmp-peralert-oid' - modules/enterprise
by Thomas Segismont
modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfoTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit cdbc4c1e5f711abc79abbf3819d5ea612313e546
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Mon Apr 29 12:01:11 2013 +0200
Don't confuse test reader with jokes
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfoTest.java b/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfoTest.java
index 2c0174a..c46c8b6 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfoTest.java
+++ b/modules/enterprise/server/plugins/alert-snmp/src/test/java/org/rhq/enterprise/server/plugins/alertSnmp/SnmpInfoTest.java
@@ -73,13 +73,13 @@ public class SnmpInfoTest {
Configuration configuration = new Configuration();
configuration.setSimpleValue(PARAM_HOST, "pipo");
configuration.setSimpleValue(PARAM_VARIABLE_BINDING_PREFIX, "molo");
- configuration.setSimpleValue(PARAM_PORT, "port as a string, really?");
+ configuration.setSimpleValue(PARAM_PORT, "123");
configuration.setSimpleValue(PARAM_TRAP_OID, "logo");
SnmpInfo snmpInfo = SnmpInfo.load(configuration);
assertNull(snmpInfo.error, "SnmpInfo#load should not have detected an error");
assertEquals(snmpInfo.host, "pipo");
- assertEquals(snmpInfo.port, "port as a string, really?");
+ assertEquals(snmpInfo.port, "123");
assertEquals(snmpInfo.oid, "molo");
assertEquals(snmpInfo.trapOid, "logo");
}
11 years
[rhq] Branch 'feature/snmp-peralert-oid' - modules/enterprise
by Thomas Segismont
modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
New commits:
commit c4e3206528c155ca7fc5f532d6bb053483ee5998
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Mon Apr 29 10:12:59 2013 +0200
Update variable display name
diff --git a/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml b/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
index 2c0d8e9..83a55e9 100644
--- a/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
+++ b/modules/enterprise/server/plugins/alert-snmp/src/main/resources/META-INF/rhq-serverplugin.xml
@@ -73,12 +73,12 @@
<a:alert-configuration>
<c:simple-property name="host" type="string" required="true" description="Trap target host"/>
<c:simple-property name="port" type="integer" required="false" default="162" description="Trap target port"/>
- <c:simple-property name="oid" type="string" required="true">
+ <c:simple-property name="oid" displayName="Variable bindings prefix" type="string" required="true">
<c:description>
<![CDATA[
- <p>Variable bindings prefix. RHQ will send alert notification details as a list of variable bindings in the
+ <p>RHQ will send alert notification details as a list of variable bindings in the
SNMP trap PDU.</p>
- <p><strong>Do not confuse this paramater with Trap Oid.</strong></p>
+ <p><strong>Do not confuse this paramater with 'Trap Oid'.</strong></p>
]]>
</c:description>
</c:simple-property>
@@ -86,10 +86,10 @@
<c:description>
<![CDATA[
<p>If set, the value of this paramater will override the value of the Trap Oid parameter defined globally
- in the server plugin configuration. The trap OID is sent as the second variable binding in the SNMP trap
+ in the server plugin configuration. The Trap OID is sent as the second variable binding in the SNMP trap
PDU.</p>
<p><strong>Only applicable to v2c and v3 traps.</strong></p>
- <p><strong>Do not confuse this paramater with Oid.</strong></p>
+ <p><strong>Do not confuse this paramater with 'Variable bindings prefix'.</strong></p>
]]>
</c:description>
</c:simple-property>
11 years
[rhq] Branch 'feature/cassandra-backend' - modules/common
by John Sanda
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptionsFactory.java | 11 ++++++++++
modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java | 4 +++
2 files changed, 15 insertions(+)
New commits:
commit c95589acf496f891f07417c5b9610dc64e7de0f5
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Apr 26 21:41:39 2013 -0400
adding javadocs
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptionsFactory.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptionsFactory.java
index 7e585ac..5c111d6 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptionsFactory.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptionsFactory.java
@@ -26,10 +26,21 @@
package org.rhq.cassandra;
/**
+ * Creates {@link DeploymentOptions} objects.
+ *
* @author John Sanda
*/
public class DeploymentOptionsFactory {
+ /**
+ * @return A new {@link DeploymentOptions}. This method checks the platform arch
+ * (32 bit vs 64 bit) and the JRE being used to determine if any particular defaults
+ * need to be set. For example, on 32 bit arches running on OpenJDK 6, Cassandra
+ * cannot use its default thread stack stack of 180k. It causes the JVM to segfault on
+ * start up. When this runtime environment is detected, the factory will set the
+ * appropriate system property so that a default thread stack of 240k is used. That
+ * can be overridden by calling {@link DeploymentOptions#setStackSize(String)}.
+ */
public DeploymentOptions newDeploymentOptions() {
String arch = System.getProperty("os.arch");
String javaVMName = System.getProperty("java.vm.name");
diff --git a/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java b/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java
index 6502df9..f6f81cf 100644
--- a/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java
+++ b/modules/common/cassandra-util/src/main/java/org/rhq/cassandra/util/ClusterBuilder.java
@@ -30,6 +30,10 @@ import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ProtocolOptions;
/**
+ * This class should generally be used for creating a {@link Cluster} instead of
+ * {@link Cluster.Builder}. It ensures that the cluster and session objects are configured
+ * in a consistent fashion everywhere they are used.
+ *
* @author John Sanda
*/
public class ClusterBuilder {
11 years
[rhq] modules/core modules/plugins
by mazz
modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java | 92 +++
modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerCanonicalPathTest.java | 275 ++++++++++
modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java | 173 +++++-
modules/plugins/ant-bundle/src/test/resources/test-bundle-dotdot.xml | 19
4 files changed, 547 insertions(+), 12 deletions(-)
New commits:
commit 8ae20bd510aa660e94f70cad95fc680fd0dedd47
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Apr 26 14:41:02 2013 -0400
BZ 917085 - allow for relative and absolute raw file paths to include ".."
diff --git a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
index e81fbaa..c55c1bc 100644
--- a/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
+++ b/modules/core/util/src/main/java/org/rhq/core/util/updater/DeploymentData.java
@@ -30,6 +30,7 @@ import java.util.Set;
import java.util.regex.Pattern;
import org.rhq.core.template.TemplateEngine;
+import org.rhq.core.util.file.FileUtil;
/**
* Data that describes a particular deployment. In effect, this provides the
@@ -114,7 +115,7 @@ public class DeploymentData {
this.deploymentProps = deploymentProps;
this.zipFiles = zipFiles;
this.rawFiles = rawFiles;
- this.destinationDir = destinationDir;
+ this.destinationDir = getCanonicalFile(destinationDir);
this.sourceDir = sourceDir;
this.ignoreRegex = ignoreRegex;
this.manageRootDir = manageRootDir;
@@ -131,6 +132,69 @@ public class DeploymentData {
this.templateEngine = templateEngine;
}
+ // We need to "normalize" all raw file paths that have ".." in them to ensure everything works properly.
+ // Any raw file pathname (the values in this.rawFiles) that needs to be normalized will be converted to
+ // a canonical path. Note that any pathname that is relative but have ".." paths that end up taking the file
+ // above the destination directory needs to be normalized and will end up being an absolute path
+ // (so all log messages will indicate the full absolute path and if the file
+ // needs to be backed up it will be backed up as if it was an external file that was specified with an absolute path).
+ // If the relative path has ".." but does not take the file above the destination directory will simply have its ".."
+ // normalized out but will still be a relative path (relative to destination directory) (we can't make it absolute
+ // otherwise Deployer's update will run into errors while backing up and scanning for deleted files).
+ // See BZ 917085.
+ for (Map.Entry<File, File> entry : this.rawFiles.entrySet()) {
+ File rawFile = entry.getValue();
+ String rawFilePath = rawFile.getPath();
+
+ boolean doubledot = rawFilePath.replace('\\', '/').matches(".*((/\\.\\.)|(\\.\\./)).*"); // finds "/.." or "../" in the string
+
+ if (doubledot) {
+ File fileToCanonicalize;
+
+ if (rawFile.isAbsolute()) {
+ fileToCanonicalize = rawFile;
+ } else {
+ boolean isWindows = (File.separatorChar == '\\');
+ if (isWindows) {
+ // of course, Windows has to make it enormously difficult to do this right...
+
+ // determine if the windows rawFile relative path specified a drive (e.g. C:foobar.txt)
+ StringBuilder rawFilePathBuilder = new StringBuilder(rawFilePath);
+ String rawFileDriveLetter = FileUtil.stripDriveLetter(rawFilePathBuilder); // rawFilePathBuilder now has drive letter stripped
+
+ // determine what, if any, drive letter is specified in the destination directory
+ StringBuilder destDirAbsPathBuilder = new StringBuilder(this.destinationDir.getAbsolutePath());
+ String destDirDriveLetter = FileUtil.stripDriveLetter(destDirAbsPathBuilder);
+
+ // figure out what the absolute, normalized path is for the raw file
+ if ((destDirDriveLetter == null || rawFileDriveLetter == null)
+ || rawFileDriveLetter.equals(destDirDriveLetter)) {
+ fileToCanonicalize = new File(this.destinationDir, rawFilePathBuilder.toString());
+ } else {
+ throw new IllegalArgumentException("Cannot normalize relative path [" + rawFilePath
+ + "]; its drive letter is different than the destination directory ["
+ + this.destinationDir.getAbsolutePath() + "]");
+ }
+ } else {
+ fileToCanonicalize = new File(this.destinationDir, rawFilePath);
+ }
+ }
+
+ fileToCanonicalize = getCanonicalFile(fileToCanonicalize);
+
+ if (isPathUnderBaseDir(this.destinationDir, fileToCanonicalize)) {
+ // we can keep rawFile path relative, but we need to normalize out the ".." paths
+ String baseDir = this.destinationDir.getAbsolutePath();
+ String absRawFilePath = fileToCanonicalize.getAbsolutePath();
+ String canonicalRelativePath = absRawFilePath.substring(baseDir.length() + 1); // should always return a valid path; if not, let it throw exception (which likely means there is a bug here)
+ entry.setValue(new File(canonicalRelativePath));
+ } else {
+ // raw file path has ".." such that the file is really above destination dir - use an absolute, canonical path
+ entry.setValue(fileToCanonicalize);
+ }
+ }
+ }
+
return;
}
@@ -177,4 +241,30 @@ public class DeploymentData {
public Map<File, Boolean> getZipsExploded() {
return zipsExploded;
}
+
+ private File getCanonicalFile(File file) {
+ try {
+ file = file.getCanonicalFile();
+ } catch (Exception e) {
+ // ignore this - this really should never happen, but if it does,
+ // we want to continue and hope using the non-normalized file is ok;
+ file = file.getAbsoluteFile();
+ }
+ return file;
+ }
+
+ private boolean isPathUnderBaseDir(File base, File path) {
+ // this method assumes base and path are absolute and canonical
+ if (base == null) {
+ return false;
+ }
+
+ while (path != null) {
+ if (base.equals(path)) {
+ return true;
+ }
+ path = path.getParentFile();
+ }
+ return false;
+ }
}
diff --git a/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerCanonicalPathTest.java b/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerCanonicalPathTest.java
new file mode 100644
index 0000000..7a62bf0
--- /dev/null
+++ b/modules/core/util/src/test/java/org/rhq/core/util/updater/DeployerCanonicalPathTest.java
@@ -0,0 +1,275 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * 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 and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.util.updater;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.template.TemplateEngine;
+import org.rhq.core.util.MessageDigestGenerator;
+import org.rhq.core.util.file.FileUtil;
+import org.rhq.core.util.stream.StreamUtil;
+
+/**
+ * Tests deploying raw files to deployment locations specified with ".." in the path.
+ * This will require the deployer code to transform the paths to canonical paths.
+ *
+ * @author John Mazzitelli
+ */
+@Test
+public class DeployerCanonicalPathTest {
+ private TemplateEngine templateEngine;
+
+ @BeforeClass
+ public void beforeClass() {
+ Map<String, String> tokens = new HashMap<String, String>();
+ tokens.put("rhq.system.hostname", "localhost");
+ tokens.put("rhq.system.sysprop.java.version", System.getProperty("java.version"));
+
+ templateEngine = new TemplateEngine(tokens);
+ }
+
+ @BeforeMethod
+ public void beforeMethod() {
+ System.out.println("\n\n=============== START OF NEW TEST ===============\n");
+ }
+
+ // any raw file path (absolute or relative) that contains ".." will be converted to an absolute, canonical path - this is what we test
+ public void testInitialDeployRawFilesWithCanonicalPaths() throws Exception {
+ File tmpDirDest = FileUtil.createTempDirectory("DeployerCanonicalPathTest", ".dest", null);
+ File tmpDirSrc = FileUtil.createTempDirectory("DeployerCanonicalPathTest", ".src", null);
+ File rawFileRelativeDest = new File("dir-does-not-existA/../rawA.txt"); // relative to "tmpDirDest" that we just created above
+ File rawFileRelativeDest2 = new File("dir-does-not-existA/../../rawA.txt"); // relative to "tmpDirDest" but it takes us above it
+ File rawFileAbsoluteDest = new File(System.getProperty("java.io.tmpdir"), "dir-does-not-existB/../rawB.txt");
+
+ try {
+ // put some source files in our tmpDirSrc location
+ File testRawFileA = new File(tmpDirSrc, "updater-testA.txt");
+ File testRawFileA2 = new File(tmpDirSrc, "updater-testA2.txt");
+ File testRawFileB = new File(tmpDirSrc, "updater-testB.txt");
+ FileUtil.copyFile(new File("target/test-classes/updater-testA.txt"), testRawFileA);
+ FileUtil.copyFile(new File("target/test-classes/updater-testA.txt"), testRawFileA2);
+ FileUtil.copyFile(new File("target/test-classes/updater-testB.txt"), testRawFileB);
+
+ DeploymentProperties deploymentProps = new DeploymentProperties(0, "testbundle", "1.0.test", null);
+ Set<File> zipFiles = null;
+ Map<File, File> rawFiles = new HashMap<File, File>(3);
+ rawFiles.put(testRawFileA, rawFileRelativeDest); // we will realize this one ...
+ rawFiles.put(testRawFileA2, rawFileRelativeDest2); // and this one ...
+ rawFiles.put(testRawFileB, rawFileAbsoluteDest); // and we will realize this one, too
+ File destDir = tmpDirDest;
+ Pattern ignoreRegex = null;
+ Set<File> realizeRawFiles = new HashSet<File>(3);
+ realizeRawFiles.add(testRawFileA);
+ realizeRawFiles.add(testRawFileA2);
+ realizeRawFiles.add(testRawFileB);
+ DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDirSrc, destDir, null,
+ realizeRawFiles, templateEngine, ignoreRegex, true, null);
+ Deployer deployer = new Deployer(dd);
+ DeployDifferences diff = new DeployDifferences();
+ FileHashcodeMap map = deployer.deploy(diff);
+ System.out.println("map-->\n" + map);
+ System.out.println("diff->\n" + diff);
+
+ String rawFileRelativeDestCanonical = new File(tmpDirDest, rawFileRelativeDest.getPath()).getCanonicalPath();
+ String rawFileRelativeDestCanonical2 = new File(tmpDirDest, rawFileRelativeDest2.getPath())
+ .getCanonicalPath();
+ String rawFileAbsoluteDestCanonical = rawFileAbsoluteDest.getCanonicalPath();
+
+ assert map.size() == 3 : map;
+
+ assert map.containsKey("rawA.txt") : map;
+ assert new File(rawFileRelativeDestCanonical).exists();
+ assert new File(rawFileRelativeDestCanonical2).exists();
+ assert MessageDigestGenerator.getDigestString(new File(rawFileRelativeDestCanonical)).equals(
+ map.get("rawA.txt"));
+
+ // rawFileRelativeDestCanonical2 should be treated just like an absolute, external file
+ assert MessageDigestGenerator.getDigestString(new File(rawFileRelativeDestCanonical2)).equals(
+ map.get(rawFileRelativeDestCanonical2));
+ assert !MessageDigestGenerator.getDigestString(testRawFileA).equals(map.get("rawA.txt")) : "should have different hash, we realize this one!";
+
+ assert map.containsKey(rawFileAbsoluteDestCanonical) : map;
+ assert new File(rawFileAbsoluteDestCanonical).exists();
+ assert MessageDigestGenerator.getDigestString(new File(rawFileAbsoluteDestCanonical)).equals(
+ map.get(rawFileAbsoluteDestCanonical));
+ assert !MessageDigestGenerator.getDigestString(testRawFileB).equals(map.get(rawFileAbsoluteDestCanonical)) : "should have different hash, we realized this one";
+
+ assert diff.getAddedFiles().size() == 3 : diff;
+ assert diff.getAddedFiles().contains(diff.convertPath("rawA.txt")) : diff;
+ assert diff.getAddedFiles().contains(diff.convertPath(rawFileRelativeDestCanonical2)) : diff;
+ assert diff.getAddedFiles().contains(diff.convertPath(rawFileAbsoluteDestCanonical)) : diff;
+ assert diff.getRealizedFiles().size() == 3 : diff;
+ assert diff.getRealizedFiles().keySet().contains(diff.convertPath("rawA.txt")) : diff;
+ assert diff.getRealizedFiles().keySet().contains(diff.convertPath(rawFileRelativeDestCanonical2)) : diff;
+ assert diff.getRealizedFiles().keySet().contains(diff.convertPath(rawFileAbsoluteDestCanonical)) : diff;
+ } finally {
+ FileUtil.purge(tmpDirDest, true);
+ FileUtil.purge(tmpDirSrc, true);
+ rawFileAbsoluteDest.getCanonicalFile().delete();
+ }
+ }
+
+ public void testUpdateDeployRawFileWithRelativePath() throws Exception {
+ File tmpDirDest = FileUtil.createTempDirectory("DeployerCanonicalPathTest", ".dest", null);
+ File tmpDirSrc = FileUtil.createTempDirectory("DeployerCanonicalPathTest", ".src", null);
+ File rawFileRelativeDest = new File("dir-does-not-existA/../rawA.txt"); // relative to "tmpDirDest" that we just created above
+ File rawFileRelativeDest2 = new File("dir-does-not-existA/../../rawA.txt"); // relative to "tmpDirDest" but it takes us above it
+ File rawFileAbsoluteDest = new File(System.getProperty("java.io.tmpdir"), "dir-does-not-existB/../rawB.txt");
+
+ try {
+ // put some source files in our tmpDirSrc location
+ File testRawFileA = new File(tmpDirSrc, "updater-testA.txt");
+ File testRawFileA2 = new File(tmpDirSrc, "updater-testA2.txt");
+ File testRawFileB = new File(tmpDirSrc, "updater-testB.txt");
+ FileUtil.copyFile(new File("target/test-classes/updater-testA.txt"), testRawFileA);
+ FileUtil.copyFile(new File("target/test-classes/updater-testA.txt"), testRawFileA2);
+ FileUtil.copyFile(new File("target/test-classes/updater-testB.txt"), testRawFileB);
+
+ DeploymentProperties deploymentProps = new DeploymentProperties(0, "testbundle", "1.0.test", null);
+ Set<File> zipFiles = null;
+ Map<File, File> rawFiles = new HashMap<File, File>(3);
+ rawFiles.put(testRawFileA, rawFileRelativeDest);
+ rawFiles.put(testRawFileA2, rawFileRelativeDest2);
+ rawFiles.put(testRawFileB, rawFileAbsoluteDest);
+ File destDir = tmpDirDest;
+ Pattern ignoreRegex = null;
+ DeploymentData dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDirSrc, destDir, null, null,
+ templateEngine, ignoreRegex, true, null);
+ Deployer deployer = new Deployer(dd);
+ DeployDifferences diff = new DeployDifferences();
+ FileHashcodeMap map = deployer.deploy(diff);
+ System.out.println("map-->\n" + map);
+ System.out.println("diff->\n" + diff);
+ assert map.size() == 3 : map;
+
+ // make sure the first raw file is in the dest dir
+ String f = rawFileRelativeDest.getPath();
+ File destFile = new File(tmpDirDest, f).getCanonicalFile(); // notice f is assumed relative to tmpDirDest, must convert to canonical path
+ assert destFile.exists() : destFile;
+ FileUtil.writeFile(new ByteArrayInputStream("modifiedR".getBytes()), destFile); // change the file so we back it up during update
+
+ // make sure the second raw file, though specified originally as a relative file, is in the external location
+ f = rawFileRelativeDest2.getPath();
+ destFile = new File(tmpDirDest, f).getCanonicalFile(); // must convert to canonical path
+ assert destFile.exists() : destFile;
+ FileUtil.writeFile(new ByteArrayInputStream("modifiedR2".getBytes()), destFile); // change the file so we back it up during update
+
+ // make sure the third raw file is in the external location
+ destFile = rawFileAbsoluteDest.getCanonicalFile(); // must convert to canonical path
+ assert destFile.exists() : destFile;
+ FileUtil.writeFile(new ByteArrayInputStream("modifiedA".getBytes()), destFile); // change the file so we back it up during update
+
+ // UPDATE
+ // alter the src files so we backup our changed files
+ FileUtil.writeFile(new ByteArrayInputStream("src.modifiedR".getBytes()), testRawFileA);
+ FileUtil.writeFile(new ByteArrayInputStream("src.modifiedR2".getBytes()), testRawFileA2);
+ FileUtil.writeFile(new ByteArrayInputStream("src.modifiedA".getBytes()), testRawFileB);
+
+ deploymentProps = new DeploymentProperties(1, "testbundle", "2.0.test", null);
+ dd = new DeploymentData(deploymentProps, zipFiles, rawFiles, tmpDirSrc, destDir, null, null,
+ templateEngine, ignoreRegex, true, null);
+ deployer = new Deployer(dd);
+ diff = new DeployDifferences();
+ map = deployer.deploy(diff);
+ System.out.println("map-->\n" + map);
+ System.out.println("diff->\n" + diff);
+
+ String rawFileRelativeDestCanonical = new File(tmpDirDest, rawFileRelativeDest.getPath())
+ .getCanonicalPath();
+ String rawFileRelativeDestCanonical2 = new File(tmpDirDest, rawFileRelativeDest2.getPath())
+ .getCanonicalPath();
+ String rawFileAbsoluteDestCanonical = rawFileAbsoluteDest.getCanonicalPath();
+
+ assert new String(StreamUtil.slurp(new FileInputStream(new File(rawFileRelativeDestCanonical))))
+ .equals("src.modifiedR");
+ assert new String(StreamUtil.slurp(new FileInputStream(new File(rawFileRelativeDestCanonical2))))
+ .equals("src.modifiedR2");
+ assert new String(StreamUtil.slurp(new FileInputStream(new File(rawFileAbsoluteDestCanonical))))
+ .equals("src.modifiedA");
+
+ boolean isWindows = File.separatorChar == '\\';
+ final File metadir = new File(tmpDirDest, ".rhqdeployments");
+ File backupRel = new File(metadir, "1/backup/rawA.txt");
+ File backupRel2;
+ // test the second raw file, the one that was specified originally as a relative file but took us out of the dest dir
+ if (!isWindows) {
+ backupRel2 = new File(metadir, "1/ext-backup/" + rawFileRelativeDestCanonical2);
+ } else {
+ StringBuilder str = new StringBuilder(rawFileRelativeDestCanonical2);
+ String driveLetter = FileUtil.stripDriveLetter(str);
+ if (driveLetter != null) {
+ driveLetter = "_" + driveLetter + '/';
+ } else {
+ driveLetter = "";
+ }
+ backupRel2 = new File(metadir, "1/ext-backup/" + driveLetter + str.toString());
+ }
+ // test the third raw file, the one that was specified originally as an absolute, external file
+ File backupAbs;
+ if (!isWindows) {
+ backupAbs = new File(metadir, "1/ext-backup/" + rawFileAbsoluteDestCanonical);
+ } else {
+ StringBuilder str = new StringBuilder(rawFileAbsoluteDestCanonical);
+ String driveLetter = FileUtil.stripDriveLetter(str);
+ if (driveLetter != null) {
+ driveLetter = "_" + driveLetter + '/';
+ } else {
+ driveLetter = "";
+ }
+ backupAbs = new File(metadir, "1/ext-backup/" + driveLetter + str.toString());
+ }
+
+ // the backup files should exist
+ assert backupRel.exists() : backupRel;
+ assert backupRel2.exists() : backupRel2;
+ assert backupAbs.exists() : backupAbs;
+
+ assert map.size() == 3 : map;
+ assert diff.getChangedFiles().size() == 3 : diff;
+ assert diff.getChangedFiles().contains(diff.convertPath("rawA.txt")) : diff;
+ assert diff.getChangedFiles().contains(diff.convertPath(rawFileRelativeDestCanonical2)) : diff;
+ assert diff.getChangedFiles().contains(diff.convertPath(rawFileAbsoluteDestCanonical)) : diff;
+ assert diff.getDeletedFiles().isEmpty() : diff;
+ assert diff.getBackedUpFiles().size() == 3 : diff;
+ assert diff.getBackedUpFiles().keySet().contains(diff.convertPath("rawA.txt")) : diff;
+ assert diff.getBackedUpFiles().keySet().contains(diff.convertPath(rawFileRelativeDestCanonical2)) : diff;
+ assert diff.getBackedUpFiles().keySet().contains(diff.convertPath(rawFileAbsoluteDestCanonical)) : diff;
+ } finally {
+ FileUtil.purge(tmpDirDest, true);
+ FileUtil.purge(tmpDirSrc, true);
+ rawFileAbsoluteDest.getCanonicalFile().delete();
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
index daf5463..f0605a2 100644
--- a/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
+++ b/modules/plugins/ant-bundle/src/test/java/org/rhq/plugins/ant/AntBundlePluginComponentTest.java
@@ -26,10 +26,12 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.UUID;
@@ -70,20 +72,25 @@ import org.rhq.core.util.updater.DeploymentsMetadata;
@Test
public class AntBundlePluginComponentTest {
+ private static final boolean ENABLE_TESTS = true;
+
private static final String DEST_BASE_DIR_NAME = "Root File System"; // just mimics the real platform plugin types' name
private AntBundlePluginComponent plugin;
+ private File testFilesBaseDir; // under here will go all our test files: tmpDir, bundleFilesDir and destDir
private File tmpDir;
private File bundleFilesDir;
private File destDir;
@BeforeClass
public void initDirs() throws Exception {
- this.tmpDir = new File("target/antbundletest/tmp");
+ this.testFilesBaseDir = new File("target/antbundletest");
+
+ this.tmpDir = new File(this.testFilesBaseDir, "tmp");
FileUtil.purge(this.tmpDir, true);
- this.bundleFilesDir = new File("target/antbundletest/bundlefiles");
+ this.bundleFilesDir = new File(this.testFilesBaseDir, "bundlefiles");
FileUtil.purge(this.bundleFilesDir, true);
- this.destDir = new File("target/antbundletest/destination");
+ this.destDir = new File(this.testFilesBaseDir, "destination");
FileUtil.purge(this.destDir, true);
}
@@ -117,7 +124,7 @@ public class AntBundlePluginComponentTest {
FileUtil.purge(this.destDir, true);
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAntBundleRevert() throws Exception {
// install then upgrade a bundle first
testAntBundleUpgrade();
@@ -227,17 +234,17 @@ public class AntBundlePluginComponentTest {
assert previousProps.getBundleVersion().equals("3.0"); // testAntBundleUpgrade deployed version 3.0
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAntBundleUpgrade() throws Exception {
upgrade(false);
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAntBundleCleanUpgrade() throws Exception {
upgrade(true);
}
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAntBundleInitialInstall() throws Exception {
doAntBundleInitialInstall(true);
}
@@ -348,7 +355,7 @@ public class AntBundlePluginComponentTest {
/**
* Test deployment of an RHQ bundle recipe.
*/
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAntBundle() throws Exception {
ResourceType resourceType = new ResourceType("testSimpleBundle", "plugin", ResourceCategory.SERVER, null);
BundleType bundleType = new BundleType("testSimpleBundle", resourceType);
@@ -412,9 +419,149 @@ public class AntBundlePluginComponentTest {
}
/**
+ * Test raw files whose destination locations have ".." in their paths.
+ */
+ @Test(enabled = ENABLE_TESTS)
+ public void testRawFilesWithDotDotPaths() throws Exception {
+ // our test bundle's relative raw file paths that resolve above dest dir will resolve to here
+ final File externalDir = new File(this.testFilesBaseDir, "ext");
+
+ ResourceType resourceType = new ResourceType("testSimpleBundle", "plugin", ResourceCategory.SERVER, null);
+ BundleType bundleType = new BundleType("testSimpleBundle", resourceType);
+ Repo repo = new Repo("testSimpleBundle");
+ PackageType packageType = new PackageType("testSimpleBundle", resourceType);
+ Bundle bundle = new Bundle("testSimpleBundle", bundleType, repo, packageType);
+ BundleVersion bundleVersion = new BundleVersion("testSimpleBundle", "1.0", bundle,
+ getRecipeFromFile("test-bundle-dotdot.xml"));
+ BundleDestination destination = new BundleDestination(bundle, "testSimpleBundle", new ResourceGroup(
+ "testSimpleBundle"), DEST_BASE_DIR_NAME, this.destDir.getAbsolutePath());
+ Configuration config = new Configuration();
+
+ BundleDeployment deployment = new BundleDeployment();
+ deployment.setId(0);
+ deployment.setName("test bundle deployment name");
+ deployment.setBundleVersion(bundleVersion);
+ deployment.setConfiguration(config);
+ deployment.setDestination(destination);
+
+ // create test files (see bundle recipe for why these files are created)
+ final String TEST1 = "test1.txt";
+ File file1 = new File(this.bundleFilesDir, TEST1);
+ writeFile(TEST1, file1);
+
+ final String TEST2 = "test2.txt";
+ File file2 = new File(this.bundleFilesDir, TEST2);
+ writeFile(TEST2, file2);
+
+ final String TEST3 = "test3.txt";
+ File file3 = new File(this.bundleFilesDir, TEST3);
+ writeFile(TEST3, file3);
+
+ final String TEST4 = "test4.txt";
+ File file4 = new File(this.bundleFilesDir, TEST4);
+ writeFile(TEST4, file4);
+
+ // ----- initial deployment -----
+ BundleDeployRequest request = new BundleDeployRequest();
+ request.setBundleFilesLocation(this.bundleFilesDir);
+ request.setResourceDeployment(createNewBundleDeployment(deployment));
+ request.setBundleManagerProvider(new MockBundleManagerProvider());
+ request.setAbsoluteDestinationDirectory(this.destDir);
+ BundleDeployResult results = plugin.deployBundle(request);
+ assertResultsSuccess(results);
+
+ // test that the files were put where we expected them to be
+ File file1Dest = new File(this.destDir, "subdir/" + TEST1);
+ File file2Dest = new File(this.destDir, TEST2);
+ File file3Dest = new File(externalDir, TEST3);
+ File file4Dest = new File(externalDir, TEST4);
+ assert TEST1.equals(readFile(file1Dest)); // inside dest dir
+ assert TEST2.equals(readFile(file2Dest)); // inside dest dir
+ assert TEST3.equals(readFile(file3Dest)); // outside dest dir
+ assert TEST4.equals(readFile(file4Dest)); // outside dest dir
+
+ // ----- prepare to update the bundle ----
+ cleanPluginDirs(); // clean everything but the dest dir - we want to keep the metadata (this should not purge ext/ dir)
+ prepareBeforeTestMethod(); // prepare for our new test
+ // our src files will have different content for this bundle deployment compared to the initial deployment
+ writeFile(TEST1 + "update", file1);
+ writeFile(TEST2 + "update", file2);
+ writeFile(TEST3 + "update", file3);
+ writeFile(TEST4 + "update", file4);
+ // change our initial deployment files, RHQ should see the changes and back these files up
+ writeFile(TEST1 + "modified", file1Dest);
+ writeFile(TEST2 + "modified", file2Dest);
+ writeFile(TEST3 + "modified", file3Dest);
+ writeFile(TEST4 + "modified", file4Dest);
+
+ // ----- update deployment -----
+ deployment.setId(1);
+ request = new BundleDeployRequest();
+ request.setBundleFilesLocation(this.bundleFilesDir);
+ request.setResourceDeployment(createNewBundleDeployment(deployment));
+ request.setBundleManagerProvider(new MockBundleManagerProvider());
+ request.setAbsoluteDestinationDirectory(this.destDir);
+ results = plugin.deployBundle(request);
+ assertResultsSuccess(results);
+
+ // test that all files were updated
+ assert (TEST1 + "update").equals(readFile(file1Dest)); // inside dest dir
+ assert (TEST2 + "update").equals(readFile(file2Dest)); // inside dest dir
+ assert (TEST3 + "update").equals(readFile(file3Dest)); // outside dest dir
+ assert (TEST4 + "update").equals(readFile(file4Dest)); // outside dest dir
+
+ // test that our changed files that were under dest dir were properly backed up
+ DeploymentsMetadata metadata = new DeploymentsMetadata(this.destDir);
+ File backupDir = metadata.getDeploymentBackupDirectory(deployment.getId());
+ File file1Backup = new File(backupDir, "subdir/" + TEST1);
+ File file2Backup = new File(backupDir, TEST2);
+ assert file1Backup.isFile() : "should have been backed up: " + file1Backup;
+ assert file2Backup.isFile() : "should have been backed up: " + file2Backup;
+ assert (TEST1 + "modified").equals(readFile(file1Backup)) : "bad backup file: " + file1Backup;
+ assert (TEST2 + "modified").equals(readFile(file2Backup)) : "bad backup file: " + file2Backup;
+
+ // test that our changed files that were above dest dir were properly backed up
+ Map<String, File> winDirs = metadata.getDeploymentExternalBackupDirectoriesForWindows(deployment.getId());
+ if (winDirs == null) {
+ // we are running on non-windows platform
+ backupDir = metadata.getDeploymentExternalBackupDirectory(deployment.getId());
+ } else {
+ // we are on windows, our test only uses a single drive root, so we can grab the only item in the map
+ assert winDirs.size() == 1 : "should only have 1 ext backup dir on windows: " + winDirs;
+ backupDir = winDirs.values().iterator().next().getAbsoluteFile();
+ }
+ File file3Backup = new File(backupDir, file3Dest.getAbsolutePath());
+ File file4Backup = new File(backupDir, file4Dest.getAbsolutePath());
+ assert file3Backup.isFile() : "should have been backed up: " + file3Backup;
+ assert file4Backup.isFile() : "should have been backed up: " + file4Backup;
+ assert (TEST3 + "modified").equals(readFile(file3Backup)) : "bad backup file: " + file3Backup;
+ assert (TEST4 + "modified").equals(readFile(file4Backup)) : "bad backup file: " + file4Backup;
+
+ // ----- revert to last deployment, restoring backed up files
+ deployment.setId(2);
+ request = new BundleDeployRequest();
+ request.setBundleFilesLocation(this.bundleFilesDir);
+ request.setResourceDeployment(createNewBundleDeployment(deployment));
+ request.setBundleManagerProvider(new MockBundleManagerProvider());
+ request.setAbsoluteDestinationDirectory(this.destDir);
+ request.setRevert(true);
+ results = plugin.deployBundle(request);
+ assertResultsSuccess(results);
+
+ // make sure our files were reverted, giving us back the files that were backed up
+ assert readFile(file1Backup).equals(readFile(file1Dest)); // inside dest dir
+ assert readFile(file2Backup).equals(readFile(file2Dest)); // inside dest dir
+ assert readFile(file3Backup).equals(readFile(file3Dest)); // outside dest dir
+ assert readFile(file4Backup).equals(readFile(file4Dest)); // outside dest dir
+
+ // ----- clean up our test -----
+ FileUtil.purge(externalDir, true);
+ }
+
+ /**
* Test realizing of replacement tokens of resource tags.
*/
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testTags() throws Exception {
ResourceType resourceType = new ResourceType("testSimpleBundle", "plugin", ResourceCategory.SERVER, null);
BundleType bundleType = new BundleType("testSimpleBundle", resourceType);
@@ -484,7 +631,7 @@ public class AntBundlePluginComponentTest {
/**
* Test deployment of an RHQ bundle recipe where the deploy directory is not to be fully managed.
*/
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAntBundleNoManageRootDir() throws Exception {
ResourceType resourceType = new ResourceType("testNoManageRootDirBundle", "plugin", ResourceCategory.SERVER,
null);
@@ -618,7 +765,7 @@ public class AntBundlePluginComponentTest {
* Test deployment of an RHQ bundle recipe where the deploy directory is to be fully managed.
* This is the typical use-case and the default behavior.
*/
- @Test(enabled = true)
+ @Test(enabled = ENABLE_TESTS)
public void testAntBundleManageRootDir() throws Exception {
ResourceType resourceType = new ResourceType("testManageRootDirBundle", "plugin", ResourceCategory.SERVER, null);
BundleType bundleType = new BundleType("testManageRootDirBundle", resourceType);
@@ -878,6 +1025,10 @@ public class AntBundlePluginComponentTest {
return new String(StreamUtil.slurp(new FileInputStream(file)));
}
+ private void writeFile(final String content, final File file) throws IOException {
+ FileUtil.writeFile(new ByteArrayInputStream(content.getBytes()), file);
+ }
+
private void loadProperties(Properties realizedProps, FileInputStream fileInputStream) throws Exception {
try {
realizedProps.load(fileInputStream);
diff --git a/modules/plugins/ant-bundle/src/test/resources/test-bundle-dotdot.xml b/modules/plugins/ant-bundle/src/test/resources/test-bundle-dotdot.xml
new file mode 100644
index 0000000..f96b241
--- /dev/null
+++ b/modules/plugins/ant-bundle/src/test/resources/test-bundle-dotdot.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+
+<project name="bundle-dotdot" default="main" xmlns:rhq="antlib:org.rhq.bundle">
+
+ <rhq:bundle name="bundle-dotdot" version="1.0"
+ description="testing raw files with .. in their destination paths">
+
+ <rhq:deployment-unit name="bundle">
+ <rhq:file name="test1.txt" destinationFile="nothere/../phantom/../subdir/test1.txt" /> <!-- still under dest dir -->
+ <rhq:file name="test2.txt" destinationDir="nothere/../" /> <!-- still under dest dir -->
+ <rhq:file name="test3.txt" destinationFile="../ext/test3.txt" /> <!-- external location outside dest dir-->
+ <rhq:file name="test4.txt" destinationDir="../ext" /> <!-- external location outside dest dir-->
+ </rhq:deployment-unit>
+
+ </rhq:bundle>
+
+ <target name="main"/>
+
+</project>
\ No newline at end of file
11 years
[rhq] Changes to 'tsegismont/data-migrator'
by Thomas Segismont
New branch 'tsegismont/data-migrator' available with the following commits:
commit dad49bc66af203a6d82533ace027114c8fb0be11
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Fri Apr 26 09:46:48 2013 +0200
Introduce ExistingDataSource abstraction
11 years
[rhq] modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/client/security/test/ScriptingAPIServerTest.java | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit 06da5f05ae6b970dd16db61226626c45530655f5
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Apr 26 10:39:32 2013 +0200
Don't test the TagManager if it is not enabled.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/client/security/test/ScriptingAPIServerTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/client/security/test/ScriptingAPIServerTest.java
index 0195603..aa0ebd4 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/client/security/test/ScriptingAPIServerTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/client/security/test/ScriptingAPIServerTest.java
@@ -88,6 +88,10 @@ public class ScriptingAPIServerTest extends ScriptableAbstractEJB3Test {
for (RhqManager m : RhqManager.values()) {
String name = m.name();
+ // Only check for the TagManager if it is enabled at all
+ if (name.contains("TagManager") && !RhqManager.TagManager.enabled()) {
+ continue;
+ }
Object scriptedManager = engine.eval(name);
assertNotNull(scriptedManager);
11 years
[rhq] modules/integration-tests pom.xml
by Heiko W. Rupp
modules/integration-tests/jndi-access/jndi-access-test/pom.xml | 47 +++++-----
modules/integration-tests/jndi-access/jndi-access-test/src/test/resources/arquillian.xml | 2
pom.xml | 7 +
3 files changed, 34 insertions(+), 22 deletions(-)
New commits:
commit 24ca08b47b9c9b9f23b5c993ec1f04b158c9be43
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Apr 26 10:17:45 2013 +0200
Get the jndi-access test to work with JBoss EAP 6.1alpha1
diff --git a/modules/integration-tests/jndi-access/jndi-access-test/pom.xml b/modules/integration-tests/jndi-access/jndi-access-test/pom.xml
index 03dfcc9..f83573d 100644
--- a/modules/integration-tests/jndi-access/jndi-access-test/pom.xml
+++ b/modules/integration-tests/jndi-access/jndi-access-test/pom.xml
@@ -15,7 +15,7 @@
<properties>
<jboss.zip>${settings.localRepository}/org/jboss/as/jboss-as-dist/${jboss.version}/jboss-as-dist-${jboss.version}.zip</jboss.zip>
- <jboss.unzip.location>${basedir}/target/jboss-as-${jboss.version}</jboss.unzip.location>
+ <jboss.unzip.location>${basedir}/target/${jboss.eap.version}</jboss.unzip.location>
<jnp.port>54987</jnp.port>
<jnp.rmiPort>54988</jnp.rmiPort>
</properties>
@@ -26,21 +26,21 @@
<artifactId>log4j</artifactId>
<scope>runtime</scope>
</dependency>
-
+
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-dist</artifactId>
<type>zip</type>
<scope>provided</scope>
</dependency>
-
+
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb3</artifactId>
<version>${jboss.version}</version>
<scope>test</scope>
</dependency>
-
+
<dependency>
<groupId>org.rhq</groupId>
<artifactId>rhq-scripting-api</artifactId>
@@ -54,7 +54,7 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
-
+
<dependency>
<groupId>org.rhq</groupId>
<artifactId>rhq-scripting-python</artifactId>
@@ -69,7 +69,7 @@
<scope>test</scope>
</dependency>
- <!-- We need to pull some classes from the server jar and itests-2 - namely the naming hack to be able to test
+ <!-- We need to pull some classes from the server jar and itests-2 - namely the naming hack to be able to test
that it actually works -->
<dependency>
<groupId>org.rhq</groupId>
@@ -84,20 +84,20 @@
<artifactId>arquillian-testng-container</artifactId>
<scope>test</scope>
</dependency>
-
+
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>provided</scope>
</dependency>
-
+
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
-
+
<!-- We'll try remote connections using JNP -->
<dependency>
<groupId>jboss</groupId>
@@ -105,7 +105,7 @@
<version>4.2.2.GA</version>
<scope>test</scope>
</dependency>
-
+
<!-- This is here only to ensure the build order and HAS TO COME AS LAST to avoid any classpath
collisions. -->
<dependency>
@@ -148,6 +148,12 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.jboss.xnio</groupId>
+ <artifactId>xnio-api</artifactId>
+ <version>${xnio.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</profile>
@@ -158,13 +164,13 @@
<name>!remote-test-server</name>
</property>
</activation>
-
+
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<scope>test</scope>
- </dependency>
+ </dependency>
</dependencies>
</profile>
@@ -175,7 +181,7 @@
<name>remote-test-server</name>
</property>
</activation>
-
+
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
@@ -187,13 +193,12 @@
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-remote</artifactId>
- <version>${jboss.version}</version>
<scope>test</scope>
- </dependency>
+ </dependency>
</dependencies>
</profile>
</profiles>
-
+
<build>
<testResources>
<testResource>
@@ -211,8 +216,8 @@
<phase>process-test-resources</phase>
<configuration>
<target>
- <unzip src="${jboss.zip}" dest="${jboss.unzip.location}/.." />
- <copy file="src/test/resources/security.policy" toDir="${jboss.unzip.location}"/>
+ <unzip src="${jboss.zip}" dest="${jboss.unzip.location}/.." />
+ <copy file="src/test/resources/security.policy" toDir="${jboss.unzip.location}"/>
</target>
</configuration>
<goals>
@@ -221,10 +226,10 @@
</execution>
</executions>
</plugin>
-
+
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <!-- Everything but the web service tests, this is the standard
+ <!-- Everything but the web service tests, this is the standard
test execution -->
<configuration>
<excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
@@ -237,7 +242,7 @@
</systemPropertyVariables>
<argLine>${jacoco.unit-test.args} -Djava.security.manager -Djava.security.policy==${basedir}/target/test-classes/security.policy</argLine>
<additionalClasspathElements>
- <!-- The below is required for tests to run against
+ <!-- The below is required for tests to run against
Oracle. -->
<additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc6/${ojdbc6.version}/ojdbc6-${ojdbc6.version}.jar</additionalClasspathElement>
</additionalClasspathElements>
diff --git a/modules/integration-tests/jndi-access/jndi-access-test/src/test/resources/arquillian.xml b/modules/integration-tests/jndi-access/jndi-access-test/src/test/resources/arquillian.xml
index 8bee491..1783f59 100644
--- a/modules/integration-tests/jndi-access/jndi-access-test/src/test/resources/arquillian.xml
+++ b/modules/integration-tests/jndi-access/jndi-access-test/src/test/resources/arquillian.xml
@@ -1,7 +1,7 @@
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
-
+
<defaultProtocol type="Servlet 3.0" />
<container qualifier="as7" default="true">
<configuration>
diff --git a/pom.xml b/pom.xml
index d6489ef..da1506f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -153,6 +153,7 @@
<arquillian.version>1.0.3.Final</arquillian.version>
<arquillian.jboss.container.version>7.2.0.Final</arquillian.jboss.container.version>
<shrinkwrap-resolver.version>2.0.0-alpha-7</shrinkwrap-resolver.version>
+ <xnio.version>3.0.7.GA</xnio.version> <!-- needed in jndi-access tests to talk to the managed AS -->
<xercesImpl.version>2.9.1-jbossas-2</xercesImpl.version> <!-- see BZ-820629 and CVE-2009-2625 -->
<opencsv.version>1.8</opencsv.version>
<commons-httpclient.version>3.0.1</commons-httpclient.version>
@@ -725,6 +726,12 @@
</dependency>
<dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-arquillian-container-remote</artifactId>
+ <version>${arquillian.jboss.container.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.core</artifactId>
<version>${jacoco.version}</version>
11 years