You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by wo...@apache.org on 2005/11/05 06:34:53 UTC

svn commit: r330976 - in /jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter: report/DataSet.java report/ReportChart.java testelement/AbstractChart.java testelement/AbstractTable.java testelement/BarChart.java testelement/JTLData.java

Author: woolfel
Date: Fri Nov  4 21:34:48 2005
New Revision: 330976

URL: http://svn.apache.org/viewcvs?rev=330976&view=rev
Log:
checking in some changes and 2 new classes. one is a base
interface for dataset and the other is a base implementation.
peter

Added:
    jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/DataSet.java
    jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/JTLData.java
Modified:
    jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/ReportChart.java
    jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/AbstractChart.java
    jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/AbstractTable.java
    jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/BarChart.java

Added: jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/DataSet.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/DataSet.java?rev=330976&view=auto
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/DataSet.java (added)
+++ jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/DataSet.java Fri Nov  4 21:34:48 2005
@@ -0,0 +1,58 @@
+//$Header$
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.jmeter.report;
+
+import java.util.Date;
+import java.util.Set;
+
+import org.apache.jmeter.visualizers.SamplingStatCalculator;
+import org.apache.jmeter.visualizers.Visualizer;
+
+/**
+ * @author Peter Lin
+ *
+ * DataSet extends Visualizer so that it can be used with ResultCollector.
+ * Classes implementing the interface should create a new instance of
+ * ResultCollector and call setListener(Visualizer) passing itself.
+ * When the ResultCollector.loadExistingFile is called, it will pass
+ * the SampleResults.
+ */
+public interface DataSet extends Visualizer {
+
+    public void setPath(String absolutePath);
+    public String getPath();
+    public void setStartTimestamp(long stamp);
+    public long getStartTimestamp();
+    public void setEndTimestamp(long stamp);
+    public long getEndTimestamp();
+    public Date getDate();
+    public Set getURLs();
+    public Set getStats();
+    /**
+     * Return the SamplingStatCalculate for a specific URL.
+     * @param url
+     * @return
+     */
+    public SamplingStatCalculator getStatistics(String url);
+    /**
+     * Classes implementing the method should load the data from
+     * the target location. It doesn't necessarily have to be a
+     * file. It could be from a database.
+     */
+    public void loadData();
+}

Modified: jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/ReportChart.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/ReportChart.java?rev=330976&r1=330975&r2=330976&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/ReportChart.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/report/ReportChart.java Fri Nov  4 21:34:48 2005
@@ -21,5 +21,13 @@
 
 
 public interface ReportChart {
+    /**
+     * The idea is a report table will be passed to a ReportChart
+     * TestElement. The ReportChart is responsible for choosing which
+     * columns/rows it needs and generate a chart for it. The chart
+     * object is a JComponent.
+     * @param element
+     * @return
+     */
 	JComponent renderChart(ReportTable element);
 }

Modified: jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/AbstractChart.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/AbstractChart.java?rev=330976&r1=330975&r2=330976&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/AbstractChart.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/AbstractChart.java Fri Nov  4 21:34:48 2005
@@ -107,5 +107,12 @@
     	return checked;
     }
     
+    /**
+     * Subclasses will need to implement the method by doing the following:
+     * 1. get the x and y axis
+     * 2. filter the table data
+     * 3. pass the data to the chart library
+     * 4. return the generated chart
+     */
 	public abstract JComponent renderChart(ReportTable element);
 }

Modified: jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/AbstractTable.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/AbstractTable.java?rev=330976&r1=330975&r2=330976&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/AbstractTable.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/AbstractTable.java Fri Nov  4 21:34:48 2005
@@ -45,11 +45,11 @@
     	REPORT_TABLE_RESPONSE_RATE, REPORT_TABLE_TRANSFER_RATE, REPORT_TABLE_50_PERCENT,
     	REPORT_TABLE_90_PERCENT, REPORT_TABLE_ERROR_RATE };
 
-    public static final String REPORT_TABLE_FILE = "ReportTable.file";
     public static final String REPORT_TABLE_DATE = "ReportTable.test.date";
+    public static final String REPORT_TABLE_TOTAL = "ReportTable.total";
     public static final String REPORT_TABLE_URL = "ReportTable.url";
     
-    public static final String[] xitems = { REPORT_TABLE_FILE, REPORT_TABLE_DATE,
+    public static final String[] xitems = { REPORT_TABLE_DATE, REPORT_TABLE_TOTAL,
     	REPORT_TABLE_URL };
     
     protected ArrayList children = new ArrayList();
@@ -144,8 +144,9 @@
 	}
     
     /**
-     * method isn't implemented and is left as abstract. Subclasses
-     * need to provide concrete logic
+     * method isn't implemented and is left abstract. Subclasses
+     * need to filter the data in the list and return statistics.
+     * The statistics should be like the aggregate listener.
      */
     public abstract String[][] getTableData(List data);
     

Modified: jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/BarChart.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/BarChart.java?rev=330976&r1=330975&r2=330976&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/BarChart.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/BarChart.java Fri Nov  4 21:34:48 2005
@@ -33,6 +33,7 @@
 	}
 
 	public JComponent renderChart(ReportTable element) {
+        
 		return null;
 	}
 }

Added: jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/JTLData.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/JTLData.java?rev=330976&view=auto
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/JTLData.java (added)
+++ jakarta/jmeter/branches/rel-2-1/src/reports/org/apache/jmeter/testelement/JTLData.java Fri Nov  4 21:34:48 2005
@@ -0,0 +1,145 @@
+//$Header$
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+package org.apache.jmeter.testelement;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.jmeter.report.DataSet;
+import org.apache.jmeter.samplers.SampleResult;
+import org.apache.jmeter.visualizers.SamplingStatCalculator;
+
+/**
+ * @author Peter Lin
+ *
+ * The purpose of TableData is to contain the results of a single .jtl file.
+ * It is equivalent to what the AggregateListener table. A HashMap is used
+ * to store the data. The URL is the key and the value is SamplingStatCalculator
+ */
+public class JTLData implements Serializable, DataSet {
+
+    protected HashMap data = new HashMap();
+    protected String jtl_file = null;
+    protected long startTimestamp = 0;
+    protected long endTimestamp = 0;
+    
+	/**
+	 * 
+	 */
+	public JTLData() {
+		super();
+	}
+
+    /**
+     * Return a Set of the URL's
+     * @return
+     */
+    public Set getURLs() {
+        return this.data.keySet();
+    }
+    
+    /**
+     * Return a Set of the values
+     * @return
+     */
+    public Set getStats() {
+        return this.data.entrySet();
+    }
+    
+    /**
+     * The purpose of the method is to make it convienant to pass a list
+     * of the URL's and return a list of the SamplingStatCalculators. If
+     * no URL's match, the list is empty.
+     * @param urls
+     * @return
+     */
+    public List getStats(List urls) {
+        ArrayList items = new ArrayList();
+        // TODO implement the logic
+        return items;
+    }
+    
+    public void setPath(String absolutePath) {
+        this.jtl_file = absolutePath;
+    }
+    
+    public String getPath() {
+        return this.jtl_file;
+    }
+    
+    public void setStartTimestamp(long stamp) {
+        this.startTimestamp = stamp;
+    }
+    
+    public long getStartTimestamp() {
+        return this.startTimestamp;
+    }
+    
+    public void setEndTimestamp(long stamp) {
+        this.endTimestamp = stamp;
+    }
+    
+    public long getEndTimestamp() {
+        return this.endTimestamp;
+    }
+    
+    /**
+     * The date we use for the result is the start timestamp. The
+     * reasoning is that a test may run for a long time, but it
+     * is most likely scheduled to run using CRON on unix or
+     * scheduled task in windows.
+     * @return
+     */
+    public Date getDate() {
+        return new Date(this.startTimestamp);
+    }
+    
+    /**
+     * The method will SamplingStatCalculator for the given URL. If the URL
+     * doesn't exist, the method returns null.
+     * @param url
+     * @return
+     */
+    public SamplingStatCalculator getStatistics(String url) {
+        if (this.data.containsKey(url)) {
+            return (SamplingStatCalculator)this.data.get(url);
+        } else {
+            return null;
+        }
+    }
+    
+    public void loadData() {
+        
+    }
+    
+    public void add(SampleResult sample) {
+        
+    }
+    
+    /**
+     * By default, the method always returns true. Subclasses can over
+     * ride the implementation.
+     */
+    public boolean isStats() {
+        return true;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org