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 [5/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/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=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionUtil.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionUtil.java Wed Jul 5 15:30:19 2006
@@ -1,288 +1,288 @@
-/**
- * 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.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Constructor;
-
-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) {
- try {
- String debugInfo;
-
- Object target = obj;
- Class targetClass = obj.getClass();
-
- // DEBUG: Debugging Info
- debugInfo = "Invoking: " + targetClass.getName();
-
- StringTokenizer tokenizer = new StringTokenizer(key, ".");
- String keySubString = key;
- int tokenCount = tokenizer.countTokens();
-
- // For nested settings, get the object first. -1, do not count the last token
- for (int j=0; j<tokenCount-1; j++) {
- // Find getter method first
- String name = tokenizer.nextToken();
-
- // Check if the target object will accept the settings
- if (target instanceof ReflectionConfigurable && !((ReflectionConfigurable)target).acceptConfig(keySubString, val)) {
- return;
- } else {
- // This will reduce the key, so that it will be recognize by the next object. i.e.
- // Property name: factory.prefetchPolicy.queuePrefetch
- // Calling order: this.getFactory().prefetchPolicy().queuePrefetch();
- // If factory does not accept the config, it should be given prefetchPolicy.queuePrefetch as the key
- keySubString = keySubString.substring(name.length() + 1); // +1 to account for the '.'
- }
-
- 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();
- // Check if the target object will accept the settings
- if (target instanceof ReflectionConfigurable && !((ReflectionConfigurable)target).acceptConfig(property, val)) {
- return;
- }
-
- // Find setter method
- Method setterMethod = findSetterMethod(targetClass, property);
-
- // Get the first parameter type. This assumes that there is only one parameter.
- if (setterMethod == null) {
- throw new IllegalAccessException("Unable to find appropriate setter method signature for property: " + property);
- }
- Class paramType = setterMethod.getParameterTypes()[0];
-
- // Set primitive type
- debugInfo += ("." + setterMethod + "(" + paramType.getName() + ": " + val + ")");
- if (paramType.isPrimitive()) {
- if (paramType == Boolean.TYPE) {
- setterMethod.invoke(target, new Object[] {Boolean.valueOf(val)});
- } else if (paramType == Integer.TYPE) {
- setterMethod.invoke(target, new Object[] {Integer.valueOf(val)});
- } else if (paramType == Long.TYPE) {
- setterMethod.invoke(target, new Object[] {Long.valueOf(val)});
- } else if (paramType == Double.TYPE) {
- setterMethod.invoke(target, new Object[] {Double.valueOf(val)});
- } else if (paramType == Float.TYPE) {
- setterMethod.invoke(target, new Object[] {Float.valueOf(val)});
- } else if (paramType == Short.TYPE) {
- setterMethod.invoke(target, new Object[] {Short.valueOf(val)});
- } else if (paramType == Byte.TYPE) {
- setterMethod.invoke(target, new Object[] {Byte.valueOf(val)});
- } else if (paramType == Character.TYPE) {
- setterMethod.invoke(target, new Object[] {new Character(val.charAt(0))});
- }
- } else {
- // Set String type
- if (paramType == String.class) {
- setterMethod.invoke(target, new Object[] {val});
-
- // For unknown object type, try to create an instance of the object using a String constructor
- } else {
- Constructor c = paramType.getConstructor(new Class[] {String.class});
- Object paramObject = c.newInstance(new Object[] {val});
-
- setterMethod.invoke(target, new Object[] {paramObject});
- }
- }
- 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();
- Method[] getterMethods = findAllGetterMethods(targetClass);
- for (int i=0; i<getterMethods.length; i++) {
- try {
- String propertyName = getPropertyName(getterMethods[i].getName());
- Class retType = getterMethods[i].getReturnType();
-
- // If primitive or string type, return it
- if (retType.isPrimitive() || retType == String.class) {
- // Check for an appropriate setter method to consider it as a property
- if (findSetterMethod(targetClass, propertyName) != null) {
- Object val = null;
- try {
- val = getterMethods[i].invoke(targetObject, null);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- props.setProperty(prefix + propertyName, val + "");
- }
- } else {
- try {
- Object val = getterMethods[i].invoke(targetObject, null);
- if (val != null) {
- props.putAll(retrieveClassProperties(propertyName + ".", 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;
- }
- }
-
- private static Method findSetterMethod(Class targetClass, String propertyName) {
- String methodName = "set" + propertyName.substring(0,1).toUpperCase() + propertyName.substring(1);
-
- Method[] methods = targetClass.getMethods();
- for (int i=0; i<methods.length; i++) {
- if (methods[i].getName().equals(methodName) && isSetterMethod(methods[i])) {
- return methods[i];
- }
- }
- return null;
- }
-
- private static Method findGetterMethod(Class targetClass, String propertyName) {
- String methodName1 = "get" + propertyName.substring(0,1).toUpperCase() + propertyName.substring(1);
- String methodName2 = "is" + propertyName.substring(0,1).toUpperCase() + propertyName.substring(1);
-
- Method[] methods = targetClass.getMethods();
- for (int i=0; i<methods.length; i++) {
- if ((methods[i].getName().equals(methodName1) || methods[i].getName().equals(methodName2)) && isGetterMethod(methods[i])) {
- return methods[i];
- }
- }
- return null;
- }
-
- private static Method[] findAllGetterMethods(Class targetClass) {
- List getterMethods = new ArrayList();
- Method[] methods = targetClass.getMethods();
-
- for (int i=0; i<methods.length; i++) {
- if (isGetterMethod(methods[i])) {
- getterMethods.add(methods[i]);
- }
- }
-
- return (Method[])getterMethods.toArray(new Method[] {});
- }
-
- private static boolean isGetterMethod(Method method) {
- // Check method signature first
- // If 'get' method, must return a non-void value
- // If 'is' method, must return a boolean value
- // Both must have no parameters
- // Method must not belong to the Object class to prevent infinite loop
- return (((method.getName().startsWith("is") && method.getReturnType() == Boolean.TYPE) ||
- (method.getName().startsWith("get") && method.getReturnType() != Void.TYPE)) &&
- (method.getParameterTypes().length == 0) && method.getDeclaringClass() != Object.class);
- }
-
- private static boolean isSetterMethod(Method method) {
- // Check method signature first
- if (method.getName().startsWith("set") && method.getReturnType() == Void.TYPE) {
- Class[] paramType = method.getParameterTypes();
- // Check that it can only accept one parameter
- if (paramType.length == 1) {
- // Check if parameter is a primitive or can accept a String parameter
- if (paramType[0].isPrimitive() || paramType[0] == String.class) {
- return true;
- } else {
- // Check if object can accept a string as a constructor
- try {
- if (paramType[0].getConstructor(new Class[] {String.class}) != null) {
- return true;
- }
- } catch (NoSuchMethodException e) {
- // Do nothing
- }
- }
- }
- }
- return false;
- }
-
- private static String getPropertyName(String methodName) {
- String name;
- if (methodName.startsWith("get")) {
- name = methodName.substring(3);
- } else if (methodName.startsWith("set")) {
- name = methodName.substring(3);
- } else if (methodName.startsWith("is")) {
- name = methodName.substring(2);
- } else {
- name = "";
- }
-
- return name.substring(0,1).toLowerCase() + name.substring(1);
- }
-}
+/**
+ * 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.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Constructor;
+
+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) {
+ try {
+ String debugInfo;
+
+ Object target = obj;
+ Class targetClass = obj.getClass();
+
+ // DEBUG: Debugging Info
+ debugInfo = "Invoking: " + targetClass.getName();
+
+ StringTokenizer tokenizer = new StringTokenizer(key, ".");
+ String keySubString = key;
+ int tokenCount = tokenizer.countTokens();
+
+ // For nested settings, get the object first. -1, do not count the last token
+ for (int j=0; j<tokenCount-1; j++) {
+ // Find getter method first
+ String name = tokenizer.nextToken();
+
+ // Check if the target object will accept the settings
+ if (target instanceof ReflectionConfigurable && !((ReflectionConfigurable)target).acceptConfig(keySubString, val)) {
+ return;
+ } else {
+ // This will reduce the key, so that it will be recognize by the next object. i.e.
+ // Property name: factory.prefetchPolicy.queuePrefetch
+ // Calling order: this.getFactory().prefetchPolicy().queuePrefetch();
+ // If factory does not accept the config, it should be given prefetchPolicy.queuePrefetch as the key
+ keySubString = keySubString.substring(name.length() + 1); // +1 to account for the '.'
+ }
+
+ 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();
+ // Check if the target object will accept the settings
+ if (target instanceof ReflectionConfigurable && !((ReflectionConfigurable)target).acceptConfig(property, val)) {
+ return;
+ }
+
+ // Find setter method
+ Method setterMethod = findSetterMethod(targetClass, property);
+
+ // Get the first parameter type. This assumes that there is only one parameter.
+ if (setterMethod == null) {
+ throw new IllegalAccessException("Unable to find appropriate setter method signature for property: " + property);
+ }
+ Class paramType = setterMethod.getParameterTypes()[0];
+
+ // Set primitive type
+ debugInfo += ("." + setterMethod + "(" + paramType.getName() + ": " + val + ")");
+ if (paramType.isPrimitive()) {
+ if (paramType == Boolean.TYPE) {
+ setterMethod.invoke(target, new Object[] {Boolean.valueOf(val)});
+ } else if (paramType == Integer.TYPE) {
+ setterMethod.invoke(target, new Object[] {Integer.valueOf(val)});
+ } else if (paramType == Long.TYPE) {
+ setterMethod.invoke(target, new Object[] {Long.valueOf(val)});
+ } else if (paramType == Double.TYPE) {
+ setterMethod.invoke(target, new Object[] {Double.valueOf(val)});
+ } else if (paramType == Float.TYPE) {
+ setterMethod.invoke(target, new Object[] {Float.valueOf(val)});
+ } else if (paramType == Short.TYPE) {
+ setterMethod.invoke(target, new Object[] {Short.valueOf(val)});
+ } else if (paramType == Byte.TYPE) {
+ setterMethod.invoke(target, new Object[] {Byte.valueOf(val)});
+ } else if (paramType == Character.TYPE) {
+ setterMethod.invoke(target, new Object[] {new Character(val.charAt(0))});
+ }
+ } else {
+ // Set String type
+ if (paramType == String.class) {
+ setterMethod.invoke(target, new Object[] {val});
+
+ // For unknown object type, try to create an instance of the object using a String constructor
+ } else {
+ Constructor c = paramType.getConstructor(new Class[] {String.class});
+ Object paramObject = c.newInstance(new Object[] {val});
+
+ setterMethod.invoke(target, new Object[] {paramObject});
+ }
+ }
+ 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();
+ Method[] getterMethods = findAllGetterMethods(targetClass);
+ for (int i=0; i<getterMethods.length; i++) {
+ try {
+ String propertyName = getPropertyName(getterMethods[i].getName());
+ Class retType = getterMethods[i].getReturnType();
+
+ // If primitive or string type, return it
+ if (retType.isPrimitive() || retType == String.class) {
+ // Check for an appropriate setter method to consider it as a property
+ if (findSetterMethod(targetClass, propertyName) != null) {
+ Object val = null;
+ try {
+ val = getterMethods[i].invoke(targetObject, null);
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ props.setProperty(prefix + propertyName, val + "");
+ }
+ } else {
+ try {
+ Object val = getterMethods[i].invoke(targetObject, null);
+ if (val != null) {
+ props.putAll(retrieveClassProperties(propertyName + ".", 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;
+ }
+ }
+
+ private static Method findSetterMethod(Class targetClass, String propertyName) {
+ String methodName = "set" + propertyName.substring(0,1).toUpperCase() + propertyName.substring(1);
+
+ Method[] methods = targetClass.getMethods();
+ for (int i=0; i<methods.length; i++) {
+ if (methods[i].getName().equals(methodName) && isSetterMethod(methods[i])) {
+ return methods[i];
+ }
+ }
+ return null;
+ }
+
+ private static Method findGetterMethod(Class targetClass, String propertyName) {
+ String methodName1 = "get" + propertyName.substring(0,1).toUpperCase() + propertyName.substring(1);
+ String methodName2 = "is" + propertyName.substring(0,1).toUpperCase() + propertyName.substring(1);
+
+ Method[] methods = targetClass.getMethods();
+ for (int i=0; i<methods.length; i++) {
+ if ((methods[i].getName().equals(methodName1) || methods[i].getName().equals(methodName2)) && isGetterMethod(methods[i])) {
+ return methods[i];
+ }
+ }
+ return null;
+ }
+
+ private static Method[] findAllGetterMethods(Class targetClass) {
+ List getterMethods = new ArrayList();
+ Method[] methods = targetClass.getMethods();
+
+ for (int i=0; i<methods.length; i++) {
+ if (isGetterMethod(methods[i])) {
+ getterMethods.add(methods[i]);
+ }
+ }
+
+ return (Method[])getterMethods.toArray(new Method[] {});
+ }
+
+ private static boolean isGetterMethod(Method method) {
+ // Check method signature first
+ // If 'get' method, must return a non-void value
+ // If 'is' method, must return a boolean value
+ // Both must have no parameters
+ // Method must not belong to the Object class to prevent infinite loop
+ return (((method.getName().startsWith("is") && method.getReturnType() == Boolean.TYPE) ||
+ (method.getName().startsWith("get") && method.getReturnType() != Void.TYPE)) &&
+ (method.getParameterTypes().length == 0) && method.getDeclaringClass() != Object.class);
+ }
+
+ private static boolean isSetterMethod(Method method) {
+ // Check method signature first
+ if (method.getName().startsWith("set") && method.getReturnType() == Void.TYPE) {
+ Class[] paramType = method.getParameterTypes();
+ // Check that it can only accept one parameter
+ if (paramType.length == 1) {
+ // Check if parameter is a primitive or can accept a String parameter
+ if (paramType[0].isPrimitive() || paramType[0] == String.class) {
+ return true;
+ } else {
+ // Check if object can accept a string as a constructor
+ try {
+ if (paramType[0].getConstructor(new Class[] {String.class}) != null) {
+ return true;
+ }
+ } catch (NoSuchMethodException e) {
+ // Do nothing
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private static String getPropertyName(String methodName) {
+ String name;
+ if (methodName.startsWith("get")) {
+ name = methodName.substring(3);
+ } else if (methodName.startsWith("set")) {
+ name = methodName.substring(3);
+ } else if (methodName.startsWith("is")) {
+ name = methodName.substring(2);
+ } else {
+ name = "";
+ }
+
+ return name.substring(0,1).toLowerCase() + name.substring(1);
+ }
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/properties/ReflectionUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
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=419366&r1=419365&r2=419366&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 Wed Jul 5 15:30:19 2006
@@ -1,38 +1,38 @@
-/**
- *
- * 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;
-
-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.Map;
-
-public abstract class AbstractPerfReportWriter implements PerformanceReportWriter {
- protected ReportPlugin[] plugins = new ReportPlugin[] {
- new ThroughputReportPlugin(),
- new CpuReportPlugin()
- };
-
- protected void handleCsvData(int pluginType, String csvData) {
- plugins[pluginType].handleCsvData(csvData);
- }
-
- protected Map getSummary(int pluginType) {
- return plugins[pluginType].getSummary();
- }
-}
+/**
+ *
+ * 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;
+
+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.Map;
+
+public abstract class AbstractPerfReportWriter implements PerformanceReportWriter {
+ protected ReportPlugin[] plugins = new ReportPlugin[] {
+ new ThroughputReportPlugin(),
+ new CpuReportPlugin()
+ };
+
+ protected void handleCsvData(int pluginType, String csvData) {
+ plugins[pluginType].handleCsvData(csvData);
+ }
+
+ protected Map getSummary(int pluginType) {
+ return plugins[pluginType].getSummary();
+ }
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/AbstractPerfReportWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
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=419366&r1=419365&r2=419366&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 Wed Jul 5 15:30:19 2006
@@ -1,28 +1,28 @@
-/**
- *
- * 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;
-
-import java.util.Properties;
-
-public interface PerformanceReportWriter {
- public void openReportWriter();
- public void closeReportWriter();
- public void writeInfo(String info);
- public void writeCsvData(int csvType, String csvData);
- public void writeProperties(String header, Properties props);
- public void writeProperties(Properties props);
-}
+/**
+ *
+ * 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;
+
+import java.util.Properties;
+
+public interface PerformanceReportWriter {
+ public void openReportWriter();
+ public void closeReportWriter();
+ public void writeInfo(String info);
+ public void writeCsvData(int csvType, String csvData);
+ public void writeProperties(String header, Properties props);
+ public void writeProperties(Properties props);
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/PerformanceReportWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/PerformanceStatisticsUtil.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/PerformanceStatisticsUtil.java?rev=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/PerformanceStatisticsUtil.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/PerformanceStatisticsUtil.java Wed Jul 5 15:30:19 2006
@@ -1,100 +1,100 @@
-/**
- *
- * 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;
-
-import java.util.List;
-import java.util.Iterator;
-
-public final class PerformanceStatisticsUtil {
- private PerformanceStatisticsUtil() {
- }
-
- public static long getTotalThroughput(List totalTPList) {
- long totalTP = 0;
- if (totalTPList != null) {
- for (Iterator i=totalTPList.iterator(); i.hasNext();) {
- totalTP += ((Long)i.next()).longValue();
- }
- } else {
- totalTP = -1;
- }
- return totalTP;
- }
-
- public static long getMinThroughput(List totalTPList) {
- long minTP = Long.MAX_VALUE;
- if (totalTPList != null) {
- for (Iterator i=totalTPList.iterator(); i.hasNext();) {
- minTP = Math.min(((Long)i.next()).longValue(), minTP);
- }
- } else {
- minTP = -1;
- }
- return minTP;
- }
-
- public static long getMaxThroughput(List totalTPList) {
- long maxTP = Long.MIN_VALUE;
- if (totalTPList != null) {
- for (Iterator i=totalTPList.iterator(); i.hasNext();) {
- maxTP = Math.max(((Long)i.next()).longValue(), maxTP);
- }
- } else {
- maxTP = -1;
- }
- return maxTP;
- }
-
- public static double getAveThroughput(List totalTPList) {
- double aveTP;
- if (totalTPList != null) {
- int sampleCount = 0;
- long totalTP = 0;
- for (Iterator i=totalTPList.iterator(); i.hasNext();) {
- sampleCount++;
- totalTP += ((Long)i.next()).longValue();
- }
- return (double)totalTP / (double)sampleCount;
- } else {
- aveTP = -1;
- }
- return aveTP;
- }
-
- public static double getAveThroughputExcludingMinMax(List totalTPList) {
- double aveTP;
- long minTP = getMinThroughput(totalTPList);
- long maxTP = getMaxThroughput(totalTPList);
- if (totalTPList != null) {
- int sampleCount = 0;
- long totalTP = 0;
- long sampleTP;
- for (Iterator i=totalTPList.iterator(); i.hasNext();) {
- sampleCount++;
- sampleTP = ((Long)i.next()).longValue();
- if (sampleTP != minTP && sampleTP != maxTP) {
- totalTP += sampleTP;
- }
- }
- return (double)totalTP / (double)sampleCount;
- } else {
- aveTP = -1;
- }
- return aveTP;
- }
-
-}
+/**
+ *
+ * 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;
+
+import java.util.List;
+import java.util.Iterator;
+
+public final class PerformanceStatisticsUtil {
+ private PerformanceStatisticsUtil() {
+ }
+
+ public static long getTotalThroughput(List totalTPList) {
+ long totalTP = 0;
+ if (totalTPList != null) {
+ for (Iterator i=totalTPList.iterator(); i.hasNext();) {
+ totalTP += ((Long)i.next()).longValue();
+ }
+ } else {
+ totalTP = -1;
+ }
+ return totalTP;
+ }
+
+ public static long getMinThroughput(List totalTPList) {
+ long minTP = Long.MAX_VALUE;
+ if (totalTPList != null) {
+ for (Iterator i=totalTPList.iterator(); i.hasNext();) {
+ minTP = Math.min(((Long)i.next()).longValue(), minTP);
+ }
+ } else {
+ minTP = -1;
+ }
+ return minTP;
+ }
+
+ public static long getMaxThroughput(List totalTPList) {
+ long maxTP = Long.MIN_VALUE;
+ if (totalTPList != null) {
+ for (Iterator i=totalTPList.iterator(); i.hasNext();) {
+ maxTP = Math.max(((Long)i.next()).longValue(), maxTP);
+ }
+ } else {
+ maxTP = -1;
+ }
+ return maxTP;
+ }
+
+ public static double getAveThroughput(List totalTPList) {
+ double aveTP;
+ if (totalTPList != null) {
+ int sampleCount = 0;
+ long totalTP = 0;
+ for (Iterator i=totalTPList.iterator(); i.hasNext();) {
+ sampleCount++;
+ totalTP += ((Long)i.next()).longValue();
+ }
+ return (double)totalTP / (double)sampleCount;
+ } else {
+ aveTP = -1;
+ }
+ return aveTP;
+ }
+
+ public static double getAveThroughputExcludingMinMax(List totalTPList) {
+ double aveTP;
+ long minTP = getMinThroughput(totalTPList);
+ long maxTP = getMaxThroughput(totalTPList);
+ if (totalTPList != null) {
+ int sampleCount = 0;
+ long totalTP = 0;
+ long sampleTP;
+ for (Iterator i=totalTPList.iterator(); i.hasNext();) {
+ sampleCount++;
+ sampleTP = ((Long)i.next()).longValue();
+ if (sampleTP != minTP && sampleTP != maxTP) {
+ totalTP += sampleTP;
+ }
+ }
+ return (double)totalTP / (double)sampleCount;
+ } else {
+ aveTP = -1;
+ }
+ return aveTP;
+ }
+
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/PerformanceStatisticsUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
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=419366&r1=419365&r2=419366&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 Wed Jul 5 15:30:19 2006
@@ -1,93 +1,93 @@
-/**
- *
- * 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;
-
-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;
-import java.util.Arrays;
-
-public class VerbosePerfReportWriter extends AbstractPerfReportWriter {
-
- public void openReportWriter() {
- // Do nothing
- }
-
- public void closeReportWriter() {
- writeHeader("Performance Summary");
- writePerfSummary();
- }
-
- public void writeInfo(String info) {
- System.out.println("[PERF-INFO]: " + info);
- }
-
- 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) {
- writeHeader(header);
- writeProperties(props);
- }
-
- public void writeProperties(Properties props) {
- for (Iterator i=props.keySet().iterator(); i.hasNext();) {
- String key = (String)i.next();
- String val = props.getProperty(key, "");
- System.out.println("[PERF-PROP]: " + key + "=" + val);
- }
- }
-
- public void writePerfSummary() {
- 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(borderStr);
- System.out.println("# " + header + " #");
- System.out.println(borderStr);
- }
-
-}
+/**
+ *
+ * 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;
+
+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;
+import java.util.Arrays;
+
+public class VerbosePerfReportWriter extends AbstractPerfReportWriter {
+
+ public void openReportWriter() {
+ // Do nothing
+ }
+
+ public void closeReportWriter() {
+ writeHeader("Performance Summary");
+ writePerfSummary();
+ }
+
+ public void writeInfo(String info) {
+ System.out.println("[PERF-INFO]: " + info);
+ }
+
+ 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) {
+ writeHeader(header);
+ writeProperties(props);
+ }
+
+ public void writeProperties(Properties props) {
+ for (Iterator i=props.keySet().iterator(); i.hasNext();) {
+ String key = (String)i.next();
+ String val = props.getProperty(key, "");
+ System.out.println("[PERF-PROP]: " + key + "=" + val);
+ }
+ }
+
+ public void writePerfSummary() {
+ 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(borderStr);
+ System.out.println("# " + header + " #");
+ System.out.println(borderStr);
+ }
+
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/VerbosePerfReportWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
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=419366&r1=419365&r2=419366&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 Wed Jul 5 15:30:19 2006
@@ -1,329 +1,329 @@
-/**
- *
- * 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;
-
-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;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.StringTokenizer;
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.FileNotFoundException;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-public class XmlFilePerfReportWriter extends AbstractPerfReportWriter {
- private static final Log log = LogFactory.getLog(XmlFilePerfReportWriter.class);
-
- private File tempLogFile;
- private PrintWriter tempLogFileWriter;
-
- private File xmlFile;
- private PrintWriter xmlFileWriter;
-
- private String reportDir;
- private String reportName;
-
- private Map testPropsMap;
- private List testPropsList;
-
- public XmlFilePerfReportWriter() {
- this("", "PerformanceReport.xml");
- }
-
- public XmlFilePerfReportWriter(String reportDir, String reportName) {
- this.testPropsMap = new HashMap();
- this.testPropsList = new ArrayList();
- this.reportDir = reportDir;
- this.reportName = reportName;
- }
-
- public void openReportWriter() {
- if (tempLogFile == null) {
- tempLogFile = createTempLogFile();
- }
-
- try {
- // Disable auto-flush and allocate 100kb of buffer
- tempLogFileWriter = new PrintWriter(new BufferedOutputStream(new FileOutputStream(tempLogFile), 102400), false);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
-
- public void closeReportWriter() {
- // Flush and close log file writer
- tempLogFileWriter.flush();
- tempLogFileWriter.close();
-
- writeToXml();
- }
-
- 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 File getXmlFile() {
- return xmlFile;
- }
-
- public void setXmlFile(File xmlFile) {
- this.xmlFile = xmlFile;
- }
-
- public void writeInfo(String info) {
- tempLogFileWriter.println("[INFO]" + info);
- }
-
- 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) {
- testPropsMap.put(header, props);
- }
-
- public void writeProperties(Properties props) {
- testPropsList.add(props);
- }
-
- protected File createTempLogFile() {
- File f;
- try {
- f = File.createTempFile("tmpPL", null);
- } catch (IOException e) {
- f = new File("tmpPL" + System.currentTimeMillis() + ".tmp");
- }
- f.deleteOnExit();
- return f;
- }
-
- protected File createXmlFile() {
- String filename = (getReportName().endsWith(".xml") ? getReportName() : (getReportName() + ".xml"));
- String path = (getReportDir() == null) ? "" : getReportDir();
-
- return new File(path + filename);
- }
-
- protected void writeToXml() {
- try {
- xmlFile = createXmlFile();
- xmlFileWriter = new PrintWriter(new FileOutputStream(xmlFile));
- writeXmlHeader();
- writeXmlTestSettings();
- writeXmlLogFile();
- writeXmlPerfSummary();
- writeXmlFooter();
- xmlFileWriter.close();
-
- log.info("Created performance report: " + xmlFile.getAbsolutePath());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- protected void writeXmlHeader() {
- xmlFileWriter.println("<testResult>");
- }
-
- protected void writeXmlFooter() {
- xmlFileWriter.println("</testResult>");
- }
-
- protected void writeXmlTestSettings() {
- Properties props;
-
- // Write test settings
- for (Iterator i=testPropsMap.keySet().iterator(); i.hasNext();) {
- String key = (String)i.next();
- props = (Properties)testPropsMap.get(key);
- writeMap(key, props);
- }
-
- int count = 1;
- for (Iterator i=testPropsList.iterator(); i.hasNext();) {
- props = (Properties)i.next();
- writeMap("settings" + count++, props);
- }
- }
-
- protected void writeXmlLogFile() throws IOException {
- // Write throughput data
- xmlFileWriter.println("<property name='performanceData'>");
- xmlFileWriter.println("<list>");
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(tempLogFile)));
- String line;
- while ((line = reader.readLine()) != null) {
- 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("<info>" + line + "</info>");
- } else {
- xmlFileWriter.println("<error>" + line + "</error>");
- }
- }
-
- xmlFileWriter.println("</list>");
- xmlFileWriter.println("</property>");
- }
-
- protected void writeXmlPerfSummary() {
- // 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(ThroughputReportPlugin.KEY_SYS_TOTAL_TP);
- System.out.println("System Total Throughput: " + val);
- xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_TOTAL_TP + "'>" + val + "</prop>");
-
- val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_CLIENTS);
- System.out.println("System Total Clients: " + val);
- xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_TOTAL_CLIENTS + "'>" + val + "</prop>");
-
- val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_AVE_TP);
- System.out.println("System Average Throughput: " + val);
- xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_AVE_TP + "'>" + val + "</prop>");
-
- val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_AVE_EMM_TP);
- System.out.println("System Average Throughput Excluding Min/Max: " + val);
- xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_AVE_EMM_TP + "'>" + val + "</prop>");
-
- val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_TP);
- System.out.println("System Average Client Throughput: " + val);
- xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_TP + "'>" + val + "</prop>");
-
- 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='" + ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_EMM_TP + "'>" + val + "</prop>");
-
- 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='" + ThroughputReportPlugin.KEY_MIN_CLIENT_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
-
- 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='" + ThroughputReportPlugin.KEY_MAX_CLIENT_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
-
- 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='" + ThroughputReportPlugin.KEY_MIN_CLIENT_TOTAL_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
-
- 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='" + ThroughputReportPlugin.KEY_MAX_CLIENT_TOTAL_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
-
- 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='" + ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
-
- 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='" + ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
-
- 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='" + ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_EMM_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
-
- 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='" + ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_EMM_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
-
- xmlFileWriter.println("</props>");
- xmlFileWriter.println("</property>");
- }
-
- protected void writeMap(String name, Map map) {
- xmlFileWriter.println("<property name='" + name + "'>");
- xmlFileWriter.println("<props>");
- for (Iterator i=map.keySet().iterator(); i.hasNext();) {
- String propKey = (String)i.next();
- Object propVal = map.get(propKey);
- xmlFileWriter.println("<prop key='" + propKey + "'>" + propVal.toString() + "</prop>");
- }
- xmlFileWriter.println("</props>");
- xmlFileWriter.println("</property>");
- }
-
- protected void parsePerfCsvData(String elementName, String csvData) {
- StringTokenizer tokenizer = new StringTokenizer(csvData, ",;");
- 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);
- xmlElement += (" " + key + "='" + val + "'");
- }
- xmlElement += " />";
- xmlFileWriter.println(xmlElement);
- }
-}
+/**
+ *
+ * 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;
+
+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;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+import java.io.File;
+import java.io.PrintWriter;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.FileNotFoundException;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+public class XmlFilePerfReportWriter extends AbstractPerfReportWriter {
+ private static final Log log = LogFactory.getLog(XmlFilePerfReportWriter.class);
+
+ private File tempLogFile;
+ private PrintWriter tempLogFileWriter;
+
+ private File xmlFile;
+ private PrintWriter xmlFileWriter;
+
+ private String reportDir;
+ private String reportName;
+
+ private Map testPropsMap;
+ private List testPropsList;
+
+ public XmlFilePerfReportWriter() {
+ this("", "PerformanceReport.xml");
+ }
+
+ public XmlFilePerfReportWriter(String reportDir, String reportName) {
+ this.testPropsMap = new HashMap();
+ this.testPropsList = new ArrayList();
+ this.reportDir = reportDir;
+ this.reportName = reportName;
+ }
+
+ public void openReportWriter() {
+ if (tempLogFile == null) {
+ tempLogFile = createTempLogFile();
+ }
+
+ try {
+ // Disable auto-flush and allocate 100kb of buffer
+ tempLogFileWriter = new PrintWriter(new BufferedOutputStream(new FileOutputStream(tempLogFile), 102400), false);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void closeReportWriter() {
+ // Flush and close log file writer
+ tempLogFileWriter.flush();
+ tempLogFileWriter.close();
+
+ writeToXml();
+ }
+
+ 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 File getXmlFile() {
+ return xmlFile;
+ }
+
+ public void setXmlFile(File xmlFile) {
+ this.xmlFile = xmlFile;
+ }
+
+ public void writeInfo(String info) {
+ tempLogFileWriter.println("[INFO]" + info);
+ }
+
+ 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) {
+ testPropsMap.put(header, props);
+ }
+
+ public void writeProperties(Properties props) {
+ testPropsList.add(props);
+ }
+
+ protected File createTempLogFile() {
+ File f;
+ try {
+ f = File.createTempFile("tmpPL", null);
+ } catch (IOException e) {
+ f = new File("tmpPL" + System.currentTimeMillis() + ".tmp");
+ }
+ f.deleteOnExit();
+ return f;
+ }
+
+ protected File createXmlFile() {
+ String filename = (getReportName().endsWith(".xml") ? getReportName() : (getReportName() + ".xml"));
+ String path = (getReportDir() == null) ? "" : getReportDir();
+
+ return new File(path + filename);
+ }
+
+ protected void writeToXml() {
+ try {
+ xmlFile = createXmlFile();
+ xmlFileWriter = new PrintWriter(new FileOutputStream(xmlFile));
+ writeXmlHeader();
+ writeXmlTestSettings();
+ writeXmlLogFile();
+ writeXmlPerfSummary();
+ writeXmlFooter();
+ xmlFileWriter.close();
+
+ log.info("Created performance report: " + xmlFile.getAbsolutePath());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected void writeXmlHeader() {
+ xmlFileWriter.println("<testResult>");
+ }
+
+ protected void writeXmlFooter() {
+ xmlFileWriter.println("</testResult>");
+ }
+
+ protected void writeXmlTestSettings() {
+ Properties props;
+
+ // Write test settings
+ for (Iterator i=testPropsMap.keySet().iterator(); i.hasNext();) {
+ String key = (String)i.next();
+ props = (Properties)testPropsMap.get(key);
+ writeMap(key, props);
+ }
+
+ int count = 1;
+ for (Iterator i=testPropsList.iterator(); i.hasNext();) {
+ props = (Properties)i.next();
+ writeMap("settings" + count++, props);
+ }
+ }
+
+ protected void writeXmlLogFile() throws IOException {
+ // Write throughput data
+ xmlFileWriter.println("<property name='performanceData'>");
+ xmlFileWriter.println("<list>");
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(tempLogFile)));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ 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("<info>" + line + "</info>");
+ } else {
+ xmlFileWriter.println("<error>" + line + "</error>");
+ }
+ }
+
+ xmlFileWriter.println("</list>");
+ xmlFileWriter.println("</property>");
+ }
+
+ protected void writeXmlPerfSummary() {
+ // 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(ThroughputReportPlugin.KEY_SYS_TOTAL_TP);
+ System.out.println("System Total Throughput: " + val);
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_TOTAL_TP + "'>" + val + "</prop>");
+
+ val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_TOTAL_CLIENTS);
+ System.out.println("System Total Clients: " + val);
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_TOTAL_CLIENTS + "'>" + val + "</prop>");
+
+ val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_AVE_TP);
+ System.out.println("System Average Throughput: " + val);
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_AVE_TP + "'>" + val + "</prop>");
+
+ val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_AVE_EMM_TP);
+ System.out.println("System Average Throughput Excluding Min/Max: " + val);
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_AVE_EMM_TP + "'>" + val + "</prop>");
+
+ val = (String)summary.get(ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_TP);
+ System.out.println("System Average Client Throughput: " + val);
+ xmlFileWriter.println("<prop key='" + ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_TP + "'>" + val + "</prop>");
+
+ 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='" + ThroughputReportPlugin.KEY_SYS_AVE_CLIENT_EMM_TP + "'>" + val + "</prop>");
+
+ 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='" + ThroughputReportPlugin.KEY_MIN_CLIENT_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+
+ 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='" + ThroughputReportPlugin.KEY_MAX_CLIENT_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+
+ 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='" + ThroughputReportPlugin.KEY_MIN_CLIENT_TOTAL_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+
+ 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='" + ThroughputReportPlugin.KEY_MAX_CLIENT_TOTAL_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+
+ 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='" + ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+
+ 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='" + ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+
+ 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='" + ThroughputReportPlugin.KEY_MIN_CLIENT_AVE_EMM_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+
+ 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='" + ThroughputReportPlugin.KEY_MAX_CLIENT_AVE_EMM_TP + "'>clientName=" + clientName + ",value=" + clientVal + "</prop>");
+
+ xmlFileWriter.println("</props>");
+ xmlFileWriter.println("</property>");
+ }
+
+ protected void writeMap(String name, Map map) {
+ xmlFileWriter.println("<property name='" + name + "'>");
+ xmlFileWriter.println("<props>");
+ for (Iterator i=map.keySet().iterator(); i.hasNext();) {
+ String propKey = (String)i.next();
+ Object propVal = map.get(propKey);
+ xmlFileWriter.println("<prop key='" + propKey + "'>" + propVal.toString() + "</prop>");
+ }
+ xmlFileWriter.println("</props>");
+ xmlFileWriter.println("</property>");
+ }
+
+ protected void parsePerfCsvData(String elementName, String csvData) {
+ StringTokenizer tokenizer = new StringTokenizer(csvData, ",;");
+ 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);
+ xmlElement += (" " + key + "='" + val + "'");
+ }
+ xmlElement += " />";
+ xmlFileWriter.println(xmlElement);
+ }
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/XmlFilePerfReportWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/CpuReportPlugin.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/CpuReportPlugin.java Wed Jul 5 15:30:19 2006
@@ -1,29 +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
- }
-}
+/**
+ *
+ * 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
+ }
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/CpuReportPlugin.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: 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=419366&r1=419365&r2=419366&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ReportPlugin.java (original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ReportPlugin.java Wed Jul 5 15:30:19 2006
@@ -1,27 +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();
-}
+/**
+ *
+ * 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();
+}
Propchange: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/reports/plugins/ReportPlugin.java
------------------------------------------------------------------------------
svn:eol-style = native