modules/helpers/metrics-simulator/pom.xml
| 37 +++++
modules/helpers/metrics-simulator/src/main/assembly/bin/rhq-ms
| 46 ++++++
modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
| 6
modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/SimulatorCLI.java
| 70 ++++++++++
modules/helpers/metrics-simulator/src/main/resources/conf/log4j.properties
| 39 +++++
modules/helpers/metrics-simulator/src/main/resources/log4j.properties
| 39 -----
modules/helpers/metrics-simulator/src/main/scripts/assembly.xml
| 50 +++++++
7 files changed, 248 insertions(+), 39 deletions(-)
New commits:
commit 0e0f40338a226f3022ff3177a0a6ab1f7d7d8a00
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Feb 27 17:38:04 2013 -0500
inital commit for packaging simulator as stand-alone, cli app
The simulator can/will be executed with the rhq-ms shell script. Further
changes are needed to wire everything up.
diff --git a/modules/helpers/metrics-simulator/pom.xml
b/modules/helpers/metrics-simulator/pom.xml
index 2f30869..115faca 100644
--- a/modules/helpers/metrics-simulator/pom.xml
+++ b/modules/helpers/metrics-simulator/pom.xml
@@ -58,6 +58,24 @@
<artifactId>commons-math3</artifactId>
<version>3.1.1</version>
</dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${commons-logging.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
</dependencies>
<build>
@@ -68,6 +86,25 @@
<skipTests>true</skipTests>
</configuration>
</plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/scripts/assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/modules/helpers/metrics-simulator/src/main/assembly/bin/rhq-ms
b/modules/helpers/metrics-simulator/src/main/assembly/bin/rhq-ms
new file mode 100755
index 0000000..e4388a7
--- /dev/null
+++ b/modules/helpers/metrics-simulator/src/main/assembly/bin/rhq-ms
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+_DOLLARZERO=`readlink "$0" 2>/dev/null || echo "$0"`
+RHQ_MS_BIN_DIR_PATH=`dirname "$_DOLLARZERO"`
+
+if [ -z "$RHQ_MS_HOME" ]; then
+ cd $RHQ_MS_BIN_DIR_PATH/..
+fi
+
+RHQ_MS_HOME=`pwd`
+
+prepare_java()
+{
+ if [ -z "$JAVA_HOME" ]; then
+ echo "$JAVA_HOME must be set"
+ exit 1
+ fi
+ RHQ_MS_JAVA_EXE=$JAVA_HOME/bin/java
+}
+
+prepare_classpath()
+{
+ RHQ_MS_CLASSPATH="$RHQ_MS_HOME/conf"
+ lib_dir=`cd "$RHQ_MS_HOME/lib";ls -1 *.jar`
+ for jar in $lib_dir ; do
+ RHQ_MS_CLASSPATH="$RHQ_MS_CLASSPATH:$RHQ_MS_HOME/lib/$jar"
+ done
+}
+
+prepare_java_opts()
+{
+ if [ -z "$RHQ_MS_JAVA_OPTS" ]; then
+ RHQ_MS_JAVA_OPTS="-Xms64M -Xmx64M -Djava.net.preferIPv4Stack=true"
+ fi
+}
+
+launch_simulator()
+{
+ class="org.rhq.metrics.simulator.Simulator"
+ $RHQ_MS_JAVA_EXE $JAVA_OPTS -cp "$RHQ_MS_CLASSPATH"
org.rhq.metrics.simulator.SimulatorCLI "$@"
+}
+
+prepare_java
+prepare_classpath
+prepare_java_opts
+launch_simulator
diff --git
a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
index b2680f4..53d2a5e 100644
---
a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
+++
b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
@@ -179,4 +179,10 @@ public class Simulator {
return schedules;
}
+ public static void main(String[] args) {
+ System.out.println("Running simulator...");
+ Simulator simulator = new Simulator();
+ simulator.log.info("Testing logging...");
+ }
+
}
diff --git
a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/SimulatorCLI.java
b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/SimulatorCLI.java
new file mode 100644
index 0000000..93bb582
--- /dev/null
+++
b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/SimulatorCLI.java
@@ -0,0 +1,70 @@
+/*
+ *
+ * * RHQ Management Platform
+ * * Copyright (C) 2005-2012 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.metrics.simulator;
+
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+
+/**
+ * @author John Sanda
+ */
+public class SimulatorCLI {
+
+ private Options options;
+
+ public SimulatorCLI() {
+ options = new Options();
+
+ Option help = new Option("h", "help", false, "Display
this message.");
+ options.addOption(help);
+
+ Option simulation = new Option("s", "simulation", true,
"The simulation to run. Expected to be a JSON file.");
+ options.addOption(simulation);
+ }
+
+ public void exec(String[] args) {
+ if (args.length == 0) {
+ printUsage();
+ System.exit(1);
+ }
+ }
+
+ public void printUsage() {
+ HelpFormatter helpFormatter = new HelpFormatter();
+ String syntax = "rhq-ms [options]";
+ String header = "";
+
+ helpFormatter.setOptPrefix("");
+ helpFormatter.printHelp(syntax, header, options, null);
+ }
+
+ public static void main(String[] args) {
+ SimulatorCLI cli = new SimulatorCLI();
+ cli.exec(args);
+ }
+
+}
diff --git a/modules/helpers/metrics-simulator/src/main/resources/conf/log4j.properties
b/modules/helpers/metrics-simulator/src/main/resources/conf/log4j.properties
new file mode 100644
index 0000000..50c2e2a
--- /dev/null
+++ b/modules/helpers/metrics-simulator/src/main/resources/conf/log4j.properties
@@ -0,0 +1,39 @@
+#
+# /*
+# * RHQ Management Platform
+# * Copyright (C) 2005-2012 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.
+# */
+#
+
+log4j.rootCategory=INFO, FILE, CONSOLE
+
+log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
+log4j.appender.FILE.File=log/rhq-ms.log
+log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE.layout.ConversionPattern=%d{ISO8601} %-5p [%t] (%c{5}) - %m%n
+#log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+log4j.appender.FILE.Append=false
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%5p %d{HH:mm:ss,SSS} %m%n
+log4j.logger.org.rhq=DEBUG
\ No newline at end of file
diff --git a/modules/helpers/metrics-simulator/src/main/resources/log4j.properties
b/modules/helpers/metrics-simulator/src/main/resources/log4j.properties
deleted file mode 100644
index 9a3f64d..0000000
--- a/modules/helpers/metrics-simulator/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# /*
-# * RHQ Management Platform
-# * Copyright (C) 2005-2012 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.
-# */
-#
-
-log4j.rootCategory=INFO, FILE, CONSOLE
-
-log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
-log4j.appender.FILE.File=./target/test.log
-log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
-log4j.appender.FILE.layout.ConversionPattern=%d{ISO8601} %-5p [%t] (%c{5}) - %m%n
-#log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
-log4j.appender.FILE.Append=false
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%5p %d{HH:mm:ss,SSS} %m%n
-log4j.logger.org.rhq=DEBUG
\ No newline at end of file
diff --git a/modules/helpers/metrics-simulator/src/main/scripts/assembly.xml
b/modules/helpers/metrics-simulator/src/main/scripts/assembly.xml
new file mode 100644
index 0000000..6bee585
--- /dev/null
+++ b/modules/helpers/metrics-simulator/src/main/scripts/assembly.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+
+<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembl...
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-p...
http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+
+ <id>rhq-metrics-simulator</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>rhq-bundle-deployer-${project.version}</baseDirectory>
<!-- matches the zip when it is renamed in rhq-container.build.xml -->
+
+ <fileSets>
+
+ <fileSet>
+ <directory>src/main/assembly</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <excludes>
+ <exclude>bin/rhq-ms</exclude>
+ </excludes>
+ </fileSet>
+
+ <fileSet>
+ <directory>src/main/assembly</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>bin/rhq-ms</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+
+ <fileSet>
+ <directory>src/main/resources/conf</directory>
+ <outputDirectory>conf</outputDirectory>
+ </fileSet>
+
+ </fileSets>
+
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ </dependencySet>
+ </dependencySets>
+
+</assembly>
+