You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2006/07/06 00:30:26 UTC
svn commit: r419366 [2/7] - in /incubator/activemq/trunk:
activeio/activeio-core/src/main/java/org/apache/activeio/journal/active/
activemq-core/src/main/java/org/apache/activemq/broker/
activemq-core/src/main/java/org/apache/activemq/command/ activemq...
Modified: incubator/activemq/trunk/maven-gram-plugin/src/main/java/org/apache/activemq/maven/GramMojo.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/maven-gram-plugin/src/main/java/org/apache/activemq/maven/GramMojo.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/maven-gram-plugin/src/main/java/org/apache/activemq/maven/GramMojo.java (original)
+++ incubator/activemq/trunk/maven-gram-plugin/src/main/java/org/apache/activemq/maven/GramMojo.java Wed Jul 5 15:30:19 2006
@@ -1,145 +1,145 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.maven;
-
-import groovy.lang.GroovyShell;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.codehaus.groovy.control.CompilationFailedException;
-import org.codehaus.jam.JamService;
-import org.codehaus.jam.JamServiceFactory;
-import org.codehaus.jam.JamServiceParams;
-import org.codehaus.plexus.archiver.manager.ArchiverManager;
-
-/**
- * Greates a Mojo for Gram.
- *
- * This module is largly based on the Gram class here:
- * http://cvs.groovy.codehaus.org/browse/groovy/groovy/modules/gram/src/main/org/codehaus/gram/Gram.java?r=1.4
- *
- * We need to get this moved over the groovy project eventually.. Putting in ActiveMQ for now so we can keep going.
- *
- * @goal gram
- * @description Runs the Gram code generator
- */
-public class GramMojo extends AbstractMojo
-{
- /**
- * Source directories of the project.
- *
- * @parameter expression="${project.compileSourceRoots}"
- * @required
- * @readonly
- */
- private List sourceDirs;
-
-
- /**
- * @parameter
- * @required
- */
- String scripts = "";
-
- /**
- * @parameter
- */
- Map groovyProperties = Collections.EMPTY_MAP;
-
- /**
- * To look up Archiver/UnArchiver implementations
- *
- * @parameter expression="${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"
- * @required
- */
- protected ArchiverManager archiverManager;
-
- public void execute() throws MojoExecutionException
- {
-
- try {
-
- System.out.println("Parsing source files in: " + sourceDirs);
-
- JamServiceFactory jamServiceFactory = JamServiceFactory.getInstance();
- JamServiceParams params = jamServiceFactory.createServiceParams();
-
- File[] dirs = new File[sourceDirs.size()];
- {
- int i=0;
- for (Iterator iter = sourceDirs.iterator(); iter.hasNext();) {
- dirs[i++] = new File((String) iter.next());
- }
- }
-
- params.includeSourcePattern(dirs, "**/*.java");
- JamService jam = jamServiceFactory.createService(params);
-
- String[] scriptsArray = scripts.split(":");
- for (int i = 1; i < scriptsArray.length; i++) {
- String script = scriptsArray[i].trim();
- if(script.length() > 0 ) {
- getLog().info("Evaluating Groovy script: " + script);
- execute(jam, script);
- }
- }
- }
- catch (Exception e) {
- getLog().error("Caught: " + e, e);
- }
- }
-
- public void execute(JamService jam, String script) throws CompilationFailedException, IOException {
- File file = new File(script);
- if (file.isFile()) {
- GroovyShell shell = createShell(jam);
- shell.evaluate(file);
- }
- else {
- // lets try load the script on the classpath
- InputStream in = getClass().getClassLoader().getResourceAsStream(script);
- if (in == null) {
- in = Thread.currentThread().getContextClassLoader().getResourceAsStream(script);
- if (in == null) {
- throw new IOException("No script called: " + script + " could be found on the classpath or the file system");
- }
- }
- GroovyShell shell = createShell(jam);
- shell.evaluate(in, script);
- }
- }
-
- protected GroovyShell createShell(JamService jam) {
- GroovyShell answer = new GroovyShell();
- for (Iterator iter = groovyProperties.entrySet().iterator(); iter.hasNext();) {
- Map.Entry entry = (Map.Entry) iter.next();
- answer.setProperty((String) entry.getKey(), entry.getValue());
- }
- answer.setProperty("jam", jam);
- answer.setProperty("classes", jam.getAllClasses());
- return answer;
- }
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.maven;
+
+import groovy.lang.GroovyShell;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.groovy.control.CompilationFailedException;
+import org.codehaus.jam.JamService;
+import org.codehaus.jam.JamServiceFactory;
+import org.codehaus.jam.JamServiceParams;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+
+/**
+ * Greates a Mojo for Gram.
+ *
+ * This module is largly based on the Gram class here:
+ * http://cvs.groovy.codehaus.org/browse/groovy/groovy/modules/gram/src/main/org/codehaus/gram/Gram.java?r=1.4
+ *
+ * We need to get this moved over the groovy project eventually.. Putting in ActiveMQ for now so we can keep going.
+ *
+ * @goal gram
+ * @description Runs the Gram code generator
+ */
+public class GramMojo extends AbstractMojo
+{
+ /**
+ * Source directories of the project.
+ *
+ * @parameter expression="${project.compileSourceRoots}"
+ * @required
+ * @readonly
+ */
+ private List sourceDirs;
+
+
+ /**
+ * @parameter
+ * @required
+ */
+ String scripts = "";
+
+ /**
+ * @parameter
+ */
+ Map groovyProperties = Collections.EMPTY_MAP;
+
+ /**
+ * To look up Archiver/UnArchiver implementations
+ *
+ * @parameter expression="${component.org.codehaus.plexus.archiver.manager.ArchiverManager}"
+ * @required
+ */
+ protected ArchiverManager archiverManager;
+
+ public void execute() throws MojoExecutionException
+ {
+
+ try {
+
+ System.out.println("Parsing source files in: " + sourceDirs);
+
+ JamServiceFactory jamServiceFactory = JamServiceFactory.getInstance();
+ JamServiceParams params = jamServiceFactory.createServiceParams();
+
+ File[] dirs = new File[sourceDirs.size()];
+ {
+ int i=0;
+ for (Iterator iter = sourceDirs.iterator(); iter.hasNext();) {
+ dirs[i++] = new File((String) iter.next());
+ }
+ }
+
+ params.includeSourcePattern(dirs, "**/*.java");
+ JamService jam = jamServiceFactory.createService(params);
+
+ String[] scriptsArray = scripts.split(":");
+ for (int i = 1; i < scriptsArray.length; i++) {
+ String script = scriptsArray[i].trim();
+ if(script.length() > 0 ) {
+ getLog().info("Evaluating Groovy script: " + script);
+ execute(jam, script);
+ }
+ }
+ }
+ catch (Exception e) {
+ getLog().error("Caught: " + e, e);
+ }
+ }
+
+ public void execute(JamService jam, String script) throws CompilationFailedException, IOException {
+ File file = new File(script);
+ if (file.isFile()) {
+ GroovyShell shell = createShell(jam);
+ shell.evaluate(file);
+ }
+ else {
+ // lets try load the script on the classpath
+ InputStream in = getClass().getClassLoader().getResourceAsStream(script);
+ if (in == null) {
+ in = Thread.currentThread().getContextClassLoader().getResourceAsStream(script);
+ if (in == null) {
+ throw new IOException("No script called: " + script + " could be found on the classpath or the file system");
+ }
+ }
+ GroovyShell shell = createShell(jam);
+ shell.evaluate(in, script);
+ }
+ }
+
+ protected GroovyShell createShell(JamService jam) {
+ GroovyShell answer = new GroovyShell();
+ for (Iterator iter = groovyProperties.entrySet().iterator(); iter.hasNext();) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ answer.setProperty((String) entry.getKey(), entry.getValue());
+ }
+ answer.setProperty("jam", jam);
+ answer.setProperty("classes", jam.getAllClasses());
+ return answer;
+ }
+
+}
Propchange: incubator/activemq/trunk/maven-gram-plugin/src/main/java/org/apache/activemq/maven/GramMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/systest/weblogic-test/ExampleEJB/ejbModule/org/apache/activemq/example/CounterMDB.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/systest/weblogic-test/ExampleEJB/ejbModule/org/apache/activemq/example/CounterMDB.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/systest/weblogic-test/ExampleEJB/ejbModule/org/apache/activemq/example/CounterMDB.java (original)
+++ incubator/activemq/trunk/systest/weblogic-test/ExampleEJB/ejbModule/org/apache/activemq/example/CounterMDB.java Wed Jul 5 15:30:19 2006
@@ -1,79 +1,79 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.example;
-
-import javax.ejb.MessageDrivenBean;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-
-import weblogic.ejb.GenericMessageDrivenBean;
-import weblogic.ejbgen.ActivationConfigProperties;
-import weblogic.ejbgen.ActivationConfigProperty;
-import weblogic.ejbgen.MessageDriven;
-import weblogic.ejbgen.ResourceRef;
-
-/**
- * A simple MDB that demonstrates receiving and sending messages via ActiveMQ.
- *
- */
-@MessageDriven(ejbName = "CounterMDB", destinationType = "javax.jms.Queue", resourceAdapterJndiName = "activemq/ResourceAdapter", maxSuspendSeconds = 0)
-@ActivationConfigProperties(value = { @ActivationConfigProperty(name = "destination", value = "BAR") })
-@ResourceRef(jndiName = "activemq/ConnectionFactory", type = "javax.jms.ConnectionFactory", auth = ResourceRef.Auth.APPLICATION, name = "cf", id = "cf", sharingScope = ResourceRef.SharingScope.SHAREABLE)
-public class CounterMDB extends GenericMessageDrivenBean implements
- MessageDrivenBean, MessageListener {
-
- private static final long serialVersionUID = 1L;
-
- private static int counter = 0;
-
- public void onMessage(Message msg) {
- System.out.println("Got: " + msg);
- incrementCounter();
-
- // Try to forward the Message.
- try {
- InitialContext ic = new InitialContext();
- ConnectionFactory cf = (ConnectionFactory) ic.lookup("java:comp/env/cf");
- ic.close();
- Connection connection = cf.createConnection();
- try {
- Session session = connection.createSession(false, 0);
- MessageProducer producer = session.createProducer(session.createQueue("FOO"));
- producer.send(msg);
- } finally {
- connection.close();
- }
-
- } catch (Exception e) {
- System.out.println("Could not forward the message.");
- e.printStackTrace();
- }
- }
-
- public static synchronized void incrementCounter() {
- counter++;
- }
-
- public static synchronized int getCounter() {
- return counter;
- }
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.example;
+
+import javax.ejb.MessageDrivenBean;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+
+import weblogic.ejb.GenericMessageDrivenBean;
+import weblogic.ejbgen.ActivationConfigProperties;
+import weblogic.ejbgen.ActivationConfigProperty;
+import weblogic.ejbgen.MessageDriven;
+import weblogic.ejbgen.ResourceRef;
+
+/**
+ * A simple MDB that demonstrates receiving and sending messages via ActiveMQ.
+ *
+ */
+@MessageDriven(ejbName = "CounterMDB", destinationType = "javax.jms.Queue", resourceAdapterJndiName = "activemq/ResourceAdapter", maxSuspendSeconds = 0)
+@ActivationConfigProperties(value = { @ActivationConfigProperty(name = "destination", value = "BAR") })
+@ResourceRef(jndiName = "activemq/ConnectionFactory", type = "javax.jms.ConnectionFactory", auth = ResourceRef.Auth.APPLICATION, name = "cf", id = "cf", sharingScope = ResourceRef.SharingScope.SHAREABLE)
+public class CounterMDB extends GenericMessageDrivenBean implements
+ MessageDrivenBean, MessageListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static int counter = 0;
+
+ public void onMessage(Message msg) {
+ System.out.println("Got: " + msg);
+ incrementCounter();
+
+ // Try to forward the Message.
+ try {
+ InitialContext ic = new InitialContext();
+ ConnectionFactory cf = (ConnectionFactory) ic.lookup("java:comp/env/cf");
+ ic.close();
+ Connection connection = cf.createConnection();
+ try {
+ Session session = connection.createSession(false, 0);
+ MessageProducer producer = session.createProducer(session.createQueue("FOO"));
+ producer.send(msg);
+ } finally {
+ connection.close();
+ }
+
+ } catch (Exception e) {
+ System.out.println("Could not forward the message.");
+ e.printStackTrace();
+ }
+ }
+
+ public static synchronized void incrementCounter() {
+ counter++;
+ }
+
+ public static synchronized int getCounter() {
+ return counter;
+ }
}
Propchange: incubator/activemq/trunk/systest/weblogic-test/ExampleEJB/ejbModule/org/apache/activemq/example/CounterMDB.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/maven/MemtestMojo.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/maven/MemtestMojo.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/maven/MemtestMojo.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/maven/MemtestMojo.java Wed Jul 5 15:30:19 2006
@@ -1,145 +1,145 @@
-package org.apache.activemq.maven;
-
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.activemq.tool.JMSMemtest;
-
-import javax.jms.JMSException;
-
-
-/**
- * Goal which does a memory usage test to check for any memory leak
- *
- * @goal memtest
- * @phase process-sources
- */
-public class MemtestMojo
- extends AbstractMojo {
-
- /**
- * @parameter expression="${url}
- *
- */
- private String url;
-
- /**
- * @parameter expression="${topic}" default-value="true"
- * @required
- */
- private String topic;
-
- /**
- * @parameter expression="${connectionCheckpointSize}" default-value="-1"
- * @required
- */
- private String connectionCheckpointSize;
-
- /**
- * @parameter expression="${durable}" default-value="false"
- * @required
- */
- private String durable;
-
- /**
- * @parameter expression="${producerCount}" default-value="1"
- * @required
- */
- private String producerCount;
-
- /**
- * @parameter expression="${prefetchSize}" default-value="-1"
- * @required
- */
- private String prefetchSize;
-
-
- /**
- * @parameter expression="${consumerCount}" default-value="1"
- * @required
- */
- private String consumerCount;
-
- /**
- * @parameter expression="${messageCount}" default-value="100000"
- * @required
- */
- private String messageCount;
-
- /**
- * @parameter expression="${messageSize}" default-value="10240"
- * @required
- */
- private String messageSize;
-
- /**
- * @parameter expression="${checkpointInterval}" default-value="2"
- * @required
- */
- private String checkpointInterval;
-
- /**
- * @parameter expression="${destinationName}" default-value="FOO.BAR"
- * @required
- */
- private String destinationName;
-
- /**
- * @parameter expression="${reportName}" default-value="activemq-memory-usage-report"
- * @required
- */
- private String reportName;
-
- /**
- * @parameter expression="${reportDirectory}" default-value="${project.build.directory}/test-memtest"
- * @required
- */
- private String reportDirectory;
-
-
-
- public void execute()
- throws MojoExecutionException {
-
- JMSMemtest.main(createArgument());
- }
-
-
-
- public String[] createArgument() {
-
-
- String[] options = {
- "url=" + url,
- "topic=" + topic,
- "durable=" + durable,
- "connectionCheckpointSize=" + connectionCheckpointSize,
- "producerCount=" + producerCount,
- "consumerCount=" + consumerCount,
- "messageCount=" + messageCount,
- "messageSize=" + messageSize,
- "checkpointInterval=" + checkpointInterval,
- "destinationName=" + destinationName,
- "reportName=" + reportName,
- "prefetchSize=" + prefetchSize,
- "reportDirectory=" + reportDirectory,
- };
- return options;
- }
-}
+package org.apache.activemq.maven;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.activemq.tool.JMSMemtest;
+
+import javax.jms.JMSException;
+
+
+/**
+ * Goal which does a memory usage test to check for any memory leak
+ *
+ * @goal memtest
+ * @phase process-sources
+ */
+public class MemtestMojo
+ extends AbstractMojo {
+
+ /**
+ * @parameter expression="${url}
+ *
+ */
+ private String url;
+
+ /**
+ * @parameter expression="${topic}" default-value="true"
+ * @required
+ */
+ private String topic;
+
+ /**
+ * @parameter expression="${connectionCheckpointSize}" default-value="-1"
+ * @required
+ */
+ private String connectionCheckpointSize;
+
+ /**
+ * @parameter expression="${durable}" default-value="false"
+ * @required
+ */
+ private String durable;
+
+ /**
+ * @parameter expression="${producerCount}" default-value="1"
+ * @required
+ */
+ private String producerCount;
+
+ /**
+ * @parameter expression="${prefetchSize}" default-value="-1"
+ * @required
+ */
+ private String prefetchSize;
+
+
+ /**
+ * @parameter expression="${consumerCount}" default-value="1"
+ * @required
+ */
+ private String consumerCount;
+
+ /**
+ * @parameter expression="${messageCount}" default-value="100000"
+ * @required
+ */
+ private String messageCount;
+
+ /**
+ * @parameter expression="${messageSize}" default-value="10240"
+ * @required
+ */
+ private String messageSize;
+
+ /**
+ * @parameter expression="${checkpointInterval}" default-value="2"
+ * @required
+ */
+ private String checkpointInterval;
+
+ /**
+ * @parameter expression="${destinationName}" default-value="FOO.BAR"
+ * @required
+ */
+ private String destinationName;
+
+ /**
+ * @parameter expression="${reportName}" default-value="activemq-memory-usage-report"
+ * @required
+ */
+ private String reportName;
+
+ /**
+ * @parameter expression="${reportDirectory}" default-value="${project.build.directory}/test-memtest"
+ * @required
+ */
+ private String reportDirectory;
+
+
+
+ public void execute()
+ throws MojoExecutionException {
+
+ JMSMemtest.main(createArgument());
+ }
+
+
+
+ public String[] createArgument() {
+
+
+ String[] options = {
+ "url=" + url,
+ "topic=" + topic,
+ "durable=" + durable,
+ "connectionCheckpointSize=" + connectionCheckpointSize,
+ "producerCount=" + producerCount,
+ "consumerCount=" + consumerCount,
+ "messageCount=" + messageCount,
+ "messageSize=" + messageSize,
+ "checkpointInterval=" + checkpointInterval,
+ "destinationName=" + destinationName,
+ "reportName=" + reportName,
+ "prefetchSize=" + prefetchSize,
+ "reportDirectory=" + reportDirectory,
+ };
+ return options;
+ }
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/maven/MemtestMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/JMSMemtest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/JMSMemtest.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/JMSMemtest.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/JMSMemtest.java Wed Jul 5 15:30:19 2006
@@ -1,307 +1,307 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.activemq.tool;
-
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.broker.BrokerService;
-import org.apache.activemq.tool.MemProducer;
-import org.apache.activemq.tool.MemConsumer;
-import org.apache.activemq.tool.MemoryMonitoringTool;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.jms.*;
-
-
-import java.util.Properties;
-
-
-public class JMSMemtest {
-
- private static final Log log = LogFactory.getLog(JMSMemtest.class);
- private static final int DEFAULT_MESSAGECOUNT = 5000;
- protected BrokerService broker;
- protected boolean topic = true;
- protected boolean durable = false;
-
- protected long messageCount = 0;
-
- // how large the message in kb before we close/start the producer/consumer with a new connection. -1 means no connectionCheckpointSize
- protected int connectionCheckpointSize;
- protected long connectionInterval;
-
-
- protected int consumerCount;
- protected int producerCount;
- protected int checkpointInterval;
- protected int prefetchSize;
- //set 10 kb of payload as default
- protected int messageSize;
-
- protected String reportDirectory;
- protected String reportName;
-
-
- protected String url = "";
- protected MemProducer[] producers;
- protected MemConsumer[] consumers;
- protected String destinationName;
- protected boolean allMessagesConsumed = true;
- protected MemConsumer allMessagesList = new MemConsumer();
-
- protected Message payload;
-
- protected ActiveMQConnectionFactory connectionFactory;
- protected Connection connection;
- protected Destination destination;
-
-
- protected boolean createConnectionPerClient = true;
-
- protected boolean transacted = false;
- protected boolean useEmbeddedBroker = true;
- protected MemoryMonitoringTool memoryMonitoringTool;
-
-
- public static void main(String[] args) {
-
-
- Properties sysSettings = new Properties();
-
- for (int i = 0; i < args.length; i++) {
-
- int index = args[i].indexOf("=");
- String key = args[i].substring(0, index);
- String val = args[i].substring(index + 1);
- sysSettings.setProperty(key, val);
-
- }
-
-
- JMSMemtest memtest = new JMSMemtest(sysSettings);
- try {
- memtest.start();
- } catch (Exception e) {
-
- e.printStackTrace();
- }
-
- }
-
-
- public JMSMemtest(Properties settings) {
- url = settings.getProperty("url");
- topic = new Boolean(settings.getProperty("topic")).booleanValue();
- durable = new Boolean(settings.getProperty("durable")).booleanValue();
- connectionCheckpointSize = new Integer(settings.getProperty("connectionCheckpointSize")).intValue();
- producerCount = new Integer(settings.getProperty("producerCount")).intValue();
- consumerCount = new Integer(settings.getProperty("consumerCount")).intValue();
- messageCount = new Integer(settings.getProperty("messageCount")).intValue();
- messageSize = new Integer(settings.getProperty("messageSize")).intValue();
- prefetchSize = new Integer(settings.getProperty("prefetchSize")).intValue();
- checkpointInterval = new Integer(settings.getProperty("checkpointInterval")).intValue() * 1000;
- producerCount = new Integer(settings.getProperty("producerCount")).intValue();
- reportName = settings.getProperty("reportName");
- destinationName = settings.getProperty("destinationName");
- reportDirectory = settings.getProperty("reportDirectory");
- connectionInterval = connectionCheckpointSize * 1024;
- }
-
- protected void start() throws Exception {
- log.info("Starting Monitor");
- memoryMonitoringTool = new MemoryMonitoringTool();
- memoryMonitoringTool.setTestSettings(getSysTestSettings());
- Thread monitorThread = memoryMonitoringTool.startMonitor();
-
- if (messageCount == 0) {
- messageCount = DEFAULT_MESSAGECOUNT;
- }
-
-
- if (useEmbeddedBroker) {
- if (broker == null) {
- broker = createBroker();
- }
- }
-
-
- connectionFactory = (ActiveMQConnectionFactory) createConnectionFactory();
- if (prefetchSize > 0) {
- connectionFactory.getPrefetchPolicy().setTopicPrefetch(prefetchSize);
- connectionFactory.getPrefetchPolicy().setQueuePrefetch(prefetchSize);
- }
-
- connection = connectionFactory.createConnection();
- Session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
-
- if (topic) {
- destination = session.createTopic(destinationName);
- } else {
- destination = session.createQueue(destinationName);
- }
-
- createPayload(session);
-
- publishAndConsume();
-
- log.info("Closing resources");
- this.close();
-
- monitorThread.join();
-
-
- }
-
-
- protected boolean resetConnection(int counter) {
- if (connectionInterval > 0) {
- long totalMsgSizeConsumed = counter * 1024;
- if (connectionInterval < totalMsgSizeConsumed) {
- return true;
- }
- }
- return false;
- }
-
- protected void publishAndConsume() throws Exception {
-
- createConsumers();
- createProducers();
- int counter = 0;
- boolean resetCon = false;
- log.info("Start sending messages ");
- for (int i = 0; i < messageCount; i++) {
- if (resetCon == true) {
- closeConsumers();
- closeProducers();
- createConsumers();
- createProducers();
- resetCon = false;
- }
-
- for (int k = 0; k < producers.length; k++) {
- producers[k].sendMessage(payload, "counter", counter);
- counter++;
- if (resetConnection(counter)) {
- resetCon = true;
- break;
- }
- }
- }
- }
-
-
- protected void close() throws Exception {
- connection.close();
- broker.stop();
-
- memoryMonitoringTool.stopMonitor();
- }
-
- protected void createPayload(Session session) throws JMSException {
-
- byte[] array = new byte[messageSize];
- for (int i = 0; i < array.length; i++) {
- array[i] = (byte) i;
- }
-
- BytesMessage bystePayload = session.createBytesMessage();
- bystePayload.writeBytes(array);
- payload = (Message) bystePayload;
- }
-
-
- protected void createProducers() throws JMSException {
- producers = new MemProducer[producerCount];
- for (int i = 0; i < producerCount; i++) {
- producers[i] = new MemProducer(connectionFactory, destination);
- if (durable) {
- producers[i].setDeliveryMode(DeliveryMode.PERSISTENT);
- } else {
- producers[i].setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- }
- producers[i].start();
- }
-
- }
-
- protected void createConsumers() throws JMSException {
- consumers = new MemConsumer[consumerCount];
- for (int i = 0; i < consumerCount; i++) {
- consumers[i] = new MemConsumer(connectionFactory, destination);
- consumers[i].setParent(allMessagesList);
- consumers[i].start();
-
-
- }
- }
-
- protected void closeProducers() throws JMSException {
- for (int i = 0; i < producerCount; i++) {
- producers[i].shutDown();
- }
-
- }
-
- protected void closeConsumers() throws JMSException {
- for (int i = 0; i < consumerCount; i++) {
- consumers[i].shutDown();
- }
- }
-
- protected ConnectionFactory createConnectionFactory() throws JMSException {
-
- if (url == null || url.trim().equals("") || url.trim().equals("null")) {
- return new ActiveMQConnectionFactory("vm://localhost");
- } else {
- return new ActiveMQConnectionFactory(url);
- }
- }
-
- protected BrokerService createBroker() throws Exception {
- BrokerService broker = new BrokerService();
- configureBroker(broker);
- broker.start();
- return broker;
- }
-
- protected void configureBroker(BrokerService broker) throws Exception {
- broker.addConnector("vm://localhost");
- broker.setDeleteAllMessagesOnStartup(true);
- }
-
- protected Properties getSysTestSettings() {
- Properties settings = new Properties();
- settings.setProperty("domain", topic == true ? "topic" : "queue");
- settings.setProperty("durable", durable == true ? "durable" : "non-durable");
- settings.setProperty("connection_checkpoint_size_kb", new Integer(connectionCheckpointSize).toString());
- settings.setProperty("producer_count", new Integer(producerCount).toString());
- settings.setProperty("consumer_count", new Integer(consumerCount).toString());
- settings.setProperty("message_count", new Long(messageCount).toString());
- settings.setProperty("message_size", new Integer(messageSize).toString());
- settings.setProperty("prefetchSize", new Integer(prefetchSize).toString());
- settings.setProperty("checkpoint_interval", new Integer(checkpointInterval).toString());
- settings.setProperty("destination_name", destinationName);
- settings.setProperty("report_name", reportName);
- settings.setProperty("report_directory", reportDirectory);
- settings.setProperty("connection_checkpoint_size", new Integer(connectionCheckpointSize).toString());
- return settings;
- }
-
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.tool;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.tool.MemProducer;
+import org.apache.activemq.tool.MemConsumer;
+import org.apache.activemq.tool.MemoryMonitoringTool;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.jms.*;
+
+
+import java.util.Properties;
+
+
+public class JMSMemtest {
+
+ private static final Log log = LogFactory.getLog(JMSMemtest.class);
+ private static final int DEFAULT_MESSAGECOUNT = 5000;
+ protected BrokerService broker;
+ protected boolean topic = true;
+ protected boolean durable = false;
+
+ protected long messageCount = 0;
+
+ // how large the message in kb before we close/start the producer/consumer with a new connection. -1 means no connectionCheckpointSize
+ protected int connectionCheckpointSize;
+ protected long connectionInterval;
+
+
+ protected int consumerCount;
+ protected int producerCount;
+ protected int checkpointInterval;
+ protected int prefetchSize;
+ //set 10 kb of payload as default
+ protected int messageSize;
+
+ protected String reportDirectory;
+ protected String reportName;
+
+
+ protected String url = "";
+ protected MemProducer[] producers;
+ protected MemConsumer[] consumers;
+ protected String destinationName;
+ protected boolean allMessagesConsumed = true;
+ protected MemConsumer allMessagesList = new MemConsumer();
+
+ protected Message payload;
+
+ protected ActiveMQConnectionFactory connectionFactory;
+ protected Connection connection;
+ protected Destination destination;
+
+
+ protected boolean createConnectionPerClient = true;
+
+ protected boolean transacted = false;
+ protected boolean useEmbeddedBroker = true;
+ protected MemoryMonitoringTool memoryMonitoringTool;
+
+
+ public static void main(String[] args) {
+
+
+ Properties sysSettings = new Properties();
+
+ for (int i = 0; i < args.length; i++) {
+
+ int index = args[i].indexOf("=");
+ String key = args[i].substring(0, index);
+ String val = args[i].substring(index + 1);
+ sysSettings.setProperty(key, val);
+
+ }
+
+
+ JMSMemtest memtest = new JMSMemtest(sysSettings);
+ try {
+ memtest.start();
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+
+ }
+
+
+ public JMSMemtest(Properties settings) {
+ url = settings.getProperty("url");
+ topic = new Boolean(settings.getProperty("topic")).booleanValue();
+ durable = new Boolean(settings.getProperty("durable")).booleanValue();
+ connectionCheckpointSize = new Integer(settings.getProperty("connectionCheckpointSize")).intValue();
+ producerCount = new Integer(settings.getProperty("producerCount")).intValue();
+ consumerCount = new Integer(settings.getProperty("consumerCount")).intValue();
+ messageCount = new Integer(settings.getProperty("messageCount")).intValue();
+ messageSize = new Integer(settings.getProperty("messageSize")).intValue();
+ prefetchSize = new Integer(settings.getProperty("prefetchSize")).intValue();
+ checkpointInterval = new Integer(settings.getProperty("checkpointInterval")).intValue() * 1000;
+ producerCount = new Integer(settings.getProperty("producerCount")).intValue();
+ reportName = settings.getProperty("reportName");
+ destinationName = settings.getProperty("destinationName");
+ reportDirectory = settings.getProperty("reportDirectory");
+ connectionInterval = connectionCheckpointSize * 1024;
+ }
+
+ protected void start() throws Exception {
+ log.info("Starting Monitor");
+ memoryMonitoringTool = new MemoryMonitoringTool();
+ memoryMonitoringTool.setTestSettings(getSysTestSettings());
+ Thread monitorThread = memoryMonitoringTool.startMonitor();
+
+ if (messageCount == 0) {
+ messageCount = DEFAULT_MESSAGECOUNT;
+ }
+
+
+ if (useEmbeddedBroker) {
+ if (broker == null) {
+ broker = createBroker();
+ }
+ }
+
+
+ connectionFactory = (ActiveMQConnectionFactory) createConnectionFactory();
+ if (prefetchSize > 0) {
+ connectionFactory.getPrefetchPolicy().setTopicPrefetch(prefetchSize);
+ connectionFactory.getPrefetchPolicy().setQueuePrefetch(prefetchSize);
+ }
+
+ connection = connectionFactory.createConnection();
+ Session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
+
+ if (topic) {
+ destination = session.createTopic(destinationName);
+ } else {
+ destination = session.createQueue(destinationName);
+ }
+
+ createPayload(session);
+
+ publishAndConsume();
+
+ log.info("Closing resources");
+ this.close();
+
+ monitorThread.join();
+
+
+ }
+
+
+ protected boolean resetConnection(int counter) {
+ if (connectionInterval > 0) {
+ long totalMsgSizeConsumed = counter * 1024;
+ if (connectionInterval < totalMsgSizeConsumed) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected void publishAndConsume() throws Exception {
+
+ createConsumers();
+ createProducers();
+ int counter = 0;
+ boolean resetCon = false;
+ log.info("Start sending messages ");
+ for (int i = 0; i < messageCount; i++) {
+ if (resetCon == true) {
+ closeConsumers();
+ closeProducers();
+ createConsumers();
+ createProducers();
+ resetCon = false;
+ }
+
+ for (int k = 0; k < producers.length; k++) {
+ producers[k].sendMessage(payload, "counter", counter);
+ counter++;
+ if (resetConnection(counter)) {
+ resetCon = true;
+ break;
+ }
+ }
+ }
+ }
+
+
+ protected void close() throws Exception {
+ connection.close();
+ broker.stop();
+
+ memoryMonitoringTool.stopMonitor();
+ }
+
+ protected void createPayload(Session session) throws JMSException {
+
+ byte[] array = new byte[messageSize];
+ for (int i = 0; i < array.length; i++) {
+ array[i] = (byte) i;
+ }
+
+ BytesMessage bystePayload = session.createBytesMessage();
+ bystePayload.writeBytes(array);
+ payload = (Message) bystePayload;
+ }
+
+
+ protected void createProducers() throws JMSException {
+ producers = new MemProducer[producerCount];
+ for (int i = 0; i < producerCount; i++) {
+ producers[i] = new MemProducer(connectionFactory, destination);
+ if (durable) {
+ producers[i].setDeliveryMode(DeliveryMode.PERSISTENT);
+ } else {
+ producers[i].setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ }
+ producers[i].start();
+ }
+
+ }
+
+ protected void createConsumers() throws JMSException {
+ consumers = new MemConsumer[consumerCount];
+ for (int i = 0; i < consumerCount; i++) {
+ consumers[i] = new MemConsumer(connectionFactory, destination);
+ consumers[i].setParent(allMessagesList);
+ consumers[i].start();
+
+
+ }
+ }
+
+ protected void closeProducers() throws JMSException {
+ for (int i = 0; i < producerCount; i++) {
+ producers[i].shutDown();
+ }
+
+ }
+
+ protected void closeConsumers() throws JMSException {
+ for (int i = 0; i < consumerCount; i++) {
+ consumers[i].shutDown();
+ }
+ }
+
+ protected ConnectionFactory createConnectionFactory() throws JMSException {
+
+ if (url == null || url.trim().equals("") || url.trim().equals("null")) {
+ return new ActiveMQConnectionFactory("vm://localhost");
+ } else {
+ return new ActiveMQConnectionFactory(url);
+ }
+ }
+
+ protected BrokerService createBroker() throws Exception {
+ BrokerService broker = new BrokerService();
+ configureBroker(broker);
+ broker.start();
+ return broker;
+ }
+
+ protected void configureBroker(BrokerService broker) throws Exception {
+ broker.addConnector("vm://localhost");
+ broker.setDeleteAllMessagesOnStartup(true);
+ }
+
+ protected Properties getSysTestSettings() {
+ Properties settings = new Properties();
+ settings.setProperty("domain", topic == true ? "topic" : "queue");
+ settings.setProperty("durable", durable == true ? "durable" : "non-durable");
+ settings.setProperty("connection_checkpoint_size_kb", new Integer(connectionCheckpointSize).toString());
+ settings.setProperty("producer_count", new Integer(producerCount).toString());
+ settings.setProperty("consumer_count", new Integer(consumerCount).toString());
+ settings.setProperty("message_count", new Long(messageCount).toString());
+ settings.setProperty("message_size", new Integer(messageSize).toString());
+ settings.setProperty("prefetchSize", new Integer(prefetchSize).toString());
+ settings.setProperty("checkpoint_interval", new Integer(checkpointInterval).toString());
+ settings.setProperty("destination_name", destinationName);
+ settings.setProperty("report_name", reportName);
+ settings.setProperty("report_directory", reportDirectory);
+ settings.setProperty("connection_checkpoint_size", new Integer(connectionCheckpointSize).toString());
+ return settings;
+ }
+
+
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/JMSMemtest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemConsumer.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemConsumer.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemConsumer.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemConsumer.java Wed Jul 5 15:30:19 2006
@@ -1,108 +1,108 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tool;
-
-import org.apache.activemq.tool.MemMessageIdList;
-
-import javax.jms.*;
-
-/**
- * @version $Revision: 1.3 $
- */
-public class MemConsumer extends MemMessageIdList implements MessageListener {
- protected Connection connection;
- protected MessageConsumer consumer;
- protected long counter = 0;
- protected boolean isParent = false;
- protected boolean inOrder = true;
-
-
- public MemConsumer() {
- super();
- }
-
- public MemConsumer(ConnectionFactory fac, Destination dest, String consumerName) throws JMSException {
- connection = fac.createConnection();
- Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- if (dest instanceof Topic && consumerName != null && consumerName.length() > 0) {
- consumer = s.createDurableSubscriber((Topic) dest, consumerName);
- } else {
- consumer = s.createConsumer(dest);
- }
- consumer.setMessageListener(this);
- }
-
- public MemConsumer(ConnectionFactory fac, Destination dest) throws JMSException {
- this(fac, dest, null);
- }
-
- public void start() throws JMSException {
- connection.start();
- }
-
- public void stop() throws JMSException {
- connection.stop();
- }
-
- public void shutDown() throws JMSException {
- connection.close();
- }
-
-
- public Message receive() throws JMSException {
- return consumer.receive();
- }
-
- public Message receive(long wait) throws JMSException {
- return consumer.receive(wait);
- }
-
- static long ctr = 0;
-
- public void onMessage(Message msg) {
- super.onMessage(msg);
-
- if (isParent) {
- try {
- long ctr = msg.getLongProperty("counter");
- if (counter != ctr) {
- inOrder = false;
- }
- counter++;
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
-
- public boolean isInOrder() {
- return inOrder;
- }
-
-
- public void setAsParent(boolean isParent) {
- this.isParent = isParent;
- }
-
- public boolean isParent() {
- return this.isParent;
- }
-
-
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tool;
+
+import org.apache.activemq.tool.MemMessageIdList;
+
+import javax.jms.*;
+
+/**
+ * @version $Revision: 1.3 $
+ */
+public class MemConsumer extends MemMessageIdList implements MessageListener {
+ protected Connection connection;
+ protected MessageConsumer consumer;
+ protected long counter = 0;
+ protected boolean isParent = false;
+ protected boolean inOrder = true;
+
+
+ public MemConsumer() {
+ super();
+ }
+
+ public MemConsumer(ConnectionFactory fac, Destination dest, String consumerName) throws JMSException {
+ connection = fac.createConnection();
+ Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ if (dest instanceof Topic && consumerName != null && consumerName.length() > 0) {
+ consumer = s.createDurableSubscriber((Topic) dest, consumerName);
+ } else {
+ consumer = s.createConsumer(dest);
+ }
+ consumer.setMessageListener(this);
+ }
+
+ public MemConsumer(ConnectionFactory fac, Destination dest) throws JMSException {
+ this(fac, dest, null);
+ }
+
+ public void start() throws JMSException {
+ connection.start();
+ }
+
+ public void stop() throws JMSException {
+ connection.stop();
+ }
+
+ public void shutDown() throws JMSException {
+ connection.close();
+ }
+
+
+ public Message receive() throws JMSException {
+ return consumer.receive();
+ }
+
+ public Message receive(long wait) throws JMSException {
+ return consumer.receive(wait);
+ }
+
+ static long ctr = 0;
+
+ public void onMessage(Message msg) {
+ super.onMessage(msg);
+
+ if (isParent) {
+ try {
+ long ctr = msg.getLongProperty("counter");
+ if (counter != ctr) {
+ inOrder = false;
+ }
+ counter++;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+ public boolean isInOrder() {
+ return inOrder;
+ }
+
+
+ public void setAsParent(boolean isParent) {
+ this.isParent = isParent;
+ }
+
+ public boolean isParent() {
+ return this.isParent;
+ }
+
+
}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemMessageIdList.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemMessageIdList.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemMessageIdList.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemMessageIdList.java Wed Jul 5 15:30:19 2006
@@ -1,177 +1,177 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tool;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * A simple container of messages for performing testing and rendezvous style
- * code. You can use this class a {@link MessageListener} and then make
- * assertions about how many messages it has received allowing a certain maximum
- * amount of time to ensure that the test does not hang forever.
- * <p/>
- * Also you can chain these instances together with the
- * {@link #setParent(MessageListener)} method so that you can aggregate the
- * total number of messages consumed across a number of consumers.
- *
- * @version $Revision: 1.6 $
- */
-public class MemMessageIdList implements MessageListener {
-
- protected static final Log log = LogFactory.getLog(MemMessageIdList.class);
-
- private List messageIds = new ArrayList();
- private Object semaphore;
- private boolean verbose;
- private MessageListener parent;
- private long maximumDuration = 15000L;
-
- public MemMessageIdList() {
- this(new Object());
- }
-
- public MemMessageIdList(Object semaphore) {
- this.semaphore = semaphore;
- }
-
- public boolean equals(Object that) {
- if (that instanceof MemMessageIdList) {
- MemMessageIdList thatListMem = (MemMessageIdList) that;
- return getMessageIds().equals(thatListMem.getMessageIds());
- }
- return false;
- }
-
- public int hashCode() {
- synchronized (semaphore) {
- return messageIds.hashCode() + 1;
- }
- }
-
- public String toString() {
- synchronized (semaphore) {
- return messageIds.toString();
- }
- }
-
- /**
- * @return all the messages on the list so far, clearing the buffer
- */
- public List flushMessages() {
- synchronized (semaphore) {
- List answer = new ArrayList(messageIds);
- messageIds.clear();
- return answer;
- }
- }
-
- public synchronized List getMessageIds() {
- synchronized (semaphore) {
- return new ArrayList(messageIds);
- }
- }
-
- public void onMessage(Message message) {
- String id = null;
- try {
- id = message.getJMSMessageID();
- synchronized (semaphore) {
- messageIds.add(id);
- semaphore.notifyAll();
- }
- if (verbose) {
- log.info("Received message: " + message);
- }
- } catch (JMSException e) {
- e.printStackTrace();
- }
- if (parent != null) {
- parent.onMessage(message);
- }
- }
-
- public int getMessageCount() {
- synchronized (semaphore) {
- return messageIds.size();
- }
- }
-
- public void waitForMessagesToArrive(int messageCount) {
- log.info("Waiting for " + messageCount + " message(s) to arrive");
-
- long start = System.currentTimeMillis();
-
- for (int i = 0; i < messageCount; i++) {
- try {
- if (hasReceivedMessages(messageCount)) {
- break;
- }
- long duration = System.currentTimeMillis() - start;
- if (duration >= maximumDuration) {
- break;
- }
- synchronized (semaphore) {
- semaphore.wait(maximumDuration - duration);
- }
- } catch (InterruptedException e) {
- log.info("Caught: " + e);
- }
- }
- long end = System.currentTimeMillis() - start;
-
- log.info("End of wait for " + end + " millis and received: " + getMessageCount() + " messages");
- }
-
-
- public boolean hasReceivedMessage() {
- return getMessageCount() == 0;
- }
-
- public boolean hasReceivedMessages(int messageCount) {
- return getMessageCount() >= messageCount;
- }
-
- public boolean isVerbose() {
- return verbose;
- }
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- public MessageListener getParent() {
- return parent;
- }
-
- /**
- * Allows a parent listener to be specified such as to aggregate messages
- * consumed across consumers
- */
- public void setParent(MessageListener parent) {
- this.parent = parent;
- }
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tool;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A simple container of messages for performing testing and rendezvous style
+ * code. You can use this class a {@link MessageListener} and then make
+ * assertions about how many messages it has received allowing a certain maximum
+ * amount of time to ensure that the test does not hang forever.
+ * <p/>
+ * Also you can chain these instances together with the
+ * {@link #setParent(MessageListener)} method so that you can aggregate the
+ * total number of messages consumed across a number of consumers.
+ *
+ * @version $Revision: 1.6 $
+ */
+public class MemMessageIdList implements MessageListener {
+
+ protected static final Log log = LogFactory.getLog(MemMessageIdList.class);
+
+ private List messageIds = new ArrayList();
+ private Object semaphore;
+ private boolean verbose;
+ private MessageListener parent;
+ private long maximumDuration = 15000L;
+
+ public MemMessageIdList() {
+ this(new Object());
+ }
+
+ public MemMessageIdList(Object semaphore) {
+ this.semaphore = semaphore;
+ }
+
+ public boolean equals(Object that) {
+ if (that instanceof MemMessageIdList) {
+ MemMessageIdList thatListMem = (MemMessageIdList) that;
+ return getMessageIds().equals(thatListMem.getMessageIds());
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ synchronized (semaphore) {
+ return messageIds.hashCode() + 1;
+ }
+ }
+
+ public String toString() {
+ synchronized (semaphore) {
+ return messageIds.toString();
+ }
+ }
+
+ /**
+ * @return all the messages on the list so far, clearing the buffer
+ */
+ public List flushMessages() {
+ synchronized (semaphore) {
+ List answer = new ArrayList(messageIds);
+ messageIds.clear();
+ return answer;
+ }
+ }
+
+ public synchronized List getMessageIds() {
+ synchronized (semaphore) {
+ return new ArrayList(messageIds);
+ }
+ }
+
+ public void onMessage(Message message) {
+ String id = null;
+ try {
+ id = message.getJMSMessageID();
+ synchronized (semaphore) {
+ messageIds.add(id);
+ semaphore.notifyAll();
+ }
+ if (verbose) {
+ log.info("Received message: " + message);
+ }
+ } catch (JMSException e) {
+ e.printStackTrace();
+ }
+ if (parent != null) {
+ parent.onMessage(message);
+ }
+ }
+
+ public int getMessageCount() {
+ synchronized (semaphore) {
+ return messageIds.size();
+ }
+ }
+
+ public void waitForMessagesToArrive(int messageCount) {
+ log.info("Waiting for " + messageCount + " message(s) to arrive");
+
+ long start = System.currentTimeMillis();
+
+ for (int i = 0; i < messageCount; i++) {
+ try {
+ if (hasReceivedMessages(messageCount)) {
+ break;
+ }
+ long duration = System.currentTimeMillis() - start;
+ if (duration >= maximumDuration) {
+ break;
+ }
+ synchronized (semaphore) {
+ semaphore.wait(maximumDuration - duration);
+ }
+ } catch (InterruptedException e) {
+ log.info("Caught: " + e);
+ }
+ }
+ long end = System.currentTimeMillis() - start;
+
+ log.info("End of wait for " + end + " millis and received: " + getMessageCount() + " messages");
+ }
+
+
+ public boolean hasReceivedMessage() {
+ return getMessageCount() == 0;
+ }
+
+ public boolean hasReceivedMessages(int messageCount) {
+ return getMessageCount() >= messageCount;
+ }
+
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ public MessageListener getParent() {
+ return parent;
+ }
+
+ /**
+ * Allows a parent listener to be specified such as to aggregate messages
+ * consumed across consumers
+ */
+ public void setParent(MessageListener parent) {
+ this.parent = parent;
+ }
+
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemMessageIdList.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemProducer.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemProducer.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemProducer.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemProducer.java Wed Jul 5 15:30:19 2006
@@ -1,74 +1,74 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tool;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- * @version $Revision: 1.3 $
- */
-public class MemProducer {
- protected Connection connection;
- protected MessageProducer producer;
-
- public MemProducer(ConnectionFactory fac, Destination dest) throws JMSException {
- connection = fac.createConnection();
- Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- producer = s.createProducer(dest);
- }
-
- public void setDeliveryMode(int mode) throws JMSException {
- producer.setDeliveryMode(mode);
- }
-
- public void start() throws JMSException {
- connection.start();
- }
-
- public void stop() throws JMSException {
- connection.stop();
- }
-
- public void shutDown() throws JMSException {
- connection.close();
- }
-
- public void sendMessage(Message msg) throws JMSException {
- sendMessage(msg, null, 0);
- }
-
- /*
- * allow producer to attach message counter on its header. This will be used to verify message order
- *
- */
- public void sendMessage(Message msg, String headerName, long headerValue) throws JMSException {
- if (headerName != null) {
- msg.setLongProperty(headerName, headerValue);
- }
-
- producer.send(msg);
-
- }
-
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tool;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+/**
+ * @version $Revision: 1.3 $
+ */
+public class MemProducer {
+ protected Connection connection;
+ protected MessageProducer producer;
+
+ public MemProducer(ConnectionFactory fac, Destination dest) throws JMSException {
+ connection = fac.createConnection();
+ Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ producer = s.createProducer(dest);
+ }
+
+ public void setDeliveryMode(int mode) throws JMSException {
+ producer.setDeliveryMode(mode);
+ }
+
+ public void start() throws JMSException {
+ connection.start();
+ }
+
+ public void stop() throws JMSException {
+ connection.stop();
+ }
+
+ public void shutDown() throws JMSException {
+ connection.close();
+ }
+
+ public void sendMessage(Message msg) throws JMSException {
+ sendMessage(msg, null, 0);
+ }
+
+ /*
+ * allow producer to attach message counter on its header. This will be used to verify message order
+ *
+ */
+ public void sendMessage(Message msg, String headerName, long headerValue) throws JMSException {
+ if (headerName != null) {
+ msg.setLongProperty(headerName, headerValue);
+ }
+
+ producer.send(msg);
+
+ }
+
}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemoryMonitoringTool.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemoryMonitoringTool.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemoryMonitoringTool.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemoryMonitoringTool.java Wed Jul 5 15:30:19 2006
@@ -1,148 +1,148 @@
-/**
- *
- * Copyright 2005-2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tool;
-
-import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
-
-
-import java.io.DataOutputStream;
-import java.util.Properties;
-import java.lang.management.MemoryMXBean;
-import java.lang.management.ManagementFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-public class MemoryMonitoringTool implements Runnable {
-
- private long checkpointInterval = 5000; // 5 sec sample checkpointInterval
- private long resultIndex = 0;
-
- private AtomicBoolean isRunning = new AtomicBoolean(false);
- private DataOutputStream dataDoutputStream = null;
-
- protected Properties testSettings = new Properties();
- protected ReportGenerator reportGenerator = new ReportGenerator();
- private MemoryMXBean memoryBean;
-
- public Properties getTestSettings() {
- return testSettings;
- }
-
- public void setTestSettings(Properties sysTestSettings) {
- this.testSettings = sysTestSettings;
- }
-
- public DataOutputStream getDataOutputStream() {
- return dataDoutputStream;
- }
-
- public void setDataOutputStream(DataOutputStream dataDoutputStream) {
- this.dataDoutputStream = dataDoutputStream;
- }
-
-
- public void stopMonitor() {
- isRunning.set(false);
- }
-
-
- public long getCheckpointInterval() {
- return checkpointInterval;
- }
-
- public void setCheckpointInterval(long checkpointInterval) {
- this.checkpointInterval = checkpointInterval;
- }
-
-
- public Thread startMonitor() {
-
- String intervalStr = this.getTestSettings().getProperty("checkpoint_interval");
- checkpointInterval = new Integer(intervalStr).intValue();
- this.getTestSettings().remove("checkpoint_interval");
-
- memoryBean = ManagementFactory.getMemoryMXBean();
- reportGenerator.setTestSettings(getTestSettings());
- addTestInformation();
-
- Thread t = new Thread(this);
- t.setName("Memory monitoring tool");
- isRunning.set(true);
- t.start();
-
- return t;
-
- }
-
-
- public void addTestInformation() {
- reportGenerator.setReportName(this.getTestSettings().getProperty("report_name"));
- reportGenerator.setReportDirectory(this.getTestSettings().getProperty("report_directory"));
- reportGenerator.startGenerateReport();
-
- reportGenerator.addTestInformation();
- reportGenerator.writeWithIndent(4, "<jvm_memory_settings>");
- reportGenerator.writeWithIndent(6, "<heap_memory>");
- reportGenerator.writeWithIndent(8, "<committed>" + memoryBean.getHeapMemoryUsage().getCommitted() + "</committed>");
- reportGenerator.writeWithIndent(8, "<max>" + memoryBean.getHeapMemoryUsage().getMax() + "</max>");
- reportGenerator.writeWithIndent(6, "</heap_memory>");
- reportGenerator.writeWithIndent(6, "<non_heap_memory>");
- reportGenerator.writeWithIndent(8, "<committed>" + memoryBean.getNonHeapMemoryUsage().getCommitted() + "</committed>");
- reportGenerator.writeWithIndent(8, "<max>" + memoryBean.getNonHeapMemoryUsage().getMax() + "</max>");
- reportGenerator.writeWithIndent(6, "</non_heap_memory>");
- reportGenerator.writeWithIndent(4, "</jvm_memory_settings>");
-
- reportGenerator.addClientSettings();
- reportGenerator.endTestInformation();
- }
-
-
- public void run() {
-
- long nonHeapMB = 0;
- long heapMB = 0;
- long oneMB = 1024 * 1024;
-
- reportGenerator.startTestResult(getCheckpointInterval());
- while (isRunning.get()) {
-
- try {
- //wait every check point before getting the next memory usage
- Thread.sleep(checkpointInterval);
-
- nonHeapMB = memoryBean.getNonHeapMemoryUsage().getUsed() / oneMB;
- heapMB = memoryBean.getHeapMemoryUsage().getUsed() / oneMB;
-
- reportGenerator.writeWithIndent(6, "<memory_usage index=" + resultIndex + " non_heap_mb=" + nonHeapMB + " non_heap_bytes=" + memoryBean.getNonHeapMemoryUsage().getUsed() + " heap_mb=" + heapMB + " heap_bytes=" + memoryBean.getHeapMemoryUsage().getUsed() + "/>");
-
- resultIndex++;
-
- } catch (Exception e) {
- e.printStackTrace();
-
- }
-
-
- }
- reportGenerator.endTestResult();
- reportGenerator.stopGenerateReport();
-
- }
-
-
-}
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tool;
+
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
+
+
+import java.io.DataOutputStream;
+import java.util.Properties;
+import java.lang.management.MemoryMXBean;
+import java.lang.management.ManagementFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public class MemoryMonitoringTool implements Runnable {
+
+ private long checkpointInterval = 5000; // 5 sec sample checkpointInterval
+ private long resultIndex = 0;
+
+ private AtomicBoolean isRunning = new AtomicBoolean(false);
+ private DataOutputStream dataDoutputStream = null;
+
+ protected Properties testSettings = new Properties();
+ protected ReportGenerator reportGenerator = new ReportGenerator();
+ private MemoryMXBean memoryBean;
+
+ public Properties getTestSettings() {
+ return testSettings;
+ }
+
+ public void setTestSettings(Properties sysTestSettings) {
+ this.testSettings = sysTestSettings;
+ }
+
+ public DataOutputStream getDataOutputStream() {
+ return dataDoutputStream;
+ }
+
+ public void setDataOutputStream(DataOutputStream dataDoutputStream) {
+ this.dataDoutputStream = dataDoutputStream;
+ }
+
+
+ public void stopMonitor() {
+ isRunning.set(false);
+ }
+
+
+ public long getCheckpointInterval() {
+ return checkpointInterval;
+ }
+
+ public void setCheckpointInterval(long checkpointInterval) {
+ this.checkpointInterval = checkpointInterval;
+ }
+
+
+ public Thread startMonitor() {
+
+ String intervalStr = this.getTestSettings().getProperty("checkpoint_interval");
+ checkpointInterval = new Integer(intervalStr).intValue();
+ this.getTestSettings().remove("checkpoint_interval");
+
+ memoryBean = ManagementFactory.getMemoryMXBean();
+ reportGenerator.setTestSettings(getTestSettings());
+ addTestInformation();
+
+ Thread t = new Thread(this);
+ t.setName("Memory monitoring tool");
+ isRunning.set(true);
+ t.start();
+
+ return t;
+
+ }
+
+
+ public void addTestInformation() {
+ reportGenerator.setReportName(this.getTestSettings().getProperty("report_name"));
+ reportGenerator.setReportDirectory(this.getTestSettings().getProperty("report_directory"));
+ reportGenerator.startGenerateReport();
+
+ reportGenerator.addTestInformation();
+ reportGenerator.writeWithIndent(4, "<jvm_memory_settings>");
+ reportGenerator.writeWithIndent(6, "<heap_memory>");
+ reportGenerator.writeWithIndent(8, "<committed>" + memoryBean.getHeapMemoryUsage().getCommitted() + "</committed>");
+ reportGenerator.writeWithIndent(8, "<max>" + memoryBean.getHeapMemoryUsage().getMax() + "</max>");
+ reportGenerator.writeWithIndent(6, "</heap_memory>");
+ reportGenerator.writeWithIndent(6, "<non_heap_memory>");
+ reportGenerator.writeWithIndent(8, "<committed>" + memoryBean.getNonHeapMemoryUsage().getCommitted() + "</committed>");
+ reportGenerator.writeWithIndent(8, "<max>" + memoryBean.getNonHeapMemoryUsage().getMax() + "</max>");
+ reportGenerator.writeWithIndent(6, "</non_heap_memory>");
+ reportGenerator.writeWithIndent(4, "</jvm_memory_settings>");
+
+ reportGenerator.addClientSettings();
+ reportGenerator.endTestInformation();
+ }
+
+
+ public void run() {
+
+ long nonHeapMB = 0;
+ long heapMB = 0;
+ long oneMB = 1024 * 1024;
+
+ reportGenerator.startTestResult(getCheckpointInterval());
+ while (isRunning.get()) {
+
+ try {
+ //wait every check point before getting the next memory usage
+ Thread.sleep(checkpointInterval);
+
+ nonHeapMB = memoryBean.getNonHeapMemoryUsage().getUsed() / oneMB;
+ heapMB = memoryBean.getHeapMemoryUsage().getUsed() / oneMB;
+
+ reportGenerator.writeWithIndent(6, "<memory_usage index=" + resultIndex + " non_heap_mb=" + nonHeapMB + " non_heap_bytes=" + memoryBean.getNonHeapMemoryUsage().getUsed() + " heap_mb=" + heapMB + " heap_bytes=" + memoryBean.getHeapMemoryUsage().getUsed() + "/>");
+
+ resultIndex++;
+
+ } catch (Exception e) {
+ e.printStackTrace();
+
+ }
+
+
+ }
+ reportGenerator.endTestResult();
+ reportGenerator.stopGenerateReport();
+
+ }
+
+
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-memtest-plugin/src/main/java/org/apache/activemq/tool/MemoryMonitoringTool.java
------------------------------------------------------------------------------
svn:eol-style = native