You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ac...@apache.org on 2006/06/23 03:53:50 UTC
svn commit: r416542 [2/2] - in
/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src:
main/java/org/apache/activemq/maven/ main/java/org/apache/activemq/tool/
main/java/org/apache/activemq/tool/properties/
main/java/org/apache/activemq/tool/...
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsClientSystemProperties.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsClientSystemProperties.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsClientSystemProperties.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsClientSystemProperties.java Thu Jun 22 18:53:48 2006
@@ -0,0 +1,113 @@
+/**
+ *
+ * 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.properties;
+
+public class JmsClientSystemProperties extends AbstractObjectProperties {
+ public static final String DEST_DISTRO_ALL = "all"; // Each client will send/receive to all destination;
+ public static final String DEST_DISTRO_EQUAL = "equal"; // Equally divide the number of destinations to the number of clients
+ public static final String DEST_DISTRO_DIVIDE = "divide"; // Divide the destination among the clients, even if some have more destination than others
+
+ public static final String REPORT_VERBOSE = "verbose"; // Report would be generated to the console
+ public static final String REPORT_XML_FILE = "xml"; // Report would be generated to an xml file
+
+ public static final String SAMPLER_TP = "tp";
+ public static final String SAMPLER_CPU = "cpu";
+
+ protected String reportType = REPORT_XML_FILE;
+ protected String reportDir = "./";
+ protected String reportName = null;
+
+ protected String samplers = SAMPLER_TP + "," + SAMPLER_CPU; // Start both samplers
+
+ protected String spiClass = "org.apache.activemq.tool.spi.ActiveMQClassLoaderSPI";
+ protected String clientPrefix = "JmsClient";
+ protected int numClients = 1;
+ protected int totalDests = 1;
+ protected String destDistro = DEST_DISTRO_ALL;
+
+ public String getReportType() {
+ return reportType;
+ }
+
+ public void setReportType(String reportType) {
+ this.reportType = reportType;
+ }
+
+ public String getReportDir() {
+ return reportDir;
+ }
+
+ public void setReportDir(String reportDir) {
+ this.reportDir = reportDir;
+ }
+
+ public String getReportName() {
+ return reportName;
+ }
+
+ public void setReportName(String reportName) {
+ this.reportName = reportName;
+ }
+
+ public String getSamplers() {
+ return samplers;
+ }
+
+ public void setSamplers(String samplers) {
+ this.samplers = samplers;
+ }
+
+ public String getSpiClass() {
+ return spiClass;
+ }
+
+ public void setSpiClass(String spiClass) {
+ this.spiClass = spiClass;
+ }
+
+ public String getClientPrefix() {
+ return clientPrefix;
+ }
+
+ public void setClientPrefix(String clientPrefix) {
+ this.clientPrefix = clientPrefix;
+ }
+
+ public int getNumClients() {
+ return numClients;
+ }
+
+ public void setNumClients(int numClients) {
+ this.numClients = numClients;
+ }
+
+ public int getTotalDests() {
+ return totalDests;
+ }
+
+ public void setTotalDests(int totalDests) {
+ this.totalDests = totalDests;
+ }
+
+ public String getDestDistro() {
+ return destDistro;
+ }
+
+ public void setDestDistro(String destDistro) {
+ this.destDistro = destDistro;
+ }
+}
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerProperties.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerProperties.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerProperties.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerProperties.java Thu Jun 22 18:53:48 2006
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2005-2006 The Apache Software Foundation
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.properties;
+
+public class JmsConsumerProperties extends JmsClientProperties {
+ public static final String TIME_BASED_RECEIVING = "time"; // Receive messages on a time-based interval
+ public static final String COUNT_BASED_RECEIVING = "count"; // Receive a specific count of messages
+
+ protected boolean durable = false; // Consumer is a durable subscriber
+ protected boolean asyncRecv = true; // If true, use onMessage() to receive messages, else use receive()
+
+ protected long recvCount = 1000000; // Receive a million messages by default
+ protected long recvDuration = 5 * 60 * 1000; // Receive for 5 mins by default
+ protected String recvType = TIME_BASED_RECEIVING;
+
+ public boolean isDurable() {
+ return durable;
+ }
+
+ public void setDurable(boolean durable) {
+ this.durable = durable;
+ }
+
+ public boolean isAsyncRecv() {
+ return asyncRecv;
+ }
+
+ public void setAsyncRecv(boolean asyncRecv) {
+ this.asyncRecv = asyncRecv;
+ }
+
+ public long getRecvCount() {
+ return recvCount;
+ }
+
+ public void setRecvCount(long recvCount) {
+ this.recvCount = recvCount;
+ }
+
+ public long getRecvDuration() {
+ return recvDuration;
+ }
+
+ public void setRecvDuration(long recvDuration) {
+ this.recvDuration = recvDuration;
+ }
+
+ public String getRecvType() {
+ return recvType;
+ }
+
+ public void setRecvType(String recvType) {
+ this.recvType = recvType;
+ }
+}
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerSystemProperties.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerSystemProperties.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerSystemProperties.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsConsumerSystemProperties.java Thu Jun 22 18:53:48 2006
@@ -0,0 +1,23 @@
+/**
+ *
+ * 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.properties;
+
+public class JmsConsumerSystemProperties extends JmsClientSystemProperties {
+ public JmsConsumerSystemProperties() {
+ clientPrefix = "JmsConsumer";
+ }
+}
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsFactoryProperties.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsFactoryProperties.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsFactoryProperties.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsFactoryProperties.java Thu Jun 22 18:53:48 2006
@@ -0,0 +1,34 @@
+/**
+ *
+ * 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.properties;
+
+import java.util.Properties;
+
+public class JmsFactoryProperties extends AbstractObjectProperties {
+ Properties factorySettings = new Properties();
+
+ public boolean acceptConfig(String key, String val) {
+ // Since we do not know the specific properties of each factory,
+ // lets cache it first and give it to the spi later
+ factorySettings.setProperty(key, val);
+ return false;
+ }
+
+ public Properties getFactorySettings() {
+ return factorySettings;
+ }
+}
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerProperties.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerProperties.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerProperties.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerProperties.java Thu Jun 22 18:53:48 2006
@@ -0,0 +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.tool.properties;
+
+public class JmsProducerProperties extends JmsClientProperties {
+ public static final String TIME_BASED_SENDING = "time"; // Produce messages base on a time interval
+ public static final String COUNT_BASED_SENDING = "count"; // Produce a specific count of messages
+ public static final String DELIVERY_MODE_PERSISTENT = "persistent"; // Persistent message delivery
+ public static final String DELIVERY_MODE_NON_PERSISTENT = "nonpersistent"; // Non-persistent message delivery
+
+ protected String deliveryMode = DELIVERY_MODE_NON_PERSISTENT; // Message delivery mode
+ protected int messageSize = 1024; // Send 1kb messages by default
+ protected long sendCount = 1000000; // Send a million messages by default
+ protected long sendDuration = 5 * 60 * 1000; // Send for 5 mins by default
+ protected String sendType = TIME_BASED_SENDING;
+ protected boolean createNewMsg = false; // If true, create a different message on each send, otherwise reuse.
+
+ public String getDeliveryMode() {
+ return deliveryMode;
+ }
+
+ public void setDeliveryMode(String deliveryMode) {
+ this.deliveryMode = deliveryMode;
+ }
+
+ public int getMessageSize() {
+ return messageSize;
+ }
+
+ public void setMessageSize(int messageSize) {
+ this.messageSize = messageSize;
+ }
+
+ public long getSendCount() {
+ return sendCount;
+ }
+
+ public void setSendCount(long sendCount) {
+ this.sendCount = sendCount;
+ }
+
+ public long getSendDuration() {
+ return sendDuration;
+ }
+
+ public void setSendDuration(long sendDuration) {
+ this.sendDuration = sendDuration;
+ }
+
+ public String getSendType() {
+ return sendType;
+ }
+
+ public void setSendType(String sendType) {
+ this.sendType = sendType;
+ }
+
+ public boolean isCreateNewMsg() {
+ return createNewMsg;
+ }
+
+ public void setCreateNewMsg(boolean createNewMsg) {
+ this.createNewMsg = createNewMsg;
+ }
+}
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerSystemProperties.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerSystemProperties.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerSystemProperties.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/JmsProducerSystemProperties.java Thu Jun 22 18:53:48 2006
@@ -0,0 +1,23 @@
+/**
+ *
+ * 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.properties;
+
+public class JmsProducerSystemProperties extends JmsClientSystemProperties {
+ public JmsProducerSystemProperties() {
+ clientPrefix = "JmsProducer";
+ }
+}
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionConfigurable.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionConfigurable.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionConfigurable.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionConfigurable.java Thu Jun 22 18:53:48 2006
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2005-2006 The Apache Software Foundation
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.properties;
+
+import java.util.Properties;
+
+public interface ReflectionConfigurable {
+ public void configureProperties(Properties props);
+ public Properties retrieveProperties(Properties props);
+ public boolean acceptConfig(String key, String val);
+}
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionUtil.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionUtil.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionUtil.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionUtil.java Thu Jun 22 18:53:48 2006
@@ -0,0 +1,226 @@
+/**
+ * Copyright 2005-2006 The Apache Software Foundation
+ * <p/>
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Iterator;
+import java.util.StringTokenizer;
+import java.util.Properties;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.lang.reflect.Method;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+
+public final class ReflectionUtil {
+ private static final Log log = LogFactory.getLog(ReflectionUtil.class);
+
+ private ReflectionUtil() {
+ }
+
+ public static void configureClass(Object obj, String key, String val) {
+ // Check if we will recognize the property first
+ if (obj instanceof ReflectionConfigurable && !((ReflectionConfigurable)obj).acceptConfig(key, val)) {
+ return;
+ }
+
+ try {
+ String debugInfo;
+
+ Object target = obj;
+ Class targetClass = obj.getClass();
+
+ // DEBUG: Debugging Info
+ debugInfo = "Invoking: " + targetClass.getName();
+
+ StringTokenizer tokenizer = new StringTokenizer(key, ".");
+ int tokenCount = tokenizer.countTokens();
+
+ // For nested settings, get the object first. -2, do not count the first and last token
+ for (int j=0; j<tokenCount-1; j++) {
+ // Find getter method first
+ String name = tokenizer.nextToken();
+ String getMethod = "get" + name.substring(0,1).toUpperCase() + name.substring(1);
+ Method method = targetClass.getMethod(getMethod, new Class[] {});
+ target = method.invoke(target, null);
+ targetClass = target.getClass();
+
+ debugInfo += ("." + getMethod + "()");
+ }
+
+ // Property name
+ String property = tokenizer.nextToken();
+
+ // Determine data type of property
+ Class propertyType = getField(targetClass, property).getType();
+
+ // Get setter method
+ String setterMethod = "set" + property.substring(0,1).toUpperCase() + property.substring(1);
+
+ // Set primitive type
+ debugInfo += ("." + setterMethod + "(" + propertyType.getName() + ": " + val + ")");
+ if (propertyType.isPrimitive()) {
+ if (propertyType == Boolean.TYPE) {
+ targetClass.getMethod(setterMethod, new Class[] {boolean.class}).invoke(target, new Object[] {Boolean.valueOf(val)});
+ } else if (propertyType == Integer.TYPE) {
+ targetClass.getMethod(setterMethod, new Class[] {int.class}).invoke(target, new Object[] {Integer.valueOf(val)});
+ } else if (propertyType == Long.TYPE) {
+ targetClass.getMethod(setterMethod, new Class[] {long.class}).invoke(target, new Object[] {Long.valueOf(val)});
+ } else if (propertyType == Double.TYPE) {
+ targetClass.getMethod(setterMethod, new Class[] {double.class}).invoke(target, new Object[] {Double.valueOf(val)});
+ } else if (propertyType == Float.TYPE) {
+ targetClass.getMethod(setterMethod, new Class[] {float.class}).invoke(target, new Object[] {Float.valueOf(val)});
+ } else if (propertyType == Short.TYPE) {
+ targetClass.getMethod(setterMethod, new Class[] {short.class}).invoke(target, new Object[] {Short.valueOf(val)});
+ } else if (propertyType == Byte.TYPE) {
+ targetClass.getMethod(setterMethod, new Class[] {byte.class}).invoke(target, new Object[] {Byte.valueOf(val)});
+ } else if (propertyType == Character.TYPE) {
+ targetClass.getMethod(setterMethod, new Class[] {char.class}).invoke(target, new Object[] {new Character(val.charAt(0))});
+ }
+ } else {
+ // Set String type
+ if (propertyType == String.class) {
+ targetClass.getMethod(setterMethod, new Class[] {String.class}).invoke(target, new Object[] {val});
+
+ // For unknown object type, try to call the valueOf method of the object
+ // to convert the string to the target object type
+ } else {
+ // Note valueOf method should be public and static
+ Object param = propertyType.getMethod("valueOf", new Class[] {String.class}).invoke(null, new Object[] {val});
+ targetClass.getMethod(setterMethod, new Class[] {propertyType}).invoke(target, new Object[] {param});
+ }
+ }
+ log.debug(debugInfo);
+
+ } catch (Exception e) {
+ log.warn(e);
+ }
+ }
+
+ public static void configureClass(Object obj, Properties props) {
+ for (Iterator i = props.keySet().iterator(); i.hasNext();) {
+ try {
+ String key = (String)i.next();
+ String val = props.getProperty(key);
+
+ configureClass(obj, key, val);
+ } catch (Throwable t) {
+ // Let's catch any exception as this could be cause by the foreign class
+ t.printStackTrace();
+ }
+ }
+ }
+
+ public static Properties retrieveObjectProperties(Object obj) {
+ Properties props = new Properties();
+ try {
+ props.putAll(retrieveClassProperties("", obj.getClass(), obj));
+ } catch (Exception e) {
+ log.warn(e);
+ }
+ return props;
+ }
+
+ protected static Properties retrieveClassProperties(String prefix, Class targetClass, Object targetObject) {
+ if (targetClass == null || targetObject == null) {
+ return new Properties();
+ } else {
+ Properties props = new Properties();
+ Field[] fields = getAllFields(targetClass);
+ Method getterMethod;
+ for (int i=0; i<fields.length; i++) {
+ try {
+ if ((getterMethod = isPropertyField(targetClass, fields[i])) != null) {
+ if (fields[i].getType().isPrimitive() || fields[i].getType() == String.class) {
+ Object val = null;
+ try {
+ val = getterMethod.invoke(targetObject, null);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ props.setProperty(prefix + fields[i].getName(), val + "");
+ } else {
+ try {
+ Object val = getterMethod.invoke(targetObject, null);
+ if (val != null) {
+ props.putAll(retrieveClassProperties(fields[i].getName() + ".", val.getClass(), val));
+ }
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ } catch (Throwable t) {
+ // Let's catch any exception, cause this could be cause by the foreign class
+ t.printStackTrace();
+ }
+ }
+ return props;
+ }
+ }
+
+ protected static Method isPropertyField(Class targetClass, Field targetField) {
+ String fieldName = targetField.getName();
+ String getMethod = "get" + fieldName.substring(0,1).toUpperCase() + fieldName.substring(1);
+ String isMethod = "is" + fieldName.substring(0,1).toUpperCase() + fieldName.substring(1);
+ String setMethod = "set" + fieldName.substring(0,1).toUpperCase() + fieldName.substring(1);
+
+ // Check setter method
+ try {
+ targetClass.getMethod(setMethod, new Class[]{targetField.getType()});
+ } catch (NoSuchMethodException e) {
+ return null;
+ }
+
+ // Check getter method and return it if it exists
+ try {
+ return targetClass.getMethod(getMethod, null);
+ } catch (NoSuchMethodException e1) {
+ try {
+ return targetClass.getMethod(isMethod, null);
+ } catch (NoSuchMethodException e2) {
+ return null;
+ }
+ }
+ }
+
+ public static Field getField(Class targetClass, String fieldName) throws NoSuchFieldException {
+ while (targetClass != null) {
+ try {
+ return targetClass.getDeclaredField(fieldName);
+ } catch (NoSuchFieldException e) {
+ targetClass = targetClass.getSuperclass();
+ }
+ }
+ throw new NoSuchFieldException(fieldName);
+ }
+
+ public static Field[] getAllFields(Class targetClass) {
+ List fieldList = new ArrayList();
+ while (targetClass != null) {
+ Collections.addAll(fieldList, targetClass.getDeclaredFields());
+ targetClass = targetClass.getSuperclass();
+ }
+ return (Field[])fieldList.toArray(new Field[0]);
+ }
+}
Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/AbstractPerfReportWriter.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/AbstractPerfReportWriter.java?rev=416542&r1=416541&r2=416542&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/AbstractPerfReportWriter.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/AbstractPerfReportWriter.java Thu Jun 22 18:53:48 2006
@@ -16,178 +16,23 @@
*/
package org.apache.activemq.tool.reports;
-import org.apache.activemq.tool.ReflectionUtil;
+import org.apache.activemq.tool.reports.plugins.ReportPlugin;
+import org.apache.activemq.tool.reports.plugins.ThroughputReportPlugin;
+import org.apache.activemq.tool.reports.plugins.CpuReportPlugin;
-import java.util.Properties;
import java.util.Map;
-import java.util.HashMap;
-import java.util.StringTokenizer;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Set;
-import java.util.Iterator;
public abstract class AbstractPerfReportWriter implements PerformanceReportWriter {
- public static final String KEY_SYS_TOTAL_TP = "SystemTotalTP";
- public static final String KEY_SYS_TOTAL_CLIENTS = "SystemTotalClients";
- public static final String KEY_SYS_AVE_TP = "SystemAveTP";
- public static final String KEY_SYS_AVE_EMM_TP = "SystemAveEMMTP";
- public static final String KEY_SYS_AVE_CLIENT_TP = "SystemAveClientTP";
- public static final String KEY_SYS_AVE_CLIENT_EMM_TP = "SystemAveClientEMMTP";
- public static final String KEY_MIN_CLIENT_TP = "MinClientTP";
- public static final String KEY_MAX_CLIENT_TP = "MaxClientTP";
- public static final String KEY_MIN_CLIENT_TOTAL_TP = "MinClientTotalTP";
- public static final String KEY_MAX_CLIENT_TOTAL_TP = "MaxClientTotalTP";
- public static final String KEY_MIN_CLIENT_AVE_TP = "MinClientAveTP";
- public static final String KEY_MAX_CLIENT_AVE_TP = "MaxClientAveTP";
- public static final String KEY_MIN_CLIENT_AVE_EMM_TP = "MinClientAveEMMTP";
- public static final String KEY_MAX_CLIENT_AVE_EMM_TP = "MaxClientAveEMMTP";
+ protected ReportPlugin[] plugins = new ReportPlugin[] {
+ new ThroughputReportPlugin(),
+ new CpuReportPlugin()
+ };
- protected Properties settings;
- protected Map clientThroughputs = new HashMap();
-
- public void setSettings(Properties settings) {
- this.settings = settings;
- ReflectionUtil.configureClass(this, settings);
- }
-
- public Properties getSettings() {
- return settings;
- }
-
- protected void parsePerfCsvData(String csvData) {
- StringTokenizer tokenizer = new StringTokenizer(csvData, ",");
- String data, key, val, clientName = null;
- Long throughput = null;
- while (tokenizer.hasMoreTokens()) {
- data = tokenizer.nextToken();
- key = data.substring(0, data.indexOf("="));
- val = data.substring(data.indexOf("=") + 1);
-
- if (key.equalsIgnoreCase("clientName")) {
- clientName = val;
- } else if (key.equalsIgnoreCase("throughput")) {
- throughput = Long.valueOf(val);
- } else {
- // Ignore unknown token
- }
- }
- addToClientTPList(clientName, throughput);
+ protected void handleCsvData(int pluginType, String csvData) {
+ plugins[pluginType].handleCsvData(csvData);
}
- protected void addToClientTPList(String clientName, Long throughput) {
- // Write to client's throughput list
- if (clientName == null || throughput == null) {
- throw new IllegalArgumentException("Invalid Throughput CSV Data: clientName=" + clientName + ", throughput=" + throughput);
- }
-
- List clientTPList = (List)clientThroughputs.get(clientName);
- if (clientTPList == null) {
- clientTPList = new ArrayList();
- clientThroughputs.put(clientName, clientTPList);
- }
- clientTPList.add(throughput);
- }
-
- protected Map createPerfSummary(Map clientTPMap) {
- long minClientTP = Long.MAX_VALUE, // TP = throughput
- maxClientTP = Long.MIN_VALUE,
- minClientTotalTP = Long.MAX_VALUE,
- maxClientTotalTP = Long.MIN_VALUE,
- systemTotalTP = 0;
-
- double minClientAveTP = Double.MAX_VALUE,
- maxClientAveTP = Double.MIN_VALUE,
- minClientAveEMMTP = Double.MAX_VALUE, // EMM = Excluding Min/Max
- maxClientAveEMMTP = Double.MIN_VALUE,
- systemAveTP = 0.0,
- systemAveEMMTP = 0.0;
-
- String nameMinClientTP = "",
- nameMaxClientTP = "",
- nameMinClientTotalTP = "",
- nameMaxClientTotalTP = "",
- nameMinClientAveTP = "",
- nameMaxClientAveTP = "",
- nameMinClientAveEMMTP = "",
- nameMaxClientAveEMMTP = "";
-
- Set clientNames = clientTPMap.keySet();
- String clientName;
- List clientTPList;
- long tempLong;
- double tempDouble;
- int clientCount = 0;
- for (Iterator i=clientNames.iterator(); i.hasNext();) {
- clientName = (String)i.next();
- clientTPList = (List)clientTPMap.get(clientName);
- clientCount++;
-
- tempLong = PerformanceStatisticsUtil.getMinThroughput(clientTPList);
- if (tempLong < minClientTP) {
- minClientTP = tempLong;
- nameMinClientTP = clientName;
- }
-
- tempLong = PerformanceStatisticsUtil.getMaxThroughput(clientTPList);
- if (tempLong > maxClientTP) {
- maxClientTP = tempLong;
- nameMaxClientTP = clientName;
- }
-
- tempLong = PerformanceStatisticsUtil.getTotalThroughput(clientTPList);
- systemTotalTP += tempLong; // Accumulate total TP
- if (tempLong < minClientTotalTP) {
- minClientTotalTP = tempLong;
- nameMinClientTotalTP = clientName;
- }
-
- if (tempLong > maxClientTotalTP) {
- maxClientTotalTP = tempLong;
- nameMaxClientTotalTP = clientName;
- }
-
- tempDouble = PerformanceStatisticsUtil.getAveThroughput(clientTPList);
- systemAveTP += tempDouble; // Accumulate ave throughput
- if (tempDouble < minClientAveTP) {
- minClientAveTP = tempDouble;
- nameMinClientAveTP = clientName;
- }
-
- if (tempDouble > maxClientAveTP) {
- maxClientAveTP = tempDouble;
- nameMaxClientAveTP = clientName;
- }
-
- tempDouble = PerformanceStatisticsUtil.getAveThroughputExcludingMinMax(clientTPList);
- systemAveEMMTP += tempDouble; // Accumulate ave throughput excluding min/max
- if (tempDouble < minClientAveEMMTP) {
- minClientAveEMMTP = tempDouble;
- nameMinClientAveEMMTP = clientName;
- }
-
- if (tempDouble > maxClientAveEMMTP) {
- maxClientAveEMMTP = tempDouble;
- nameMaxClientAveEMMTP = clientName;
- }
- }
-
- Map summary = new HashMap();
- summary.put(KEY_SYS_TOTAL_TP, String.valueOf(systemTotalTP));
- summary.put(KEY_SYS_TOTAL_CLIENTS, String.valueOf(clientCount));
- summary.put(KEY_SYS_AVE_TP, String.valueOf(systemAveTP));
- summary.put(KEY_SYS_AVE_EMM_TP, String.valueOf(systemAveEMMTP));
- summary.put(KEY_SYS_AVE_CLIENT_TP, String.valueOf(systemAveTP / clientCount));
- summary.put(KEY_SYS_AVE_CLIENT_EMM_TP, String.valueOf(systemAveEMMTP / clientCount));
- summary.put(KEY_MIN_CLIENT_TP, nameMinClientTP + "=" + minClientTP);
- summary.put(KEY_MAX_CLIENT_TP, nameMaxClientTP + "=" + maxClientTP);
- summary.put(KEY_MIN_CLIENT_TOTAL_TP, nameMinClientTotalTP + "=" + minClientTotalTP);
- summary.put(KEY_MAX_CLIENT_TOTAL_TP, nameMaxClientTotalTP + "=" + maxClientTotalTP);
- summary.put(KEY_MIN_CLIENT_AVE_TP, nameMinClientAveTP + "=" + minClientAveTP);
- summary.put(KEY_MAX_CLIENT_AVE_TP, nameMaxClientAveTP + "=" + maxClientAveTP);
- summary.put(KEY_MIN_CLIENT_AVE_EMM_TP, nameMinClientAveEMMTP + "=" + minClientAveEMMTP);
- summary.put(KEY_MAX_CLIENT_AVE_EMM_TP, nameMaxClientAveEMMTP + "=" + maxClientAveEMMTP);
-
- return summary;
+ protected Map getSummary(int pluginType) {
+ return plugins[pluginType].getSummary();
}
}
Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/PerformanceReportWriter.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/PerformanceReportWriter.java?rev=416542&r1=416541&r2=416542&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/PerformanceReportWriter.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/PerformanceReportWriter.java Thu Jun 22 18:53:48 2006
@@ -19,12 +19,10 @@
import java.util.Properties;
public interface PerformanceReportWriter {
- public void setSettings(Properties settings);
- public Properties getSettings();
public void openReportWriter();
public void closeReportWriter();
public void writeInfo(String info);
- public void writePerfData(String data);
+ public void writeCsvData(int csvType, String csvData);
public void writeProperties(String header, Properties props);
public void writeProperties(Properties props);
}
Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/VerbosePerfReportWriter.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/VerbosePerfReportWriter.java?rev=416542&r1=416541&r2=416542&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/VerbosePerfReportWriter.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/VerbosePerfReportWriter.java Thu Jun 22 18:53:48 2006
@@ -16,6 +16,9 @@
*/
package org.apache.activemq.tool.reports;
+import org.apache.activemq.tool.reports.plugins.ReportPlugin;
+import org.apache.activemq.tool.reports.plugins.ThroughputReportPlugin;
+
import java.util.Properties;
import java.util.Iterator;
import java.util.Map;
@@ -24,7 +27,7 @@
public class VerbosePerfReportWriter extends AbstractPerfReportWriter {
public void openReportWriter() {
- writeProperties("System Properties", System.getProperties());
+ // Do nothing
}
public void closeReportWriter() {
@@ -36,20 +39,13 @@
System.out.println("[PERF-INFO]: " + info);
}
- public void writeHeader(String header) {
- char[] border = new char[header.length() + 8]; // +8 for spacing
- Arrays.fill(border, '#');
- String borderStr = new String(border);
-
- System.out.println(borderStr);
- System.out.println("# " + header + " #");
- System.out.println(borderStr);
- }
-
- public void writePerfData(String data) {
- System.out.println("[PERF-DATA]: " + data);
- // Assume data is a CSV of key-value pair
- parsePerfCsvData(data);
+ public void writeCsvData(int csvType, String csvData) {
+ if (csvType == ReportPlugin.REPORT_PLUGIN_THROUGHPUT) {
+ System.out.println("[PERF-TP]: " + csvData);
+ } else if (csvType == ReportPlugin.REPORT_PLUGIN_CPU) {
+ System.out.println("[PERF-CPU]: " + csvData);
+ }
+ handleCsvData(csvType, csvData);
}
public void writeProperties(String header, Properties props) {
@@ -66,22 +62,32 @@
}
public void writePerfSummary() {
- Map summary = createPerfSummary(clientThroughputs);
+ Map summary = getSummary(ReportPlugin.REPORT_PLUGIN_THROUGHPUT);
+
+ System.out.println("[PERF-TP-SUMMARY] System Total Throughput: " + summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_TP));
+ System.out.println("[PERF-TP-SUMMARY] System Total Clients: " + summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_CLIENTS));
+ System.out.println("[PERF-TP-SUMMARY] System Average Throughput: " + summary.get(ThroughputReportPlugin.KEY_SYS_AVE_TP));
+ System.out.println("[PERF-TP-SUMMARY] System Average Throughput Excluding Min/Max: " + summary.get(ThroughputReportPlugin.KEY_SYS_AVE_EMM_TP));
+ System.out.println("[PERF-TP-SUMMARY] System Average Client Throughput: " + summary.get(ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_TP));
+ System.out.println("[PERF-TP-SUMMARY] System Average Client Throughput Excluding Min/Max: " + summary.get(ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_EMM_TP));
+ System.out.println("[PERF-TP-SUMMARY] Min Client Throughput Per Sample: " + summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_TP));
+ System.out.println("[PERF-TP-SUMMARY] Max Client Throughput Per Sample: " + summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_TP));
+ System.out.println("[PERF-TP-SUMMARY] Min Client Total Throughput: " + summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_TOTAL_TP));
+ System.out.println("[PERF-TP-SUMMARY] Max Client Total Throughput: " + summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_TOTAL_TP));
+ System.out.println("[PERF-TP-SUMMARY] Min Client Average Throughput: " + summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_TP));
+ System.out.println("[PERF-TP-SUMMARY] Max Client Average Throughput: " + summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_TP));
+ System.out.println("[PERF-TP-SUMMARY] Min Client Average Throughput Excluding Min/Max: " + summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_EMM_TP));
+ System.out.println("[PERF-TP-SUMMARY] Max Client Average Throughput Excluding Min/Max: " + summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_EMM_TP));
+ }
+
+ protected void writeHeader(String header) {
+ char[] border = new char[header.length() + 8]; // +8 for spacing
+ Arrays.fill(border, '#');
+ String borderStr = new String(border);
- System.out.println("[PERF-SUMMARY] System Total Throughput: " + summary.get(KEY_SYS_TOTAL_TP));
- System.out.println("[PERF-SUMMARY] System Total Clients: " + summary.get(KEY_SYS_TOTAL_CLIENTS));
- System.out.println("[PERF-SUMMARY] System Average Throughput: " + summary.get(KEY_SYS_AVE_TP));
- System.out.println("[PERF-SUMMARY] System Average Throughput Excluding Min/Max: " + summary.get(KEY_SYS_AVE_EMM_TP));
- System.out.println("[PERF-SUMMARY] System Average Client Throughput: " + summary.get(KEY_SYS_AVE_CLIENT_TP));
- System.out.println("[PERF-SUMMARY] System Average Client Throughput Excluding Min/Max: " + summary.get(KEY_SYS_AVE_CLIENT_EMM_TP));
- System.out.println("[PERF-SUMMARY] Min Client Throughput Per Sample: " + summary.get(KEY_MIN_CLIENT_TP));
- System.out.println("[PERF-SUMMARY] Max Client Throughput Per Sample: " + summary.get(KEY_MAX_CLIENT_TP));
- System.out.println("[PERF-SUMMARY] Min Client Total Throughput: " + summary.get(KEY_MIN_CLIENT_TOTAL_TP));
- System.out.println("[PERF-SUMMARY] Max Client Total Throughput: " + summary.get(KEY_MAX_CLIENT_TOTAL_TP));
- System.out.println("[PERF-SUMMARY] Min Client Average Throughput: " + summary.get(KEY_MIN_CLIENT_AVE_TP));
- System.out.println("[PERF-SUMMARY] Max Client Average Throughput: " + summary.get(KEY_MAX_CLIENT_AVE_TP));
- System.out.println("[PERF-SUMMARY] Min Client Average Throughput Excluding Min/Max: " + summary.get(KEY_MIN_CLIENT_AVE_EMM_TP));
- System.out.println("[PERF-SUMMARY] Max Client Average Throughput Excluding Min/Max: " + summary.get(KEY_MAX_CLIENT_AVE_EMM_TP));
+ System.out.println(borderStr);
+ System.out.println("# " + header + " #");
+ System.out.println(borderStr);
}
}
Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/XmlFilePerfReportWriter.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/XmlFilePerfReportWriter.java?rev=416542&r1=416541&r2=416542&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/XmlFilePerfReportWriter.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/XmlFilePerfReportWriter.java Thu Jun 22 18:53:48 2006
@@ -18,6 +18,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.activemq.tool.reports.plugins.ReportPlugin;
+import org.apache.activemq.tool.reports.plugins.ThroughputReportPlugin;
import java.util.Properties;
import java.util.List;
@@ -99,12 +101,24 @@
this.reportName = reportName;
}
+ public File getXmlFile() {
+ return xmlFile;
+ }
+
+ public void setXmlFile(File xmlFile) {
+ this.xmlFile = xmlFile;
+ }
+
public void writeInfo(String info) {
tempLogFileWriter.println("[INFO]" + info);
}
- public void writePerfData(String data) {
- tempLogFileWriter.println("[DATA]" + data);
+ public void writeCsvData(int csvType, String csvData) {
+ if (csvType == ReportPlugin.REPORT_PLUGIN_THROUGHPUT) {
+ tempLogFileWriter.println("[TP-DATA]" + csvData);
+ } else if (csvType == ReportPlugin.REPORT_PLUGIN_CPU) {
+ tempLogFileWriter.println("[CPU-DATA]" + csvData);
+ }
}
public void writeProperties(String header, Properties props) {
@@ -116,7 +130,7 @@
}
protected File createTempLogFile() {
- File f = null;
+ File f;
try {
f = File.createTempFile("tmpPL", null);
} catch (IOException e) {
@@ -130,8 +144,7 @@
String filename = (getReportName().endsWith(".xml") ? getReportName() : (getReportName() + ".xml"));
String path = (getReportDir() == null) ? "" : getReportDir();
- File f = new File(path + filename);
- return f;
+ return new File(path + filename);
}
protected void writeToXml() {
@@ -145,7 +158,7 @@
writeXmlFooter();
xmlFileWriter.close();
- System.out.println("Created performance report: " + xmlFile.getAbsolutePath());
+ log.info("Created performance report: " + xmlFile.getAbsolutePath());
} catch (Exception e) {
e.printStackTrace();
}
@@ -161,8 +174,6 @@
protected void writeXmlTestSettings() {
Properties props;
- // Write system settings
- writeMap("systemSettings", System.getProperties());
// Write test settings
for (Iterator i=testPropsMap.keySet().iterator(); i.hasNext();) {
@@ -186,12 +197,16 @@
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(tempLogFile)));
String line;
while ((line = reader.readLine()) != null) {
- if (line.startsWith("[DATA]")) {
- parsePerfCsvData(line.substring("[DATA]".length()));
+ if (line.startsWith("[TP-DATA]")) {
+ handleCsvData(ReportPlugin.REPORT_PLUGIN_THROUGHPUT, line.substring("[TP-DATA]".length()));
+ parsePerfCsvData("tpdata", line.substring("[TP-DATA]".length()));
+ } else if (line.startsWith("[CPU-DATA]")) {
+ handleCsvData(ReportPlugin.REPORT_PLUGIN_CPU, line.substring("[CPU-DATA]".length()));
+ parsePerfCsvData("cpudata", line.substring("[CPU-DATA]".length()));
} else if (line.startsWith("[INFO]")) {
- xmlFileWriter.println("<value>" + line + "</value>");
+ xmlFileWriter.println("<info>" + line + "</info>");
} else {
- xmlFileWriter.println("<value>[ERROR]" + line + "</value>");
+ xmlFileWriter.println("<error>" + line + "</error>");
}
}
@@ -200,84 +215,85 @@
}
protected void writeXmlPerfSummary() {
- Map summary = createPerfSummary(clientThroughputs);
+ // Write throughput summary
+ Map summary = getSummary(ReportPlugin.REPORT_PLUGIN_THROUGHPUT);
xmlFileWriter.println("<property name='perfSummary'>");
xmlFileWriter.println("<props>");
String val, clientName, clientVal;
- val = (String)summary.get(KEY_SYS_TOTAL_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_TP);
System.out.println("System Total Throughput: " + val);
- xmlFileWriter.println("<prop key='" + KEY_SYS_TOTAL_TP + "'>" + val + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_TOTAL_TP + "'>" + val + "</prop>");
- val = (String)summary.get(KEY_SYS_TOTAL_CLIENTS);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_CLIENTS);
System.out.println("System Total Clients: " + val);
- xmlFileWriter.println("<prop key='" + KEY_SYS_TOTAL_CLIENTS + "'>" + val + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_TOTAL_CLIENTS + "'>" + val + "</prop>");
- val = (String)summary.get(KEY_SYS_AVE_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_AVE_TP);
System.out.println("System Average Throughput: " + val);
- xmlFileWriter.println("<prop key='" + KEY_SYS_AVE_TP + "'>" + val + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_AVE_TP + "'>" + val + "</prop>");
- val = (String)summary.get(KEY_SYS_AVE_EMM_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_AVE_EMM_TP);
System.out.println("System Average Throughput Excluding Min/Max: " + val);
- xmlFileWriter.println("<prop key='" + KEY_SYS_AVE_EMM_TP + "'>" + val + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_AVE_EMM_TP + "'>" + val + "</prop>");
- val = (String)summary.get(KEY_SYS_AVE_CLIENT_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_TP);
System.out.println("System Average Client Throughput: " + val);
- xmlFileWriter.println("<prop key='" + KEY_SYS_AVE_CLIENT_TP + "'>" + val + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_TP + "'>" + val + "</prop>");
- val = (String)summary.get(KEY_SYS_AVE_CLIENT_EMM_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_EMM_TP);
System.out.println("System Average Client Throughput Excluding Min/Max: " + val);
- xmlFileWriter.println("<prop key='" + KEY_SYS_AVE_CLIENT_EMM_TP + "'>" + val + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_EMM_TP + "'>" + val + "</prop>");
- val = (String)summary.get(KEY_MIN_CLIENT_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_TP);
clientName = val.substring(0, val.indexOf("="));
clientVal = val.substring(val.indexOf("=") + 1);
System.out.println("Min Client Throughput Per Sample: clientName=" + clientName + ", value=" + clientVal);
- xmlFileWriter.println("<prop key='" + KEY_MIN_CLIENT_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_MIN_CLIENT_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
- val = (String)summary.get(KEY_MAX_CLIENT_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_TP);
clientName = val.substring(0, val.indexOf("="));
clientVal = val.substring(val.indexOf("=") + 1);
System.out.println("Max Client Throughput Per Sample: clientName=" + clientName + ", value=" + clientVal);
- xmlFileWriter.println("<prop key='" + KEY_MAX_CLIENT_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_MAX_CLIENT_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
- val = (String)summary.get(KEY_MIN_CLIENT_TOTAL_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_TOTAL_TP);
clientName = val.substring(0, val.indexOf("="));
clientVal = val.substring(val.indexOf("=") + 1);
System.out.println("Min Client Total Throughput: clientName=" + clientName + ", value=" + clientVal);
- xmlFileWriter.println("<prop key='" + KEY_MIN_CLIENT_TOTAL_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_MIN_CLIENT_TOTAL_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
- val = (String)summary.get(KEY_MAX_CLIENT_TOTAL_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_TOTAL_TP);
clientName = val.substring(0, val.indexOf("="));
clientVal = val.substring(val.indexOf("=") + 1);
System.out.println("Max Client Total Throughput: clientName=" + clientName + ", value=" + clientVal);
- xmlFileWriter.println("<prop key='" + KEY_MAX_CLIENT_TOTAL_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_MAX_CLIENT_TOTAL_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
- val = (String)summary.get(KEY_MIN_CLIENT_AVE_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_TP);
clientName = val.substring(0, val.indexOf("="));
clientVal = val.substring(val.indexOf("=") + 1);
System.out.println("Min Average Client Throughput: clientName=" + clientName + ", value=" + clientVal);
- xmlFileWriter.println("<prop key='" + KEY_MIN_CLIENT_AVE_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
- val = (String)summary.get(KEY_MAX_CLIENT_AVE_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_TP);
clientName = val.substring(0, val.indexOf("="));
clientVal = val.substring(val.indexOf("=") + 1);
System.out.println("Max Average Client Throughput: clientName=" + clientName + ", value=" + clientVal);
- xmlFileWriter.println("<prop key='" + KEY_MAX_CLIENT_AVE_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
- val = (String)summary.get(KEY_MIN_CLIENT_AVE_EMM_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_EMM_TP);
clientName = val.substring(0, val.indexOf("="));
clientVal = val.substring(val.indexOf("=") + 1);
System.out.println("Min Average Client Throughput Excluding Min/Max: clientName=" + clientName + ", value=" + clientVal);
- xmlFileWriter.println("<prop key='" + KEY_MIN_CLIENT_AVE_EMM_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_EMM_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
- val = (String)summary.get(KEY_MAX_CLIENT_AVE_EMM_TP);
+ val = (String)summary.get(ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_EMM_TP);
clientName = val.substring(0, val.indexOf("="));
clientVal = val.substring(val.indexOf("=") + 1);
System.out.println("Max Average Client Throughput Excluding Min/Max: clientName=" + clientName + ", value=" + clientVal);
- xmlFileWriter.println("<prop key='" + KEY_MAX_CLIENT_AVE_EMM_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_EMM_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
xmlFileWriter.println("</props>");
xmlFileWriter.println("</property>");
@@ -295,26 +311,19 @@
xmlFileWriter.println("</property>");
}
- protected void parsePerfCsvData(String csvData) {
+ protected void parsePerfCsvData(String elementName, String csvData) {
StringTokenizer tokenizer = new StringTokenizer(csvData, ",");
- String data, key, val, clientName = null;
- Long throughput = null;
- int index = -1;
+ String xmlElement;
+
+ xmlElement = "<" + elementName;
+ String data, key, val;
while (tokenizer.hasMoreTokens()) {
data = tokenizer.nextToken();
key = data.substring(0, data.indexOf("="));
val = data.substring(data.indexOf("=") + 1);
-
- if (key.equalsIgnoreCase("clientName")) {
- clientName = val;
- } else if (key.equalsIgnoreCase("throughput")) {
- throughput = Long.valueOf(val);
- } else if (key.equalsIgnoreCase("index")) {
- index = Integer.parseInt(val);
- }
+ xmlElement += (" " + key + "='" + val + "'");
}
- addToClientTPList(clientName, throughput);
- xmlFileWriter.println("<value index='" + index + "' clientName='" + clientName +
- "'>" + throughput.longValue() + "</value>");
+ xmlElement += " />";
+ xmlFileWriter.println(xmlElement);
}
}
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/CpuReportPlugin.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/CpuReportPlugin.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/CpuReportPlugin.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/CpuReportPlugin.java Thu Jun 22 18:53:48 2006
@@ -0,0 +1,29 @@
+/**
+ *
+ * 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.reports.plugins;
+
+import java.util.Map;
+
+public class CpuReportPlugin implements ReportPlugin {
+ public void handleCsvData(String csvData) {
+ // Do nothing
+ }
+
+ public Map getSummary() {
+ return null; // Do nothing
+ }
+}
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ReportPlugin.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ReportPlugin.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ReportPlugin.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ReportPlugin.java Thu Jun 22 18:53:48 2006
@@ -0,0 +1,27 @@
+/**
+ *
+ * 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.reports.plugins;
+
+import java.util.Map;
+
+public interface ReportPlugin {
+ public static final int REPORT_PLUGIN_THROUGHPUT = 0;
+ public static final int REPORT_PLUGIN_CPU = 1;
+
+ public void handleCsvData(String csvData);
+ public Map getSummary();
+}
Added: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ThroughputReportPlugin.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ThroughputReportPlugin.java?rev=416542&view=auto
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ThroughputReportPlugin.java (added)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ThroughputReportPlugin.java Thu Jun 22 18:53:48 2006
@@ -0,0 +1,182 @@
+/**
+ *
+ * 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.reports.plugins;
+
+import org.apache.activemq.tool.reports.PerformanceStatisticsUtil;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.Iterator;
+
+public class ThroughputReportPlugin implements ReportPlugin {
+ public static final String KEY_SYS_TOTAL_TP = "SystemTotalTP";
+ public static final String KEY_SYS_TOTAL_CLIENTS = "SystemTotalClients";
+ public static final String KEY_SYS_AVE_TP = "SystemAveTP";
+ public static final String KEY_SYS_AVE_EMM_TP = "SystemAveEMMTP";
+ public static final String KEY_SYS_AVE_CLIENT_TP = "SystemAveClientTP";
+ public static final String KEY_SYS_AVE_CLIENT_EMM_TP = "SystemAveClientEMMTP";
+ public static final String KEY_MIN_CLIENT_TP = "MinClientTP";
+ public static final String KEY_MAX_CLIENT_TP = "MaxClientTP";
+ public static final String KEY_MIN_CLIENT_TOTAL_TP = "MinClientTotalTP";
+ public static final String KEY_MAX_CLIENT_TOTAL_TP = "MaxClientTotalTP";
+ public static final String KEY_MIN_CLIENT_AVE_TP = "MinClientAveTP";
+ public static final String KEY_MAX_CLIENT_AVE_TP = "MaxClientAveTP";
+ public static final String KEY_MIN_CLIENT_AVE_EMM_TP = "MinClientAveEMMTP";
+ public static final String KEY_MAX_CLIENT_AVE_EMM_TP = "MaxClientAveEMMTP";
+
+ protected Map clientThroughputs = new HashMap();
+
+ public void handleCsvData(String csvData) {
+ StringTokenizer tokenizer = new StringTokenizer(csvData, ",");
+ String data, key, val, clientName = null;
+ Long throughput = null;
+ while (tokenizer.hasMoreTokens()) {
+ data = tokenizer.nextToken();
+ key = data.substring(0, data.indexOf("="));
+ val = data.substring(data.indexOf("=") + 1);
+
+ if (key.equalsIgnoreCase("clientName")) {
+ clientName = val;
+ } else if (key.equalsIgnoreCase("throughput")) {
+ throughput = Long.valueOf(val);
+ } else {
+ // Ignore unknown token
+ }
+ }
+ addToClientTPList(clientName, throughput);
+ }
+
+ public Map getSummary() {
+ long minClientTP = Long.MAX_VALUE, // TP = throughput
+ maxClientTP = Long.MIN_VALUE,
+ minClientTotalTP = Long.MAX_VALUE,
+ maxClientTotalTP = Long.MIN_VALUE,
+ systemTotalTP = 0;
+
+ double minClientAveTP = Double.MAX_VALUE,
+ maxClientAveTP = Double.MIN_VALUE,
+ minClientAveEMMTP = Double.MAX_VALUE, // EMM = Excluding Min/Max
+ maxClientAveEMMTP = Double.MIN_VALUE,
+ systemAveTP = 0.0,
+ systemAveEMMTP = 0.0;
+
+ String nameMinClientTP = "",
+ nameMaxClientTP = "",
+ nameMinClientTotalTP = "",
+ nameMaxClientTotalTP = "",
+ nameMinClientAveTP = "",
+ nameMaxClientAveTP = "",
+ nameMinClientAveEMMTP = "",
+ nameMaxClientAveEMMTP = "";
+
+ Set clientNames = clientThroughputs.keySet();
+ String clientName;
+ List clientTPList;
+ long tempLong;
+ double tempDouble;
+ int clientCount = 0;
+ for (Iterator i=clientNames.iterator(); i.hasNext();) {
+ clientName = (String)i.next();
+ clientTPList = (List)clientThroughputs.get(clientName);
+ clientCount++;
+
+ tempLong = PerformanceStatisticsUtil.getMinThroughput(clientTPList);
+ if (tempLong < minClientTP) {
+ minClientTP = tempLong;
+ nameMinClientTP = clientName;
+ }
+
+ tempLong = PerformanceStatisticsUtil.getMaxThroughput(clientTPList);
+ if (tempLong > maxClientTP) {
+ maxClientTP = tempLong;
+ nameMaxClientTP = clientName;
+ }
+
+ tempLong = PerformanceStatisticsUtil.getTotalThroughput(clientTPList);
+ systemTotalTP += tempLong; // Accumulate total TP
+ if (tempLong < minClientTotalTP) {
+ minClientTotalTP = tempLong;
+ nameMinClientTotalTP = clientName;
+ }
+
+ if (tempLong > maxClientTotalTP) {
+ maxClientTotalTP = tempLong;
+ nameMaxClientTotalTP = clientName;
+ }
+
+ tempDouble = PerformanceStatisticsUtil.getAveThroughput(clientTPList);
+ systemAveTP += tempDouble; // Accumulate ave throughput
+ if (tempDouble < minClientAveTP) {
+ minClientAveTP = tempDouble;
+ nameMinClientAveTP = clientName;
+ }
+
+ if (tempDouble > maxClientAveTP) {
+ maxClientAveTP = tempDouble;
+ nameMaxClientAveTP = clientName;
+ }
+
+ tempDouble = PerformanceStatisticsUtil.getAveThroughputExcludingMinMax(clientTPList);
+ systemAveEMMTP += tempDouble; // Accumulate ave throughput excluding min/max
+ if (tempDouble < minClientAveEMMTP) {
+ minClientAveEMMTP = tempDouble;
+ nameMinClientAveEMMTP = clientName;
+ }
+
+ if (tempDouble > maxClientAveEMMTP) {
+ maxClientAveEMMTP = tempDouble;
+ nameMaxClientAveEMMTP = clientName;
+ }
+ }
+
+ Map summary = new HashMap();
+ summary.put(KEY_SYS_TOTAL_TP, String.valueOf(systemTotalTP));
+ summary.put(KEY_SYS_TOTAL_CLIENTS, String.valueOf(clientCount));
+ summary.put(KEY_SYS_AVE_TP, String.valueOf(systemAveTP));
+ summary.put(KEY_SYS_AVE_EMM_TP, String.valueOf(systemAveEMMTP));
+ summary.put(KEY_SYS_AVE_CLIENT_TP, String.valueOf(systemAveTP / clientCount));
+ summary.put(KEY_SYS_AVE_CLIENT_EMM_TP, String.valueOf(systemAveEMMTP / clientCount));
+ summary.put(KEY_MIN_CLIENT_TP, nameMinClientTP + "=" + minClientTP);
+ summary.put(KEY_MAX_CLIENT_TP, nameMaxClientTP + "=" + maxClientTP);
+ summary.put(KEY_MIN_CLIENT_TOTAL_TP, nameMinClientTotalTP + "=" + minClientTotalTP);
+ summary.put(KEY_MAX_CLIENT_TOTAL_TP, nameMaxClientTotalTP + "=" + maxClientTotalTP);
+ summary.put(KEY_MIN_CLIENT_AVE_TP, nameMinClientAveTP + "=" + minClientAveTP);
+ summary.put(KEY_MAX_CLIENT_AVE_TP, nameMaxClientAveTP + "=" + maxClientAveTP);
+ summary.put(KEY_MIN_CLIENT_AVE_EMM_TP, nameMinClientAveEMMTP + "=" + minClientAveEMMTP);
+ summary.put(KEY_MAX_CLIENT_AVE_EMM_TP, nameMaxClientAveEMMTP + "=" + maxClientAveEMMTP);
+
+ return summary;
+ }
+
+ protected void addToClientTPList(String clientName, Long throughput) {
+ // Write to client's throughput list
+ if (clientName == null || throughput == null) {
+ throw new IllegalArgumentException("Invalid Throughput CSV Data: clientName=" + clientName + ", throughput=" + throughput);
+ }
+
+ List clientTPList = (List)clientThroughputs.get(clientName);
+ if (clientTPList == null) {
+ clientTPList = new ArrayList();
+ clientThroughputs.put(clientName, clientTPList);
+ }
+ clientTPList.add(throughput);
+ }
+}
Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/spi/ClassLoaderSPIConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/spi/ClassLoaderSPIConnectionFactory.java?rev=416542&r1=416541&r2=416542&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/spi/ClassLoaderSPIConnectionFactory.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/spi/ClassLoaderSPIConnectionFactory.java Thu Jun 22 18:53:48 2006
@@ -16,7 +16,7 @@
*/
package org.apache.activemq.tool.spi;
-import org.apache.activemq.tool.ReflectionUtil;
+import org.apache.activemq.tool.properties.ReflectionUtil;
import javax.jms.ConnectionFactory;
import java.util.Properties;
Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/tool/ReflectionUtilTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/tool/ReflectionUtilTest.java?rev=416542&r1=416541&r2=416542&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/tool/ReflectionUtilTest.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/test/java/org/apache/activemq/tool/ReflectionUtilTest.java Thu Jun 22 18:53:48 2006
@@ -20,170 +20,251 @@
import java.util.Properties;
+import org.apache.activemq.tool.properties.ReflectionUtil;
+
public class ReflectionUtilTest extends TestCase {
- private boolean booleanData;
- private int intData;
- private long longData;
- private short shortData;
- private double doubleData;
- private float floatData;
- private byte byteData;
- private char charData;
- private String stringData;
private ReflectionUtilTest testData;
+ private String data;
public void testDataTypeConfig() {
- // Initialize variables;
- booleanData = false;
- intData = 0;
- longData = 0;
- shortData = 0;
- doubleData = 0.0;
- floatData = 0.0F;
- byteData = 0;
- charData = '0';
- stringData = "false";
+ TestClass3 targetObj = new TestClass3();
- Object targetObj = new ReflectionUtilTest();
+ // Initialize variables;
+ targetObj.setBooleanData(false);
+ targetObj.setIntData(0);
+ targetObj.setLongData(0);
+ targetObj.setShortData((short)0);
+ targetObj.setDoubleData(0.0);
+ targetObj.setFloatData(0.0F);
+ targetObj.setByteData((byte)0);
+ targetObj.setCharData('0');
+ targetObj.setStringData("false");
// Set properties
Properties props = new Properties();
- props.setProperty("test.booleanData", "true");
- props.setProperty("test.intData", "1000");
- props.setProperty("test.longData", "2000");
- props.setProperty("test.shortData", "3000");
- props.setProperty("test.doubleData", "1234.567");
- props.setProperty("test.floatData", "9876.543");
- props.setProperty("test.byteData", "127");
- props.setProperty("test.charData", "A");
- props.setProperty("test.stringData", "true");
- props.setProperty("test.testData", "TEST.FOO.BAR");
+ props.setProperty("booleanData", "true");
+ props.setProperty("intData", "1000");
+ props.setProperty("longData", "2000");
+ props.setProperty("shortData", "3000");
+ props.setProperty("doubleData", "1234.567");
+ props.setProperty("floatData", "9876.543");
+ props.setProperty("byteData", "127");
+ props.setProperty("charData", "A");
+ props.setProperty("stringData", "true");
ReflectionUtil.configureClass(targetObj, props);
// Check config
- assertEquals(true, ((ReflectionUtilTest)targetObj).isBooleanData());
- assertEquals(1000, ((ReflectionUtilTest)targetObj).getIntData());
- assertEquals(2000, ((ReflectionUtilTest)targetObj).getLongData());
- assertEquals(3000, ((ReflectionUtilTest)targetObj).getShortData());
- assertEquals(1234.567, ((ReflectionUtilTest)targetObj).getDoubleData(), 0.0001);
- assertEquals(9876.543, ((ReflectionUtilTest)targetObj).getFloatData(), 0.0001);
- assertEquals(127, ((ReflectionUtilTest)targetObj).getByteData());
- assertEquals('A', ((ReflectionUtilTest)targetObj).getCharData());
- assertEquals("true", ((ReflectionUtilTest)targetObj).getStringData());
- assertEquals("TEST.FOO.BAR", ((ReflectionUtilTest)targetObj).getTestData().getStringData());
+ assertEquals(true, targetObj.isBooleanData());
+ assertEquals(1000, targetObj.getIntData());
+ assertEquals(2000, targetObj.getLongData());
+ assertEquals(3000, targetObj.getShortData());
+ assertEquals(1234.567, targetObj.getDoubleData(), 0.0001);
+ assertEquals(9876.543, targetObj.getFloatData(), 0.0001);
+ assertEquals(127, targetObj.getByteData());
+ assertEquals('A', targetObj.getCharData());
+ assertEquals("true", targetObj.getStringData());
+ }
+
+ public void testValueOfMethod() {
+ ReflectionUtilTest targetObj = new ReflectionUtilTest();
+
+ ReflectionUtil.configureClass(targetObj, "testData", "TEST.FOO.BAR");
+
+ assertEquals("TEST.FOO.BAR", targetObj.testData.data);
+ }
+
+ public void testGetProperties() {
+
+ TestClass3 testData = new TestClass3();
+ testData.setBooleanData(false);
+ testData.setByteData((byte)15);
+ testData.setCharData('G');
+ testData.setDoubleData(765.43);
+ testData.setFloatData(543.21F);
+ testData.setIntData(654321);
+ testData.setLongData(987654321);
+ testData.setShortData((short)4321);
+ testData.setStringData("BAR.TEST.FOO");
+
+ TestClass3 targetObj = new TestClass3();
+ targetObj.setBooleanData(true);
+ targetObj.setByteData((byte)10);
+ targetObj.setCharData('D');
+ targetObj.setDoubleData(1234.567);
+ targetObj.setFloatData(4567.89F);
+ targetObj.setIntData(123456);
+ targetObj.setLongData(1234567890);
+ targetObj.setShortData((short)1234);
+ targetObj.setStringData("Test.FOO.BAR");
+ targetObj.setTestData(testData);
+
+ Properties p = ReflectionUtil.retrieveObjectProperties(targetObj);
+ assertEquals("false", p.getProperty("testData.booleanData"));
+ assertEquals("15", p.getProperty("testData.byteData"));
+ assertEquals("G", p.getProperty("testData.charData"));
+ assertEquals("765.43", p.getProperty("testData.doubleData"));
+ assertEquals("543.21", p.getProperty("testData.floatData"));
+ assertEquals("654321", p.getProperty("testData.intData"));
+ assertEquals("987654321", p.getProperty("testData.longData"));
+ assertEquals("4321", p.getProperty("testData.shortData"));
+ assertEquals("BAR.TEST.FOO", p.getProperty("testData.stringData"));
+ assertEquals("true", p.getProperty("booleanData"));
+ assertEquals("10", p.getProperty("byteData"));
+ assertEquals("D", p.getProperty("charData"));
+ assertEquals("1234.567", p.getProperty("doubleData"));
+ assertEquals("4567.89", p.getProperty("floatData"));
+ assertEquals("123456", p.getProperty("intData"));
+ assertEquals("1234567890", p.getProperty("longData"));
+ assertEquals("1234", p.getProperty("shortData"));
+ assertEquals("Test.FOO.BAR", p.getProperty("stringData"));
}
public void testNestedConfig() {
- ReflectionUtilTest t1 = new ReflectionUtilTest();
- ReflectionUtilTest t2 = new ReflectionUtilTest();
- ReflectionUtilTest t3 = new ReflectionUtilTest();
- ReflectionUtilTest t4 = new ReflectionUtilTest();
- ReflectionUtilTest t5 = new ReflectionUtilTest();
+ TestClass3 t1 = new TestClass3();
+ TestClass3 t2 = new TestClass3();
+ TestClass3 t3 = new TestClass3();
+ TestClass3 t4 = new TestClass3();
+ TestClass3 t5 = new TestClass3();
- ReflectionUtil.configureClass(t1, "test.stringData", "t1");
+ ReflectionUtil.configureClass(t1, "stringData", "t1");
assertEquals("t1", t1.getStringData());
t1.setTestData(t2);
- ReflectionUtil.configureClass(t1, "test.testData.stringData", "t2");
+ ReflectionUtil.configureClass(t1, "testData.stringData", "t2");
assertEquals("t2", t2.getStringData());
t2.setTestData(t3);
- ReflectionUtil.configureClass(t1, "test.testData.testData.stringData", "t3");
+ ReflectionUtil.configureClass(t1, "testData.testData.stringData", "t3");
assertEquals("t3", t3.getStringData());
t3.setTestData(t4);
- ReflectionUtil.configureClass(t1, "test.testData.testData.testData.stringData", "t4");
+ ReflectionUtil.configureClass(t1, "testData.testData.testData.stringData", "t4");
assertEquals("t4", t4.getStringData());
t4.setTestData(t5);
- ReflectionUtil.configureClass(t1, "test.testData.testData.testData.testData.stringData", "t5");
+ ReflectionUtil.configureClass(t1, "testData.testData.testData.testData.stringData", "t5");
assertEquals("t5", t5.getStringData());
}
- public boolean isBooleanData() {
- return booleanData;
+ public static ReflectionUtilTest valueOf(String data) {
+ ReflectionUtilTest test = new ReflectionUtilTest();
+ test.data = data;
+ return test;
}
- public void setBooleanData(boolean booleanData) {
- this.booleanData = booleanData;
+ public ReflectionUtilTest getTestData() {
+ return testData;
}
- public int getIntData() {
- return intData;
+ public void setTestData(ReflectionUtilTest testData) {
+ this.testData = testData;
}
- public void setIntData(int intData) {
- this.intData = intData;
+ public String getData() {
+ return data;
}
- public long getLongData() {
- return longData;
+ public void setData(String data) {
+ this.data = data;
}
- public void setLongData(long longData) {
- this.longData = longData;
- }
+ public class TestClass1 {
+ private boolean booleanData;
+ private int intData;
+ private long longData;
- public short getShortData() {
- return shortData;
- }
+ public boolean isBooleanData() {
+ return booleanData;
+ }
- public void setShortData(short shortData) {
- this.shortData = shortData;
- }
+ public void setBooleanData(boolean booleanData) {
+ this.booleanData = booleanData;
+ }
- public double getDoubleData() {
- return doubleData;
- }
+ public int getIntData() {
+ return intData;
+ }
- public void setDoubleData(double doubleData) {
- this.doubleData = doubleData;
- }
+ public void setIntData(int intData) {
+ this.intData = intData;
+ }
- public float getFloatData() {
- return floatData;
- }
+ public long getLongData() {
+ return longData;
+ }
- public void setFloatData(float floatData) {
- this.floatData = floatData;
+ public void setLongData(long longData) {
+ this.longData = longData;
+ }
}
- public byte getByteData() {
- return byteData;
- }
+ public class TestClass2 extends TestClass1 {
+ private float floatData;
+ private byte byteData;
+ private char charData;
- public void setByteData(byte byteData) {
- this.byteData = byteData;
- }
+ public float getFloatData() {
+ return floatData;
+ }
- public char getCharData() {
- return charData;
- }
+ public void setFloatData(float floatData) {
+ this.floatData = floatData;
+ }
- public void setCharData(char charData) {
- this.charData = charData;
- }
+ public byte getByteData() {
+ return byteData;
+ }
- public String getStringData() {
- return stringData;
- }
+ public void setByteData(byte byteData) {
+ this.byteData = byteData;
+ }
- public void setStringData(String stringData) {
- this.stringData = stringData;
- }
+ public char getCharData() {
+ return charData;
+ }
- public ReflectionUtilTest getTestData() {
- return testData;
+ public void setCharData(char charData) {
+ this.charData = charData;
+ }
}
- public void setTestData(ReflectionUtilTest testData) {
- this.testData = testData;
- }
+ public class TestClass3 extends TestClass2 {
+ private short shortData;
+ private double doubleData;
+ private String stringData;
+ private TestClass3 testData;
- public static ReflectionUtilTest valueOf(String data) {
- ReflectionUtilTest obj = new ReflectionUtilTest();
- obj.setStringData(data);
- return obj;
+ public short getShortData() {
+ return shortData;
+ }
+
+ public void setShortData(short shortData) {
+ this.shortData = shortData;
+ }
+
+ public double getDoubleData() {
+ return doubleData;
+ }
+
+ public void setDoubleData(double doubleData) {
+ this.doubleData = doubleData;
+ }
+
+ public String getStringData() {
+ return stringData;
+ }
+
+ public void setStringData(String stringData) {
+ this.stringData = stringData;
+ }
+
+ public TestClass3 getTestData() {
+ return testData;
+ }
+
+ public void setTestData(TestClass3 testData) {
+ this.testData = testData;
+ }
}
}