You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2015/12/10 19:55:23 UTC
svn commit: r1719183 [2/5] - in /jmeter/trunk/src/core/org/apache/jmeter: ./
report/config/ report/core/ report/dashboard/ report/processor/
report/processor/graph/ report/processor/graph/impl/
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java Thu Dec 10 18:55:22 2015
@@ -76,52 +76,52 @@ public class HtmlTemplateExporter extend
private static final File OUTPUT_DIR_DEFAULT = new File("report-output");
private void addToContext(String key, Object value, DataContext context) {
- if (value instanceof String) {
- value = '"' + (String) value + '"';
- }
- context.put(key, value);
+ if (value instanceof String) {
+ value = '"' + (String) value + '"';
+ }
+ context.put(key, value);
}
private interface ResultCustomizer {
- ResultData customizeResult(ResultData result);
+ ResultData customizeResult(ResultData result);
}
private <TVisit> void addResultToContext(String resultKey,
- Map<String, Object> storage, DataContext dataContext,
- ResultDataVisitor<TVisit> visitor) {
- addResultToContext(resultKey, storage, dataContext, visitor, null);
+ Map<String, Object> storage, DataContext dataContext,
+ ResultDataVisitor<TVisit> visitor) {
+ addResultToContext(resultKey, storage, dataContext, visitor, null);
}
private <TVisit> void addResultToContext(String resultKey,
- Map<String, Object> storage, DataContext dataContext,
- ResultDataVisitor<TVisit> visitor, ResultCustomizer customizer) {
- Object data = storage.get(resultKey);
- if (data instanceof ResultData) {
- ResultData result = (ResultData) data;
- if (customizer != null) {
- result = customizer.customizeResult(result);
- }
- dataContext.put(resultKey, result.accept(visitor));
- }
+ Map<String, Object> storage, DataContext dataContext,
+ ResultDataVisitor<TVisit> visitor, ResultCustomizer customizer) {
+ Object data = storage.get(resultKey);
+ if (data instanceof ResultData) {
+ ResultData result = (ResultData) data;
+ if (customizer != null) {
+ result = customizer.customizeResult(result);
+ }
+ dataContext.put(resultKey, result.accept(visitor));
+ }
}
private long formatTimestamp(String key, DataContext context) {
- double result = Double.valueOf((String) context.get(key));
- long timestamp = (long) result;
- // Quote the string to respect Json spec.
- context.put(key, '"' + TimeHelper.formatTimeStamp(timestamp) + '"');
- return timestamp;
+ double result = Double.valueOf((String) context.get(key));
+ long timestamp = (long) result;
+ // Quote the string to respect Json spec.
+ context.put(key, '"' + TimeHelper.formatTimeStamp(timestamp) + '"');
+ return timestamp;
}
private <TProperty> TProperty getPropertyFromConfig(SubConfiguration cfg,
- String property, TProperty defaultValue, Class<TProperty> clazz)
- throws ExportException {
- try {
- return cfg.getProperty(property, defaultValue, clazz);
- } catch (ConfigurationException ex) {
- throw new ExportException(String.format(
- INVALID_PROPERTY_CONFIG_FMT, property, getName()), ex);
- }
+ String property, TProperty defaultValue, Class<TProperty> clazz)
+ throws ExportException {
+ try {
+ return cfg.getProperty(property, defaultValue, clazz);
+ } catch (ConfigurationException ex) {
+ throw new ExportException(String.format(
+ INVALID_PROPERTY_CONFIG_FMT, property, getName()), ex);
+ }
}
/*
@@ -134,147 +134,147 @@ public class HtmlTemplateExporter extend
*/
@Override
public void export(SampleContext context, File file,
- ReportGeneratorConfiguration configuration) throws ExportException {
- if (context == null) {
- throw new ArgumentNullException("context");
- }
- if (file == null) {
- throw new ArgumentNullException("file");
- }
- if (configuration == null) {
- throw new ArgumentNullException("configuration");
- }
-
- log.debug("Start template processing");
-
- // Create data context and populate it
- DataContext dataContext = new DataContext();
-
- // Get the configuration of the current exporter
- final ExporterConfiguration exportCfg = configuration
- .getExportConfigurations().get(getName());
-
- // Get template directory property value
- File templateDirectory = getPropertyFromConfig(exportCfg, TEMPLATE_DIR,
- TEMPLATE_DIR_DEFAULT, File.class);
- if (templateDirectory.isDirectory() == false) {
- String message = String.format(INVALID_TEMPLATE_DIRECTORY_FMT,
- templateDirectory);
- log.error(message);
- throw new ExportException(message);
- }
-
- // Get output directory property value
- File outputDir = getPropertyFromConfig(exportCfg, OUTPUT_DIR,
- OUTPUT_DIR_DEFAULT, File.class);
- log.info("Will generate dashboard in folder:" + outputDir);
-
- // Add the flag defining whether only sample series are filtered to the
- // context
- addToContext(DATA_CTX_FILTERS_ONLY_SAMPLE_SERIES,
- exportCfg.filtersOnlySampleSeries(), dataContext);
-
- // Add the series filter to the context
- addToContext(DATA_CTX_SERIES_FILTER, exportCfg.getSeriesFilter(),
- dataContext);
-
- // Add the flag defining whether only controller series are displayed
- addToContext(DATA_CTX_SHOW_CONTROLLERS_ONLY,
- exportCfg.showControllerSeriesOnly(), dataContext);
-
- JsonizerVisitor jsonizer = new JsonizerVisitor();
- Map<String, Object> storedData = context.getData();
-
- // Add begin date consumer result to the data context
- addResultToContext(ReportGenerator.BEGIN_DATE_CONSUMER_NAME,
- storedData, dataContext, jsonizer);
-
- // Add end date summary consumer result to the data context
- addResultToContext(ReportGenerator.END_DATE_CONSUMER_NAME, storedData,
- dataContext, jsonizer);
-
- // Add Apdex summary consumer result to the data context
- addResultToContext(ReportGenerator.APDEX_SUMMARY_CONSUMER_NAME,
- storedData, dataContext, jsonizer);
-
- // Add errors summary consumer result to the data context
- addResultToContext(ReportGenerator.ERRORS_SUMMARY_CONSUMER_NAME,
- storedData, dataContext, jsonizer);
-
- // Add requests summary consumer result to the data context
- addResultToContext(ReportGenerator.REQUESTS_SUMMARY_CONSUMER_NAME,
- storedData, dataContext, jsonizer);
-
- // Add statistics summary consumer result to the data context
- addResultToContext(ReportGenerator.STATISTICS_SUMMARY_CONSUMER_NAME,
- storedData, dataContext, jsonizer);
-
- // Collect graph results from sample context and transform them into
- // Json strings to inject in the data context
- for (String graphId : configuration.getGraphConfigurations().keySet()) {
- final SubConfiguration extraOptions = exportCfg
- .getGraphExtraConfigurations().get(graphId);
- addResultToContext(graphId, storedData, dataContext, jsonizer,
- new ResultCustomizer() {
-
- @Override
- public ResultData customizeResult(ResultData result) {
- MapResultData customizedResult = new MapResultData();
- customizedResult.setResult(DATA_CTX_RESULT,
- (ResultData) result);
- if (extraOptions != null) {
- MapResultData extraResult = new MapResultData();
- for (Map.Entry<String, String> extraEntry : extraOptions
- .getProperties().entrySet()) {
- extraResult.setResult(
- extraEntry.getKey(),
- new ValueResultData(extraEntry
- .getValue()));
- }
- customizedResult.setResult(
- DATA_CTX_EXTRA_OPTIONS, extraResult);
- }
- return customizedResult;
- }
- });
- }
-
- // Replace the begin date with its formatted string and store the old
- // timestamp
- long oldTimestamp = formatTimestamp(
- ReportGenerator.BEGIN_DATE_CONSUMER_NAME, dataContext);
-
- // Replace the end date with its formatted string
- formatTimestamp(ReportGenerator.END_DATE_CONSUMER_NAME, dataContext);
-
- // Add time zone offset (that matches the begin date) to the context
- TimeZone timezone = TimeZone.getDefault();
- addToContext(DATA_CTX_TIMEZONE_OFFSET,
- timezone.getOffset(oldTimestamp), dataContext);
-
- // Add the test file name to the context
- addToContext(DATA_CTX_TESTFILE, file.getName(), dataContext);
-
- // Add the overall filter property to the context
- addToContext(DATA_CTX_OVERALL_FILTER, configuration.getSampleFilter(),
- dataContext);
-
- // Walk template directory to copy files and process templated ones
- Configuration templateCfg = new Configuration(
- Configuration.getVersion());
- try {
- templateCfg.setDirectoryForTemplateLoading(templateDirectory);
- templateCfg
- .setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
- TemplateVisitor visitor = new TemplateVisitor(
- templateDirectory.toPath(), outputDir.toPath(),
- templateCfg, dataContext);
- Files.walkFileTree(templateDirectory.toPath(), visitor);
- } catch (IOException ex) {
- throw new ExportException("Unable to process template files.", ex);
- }
+ ReportGeneratorConfiguration configuration) throws ExportException {
+ if (context == null) {
+ throw new ArgumentNullException("context");
+ }
+ if (file == null) {
+ throw new ArgumentNullException("file");
+ }
+ if (configuration == null) {
+ throw new ArgumentNullException("configuration");
+ }
+
+ log.debug("Start template processing");
+
+ // Create data context and populate it
+ DataContext dataContext = new DataContext();
+
+ // Get the configuration of the current exporter
+ final ExporterConfiguration exportCfg = configuration
+ .getExportConfigurations().get(getName());
+
+ // Get template directory property value
+ File templateDirectory = getPropertyFromConfig(exportCfg, TEMPLATE_DIR,
+ TEMPLATE_DIR_DEFAULT, File.class);
+ if (templateDirectory.isDirectory() == false) {
+ String message = String.format(INVALID_TEMPLATE_DIRECTORY_FMT,
+ templateDirectory);
+ log.error(message);
+ throw new ExportException(message);
+ }
+
+ // Get output directory property value
+ File outputDir = getPropertyFromConfig(exportCfg, OUTPUT_DIR,
+ OUTPUT_DIR_DEFAULT, File.class);
+ log.info("Will generate dashboard in folder:" + outputDir);
+
+ // Add the flag defining whether only sample series are filtered to the
+ // context
+ addToContext(DATA_CTX_FILTERS_ONLY_SAMPLE_SERIES,
+ exportCfg.filtersOnlySampleSeries(), dataContext);
+
+ // Add the series filter to the context
+ addToContext(DATA_CTX_SERIES_FILTER, exportCfg.getSeriesFilter(),
+ dataContext);
+
+ // Add the flag defining whether only controller series are displayed
+ addToContext(DATA_CTX_SHOW_CONTROLLERS_ONLY,
+ exportCfg.showControllerSeriesOnly(), dataContext);
+
+ JsonizerVisitor jsonizer = new JsonizerVisitor();
+ Map<String, Object> storedData = context.getData();
+
+ // Add begin date consumer result to the data context
+ addResultToContext(ReportGenerator.BEGIN_DATE_CONSUMER_NAME,
+ storedData, dataContext, jsonizer);
+
+ // Add end date summary consumer result to the data context
+ addResultToContext(ReportGenerator.END_DATE_CONSUMER_NAME, storedData,
+ dataContext, jsonizer);
+
+ // Add Apdex summary consumer result to the data context
+ addResultToContext(ReportGenerator.APDEX_SUMMARY_CONSUMER_NAME,
+ storedData, dataContext, jsonizer);
+
+ // Add errors summary consumer result to the data context
+ addResultToContext(ReportGenerator.ERRORS_SUMMARY_CONSUMER_NAME,
+ storedData, dataContext, jsonizer);
+
+ // Add requests summary consumer result to the data context
+ addResultToContext(ReportGenerator.REQUESTS_SUMMARY_CONSUMER_NAME,
+ storedData, dataContext, jsonizer);
+
+ // Add statistics summary consumer result to the data context
+ addResultToContext(ReportGenerator.STATISTICS_SUMMARY_CONSUMER_NAME,
+ storedData, dataContext, jsonizer);
+
+ // Collect graph results from sample context and transform them into
+ // Json strings to inject in the data context
+ for (String graphId : configuration.getGraphConfigurations().keySet()) {
+ final SubConfiguration extraOptions = exportCfg
+ .getGraphExtraConfigurations().get(graphId);
+ addResultToContext(graphId, storedData, dataContext, jsonizer,
+ new ResultCustomizer() {
+
+ @Override
+ public ResultData customizeResult(ResultData result) {
+ MapResultData customizedResult = new MapResultData();
+ customizedResult.setResult(DATA_CTX_RESULT,
+ (ResultData) result);
+ if (extraOptions != null) {
+ MapResultData extraResult = new MapResultData();
+ for (Map.Entry<String, String> extraEntry : extraOptions
+ .getProperties().entrySet()) {
+ extraResult.setResult(
+ extraEntry.getKey(),
+ new ValueResultData(extraEntry
+ .getValue()));
+ }
+ customizedResult.setResult(
+ DATA_CTX_EXTRA_OPTIONS, extraResult);
+ }
+ return customizedResult;
+ }
+ });
+ }
+
+ // Replace the begin date with its formatted string and store the old
+ // timestamp
+ long oldTimestamp = formatTimestamp(
+ ReportGenerator.BEGIN_DATE_CONSUMER_NAME, dataContext);
+
+ // Replace the end date with its formatted string
+ formatTimestamp(ReportGenerator.END_DATE_CONSUMER_NAME, dataContext);
+
+ // Add time zone offset (that matches the begin date) to the context
+ TimeZone timezone = TimeZone.getDefault();
+ addToContext(DATA_CTX_TIMEZONE_OFFSET,
+ timezone.getOffset(oldTimestamp), dataContext);
+
+ // Add the test file name to the context
+ addToContext(DATA_CTX_TESTFILE, file.getName(), dataContext);
+
+ // Add the overall filter property to the context
+ addToContext(DATA_CTX_OVERALL_FILTER, configuration.getSampleFilter(),
+ dataContext);
+
+ // Walk template directory to copy files and process templated ones
+ Configuration templateCfg = new Configuration(
+ Configuration.getVersion());
+ try {
+ templateCfg.setDirectoryForTemplateLoading(templateDirectory);
+ templateCfg
+ .setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
+ TemplateVisitor visitor = new TemplateVisitor(
+ templateDirectory.toPath(), outputDir.toPath(),
+ templateCfg, dataContext);
+ Files.walkFileTree(templateDirectory.toPath(), visitor);
+ } catch (IOException ex) {
+ throw new ExportException("Unable to process template files.", ex);
+ }
- log.debug("End of template processing");
+ log.debug("End of template processing");
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/JsonizerVisitor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/JsonizerVisitor.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/JsonizerVisitor.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/JsonizerVisitor.java Thu Dec 10 18:55:22 2015
@@ -39,7 +39,7 @@ public class JsonizerVisitor implements
* Instantiates a new jsonizer visitor.
*/
public JsonizerVisitor() {
- // TODO Auto-generated constructor stub
+ // TODO Auto-generated constructor stub
}
/*
@@ -51,16 +51,16 @@ public class JsonizerVisitor implements
*/
@Override
public String visitListResult(ListResultData listResult) {
- String result = "";
- if (listResult != null) {
- int count = listResult.getSize();
- String[] items = new String[count];
- for (int i = 0; i < count; i++) {
- items[i] = listResult.get(i).accept(this);
- }
- result = JsonUtil.toJsonArray(items);
- }
- return result;
+ String result = "";
+ if (listResult != null) {
+ int count = listResult.getSize();
+ String[] items = new String[count];
+ for (int i = 0; i < count; i++) {
+ items[i] = listResult.get(i).accept(this);
+ }
+ result = JsonUtil.toJsonArray(items);
+ }
+ return result;
}
/*
@@ -72,15 +72,15 @@ public class JsonizerVisitor implements
*/
@Override
public String visitMapResult(MapResultData mapResult) {
- String result = "";
- if (mapResult != null) {
- HashMap<String, String> map = new HashMap<>();
- for (Map.Entry<String, ResultData> entry : mapResult.entrySet()) {
- map.put(entry.getKey(), entry.getValue().accept(this));
- }
- result = JsonUtil.toJsonObject(map);
- }
- return result;
+ String result = "";
+ if (mapResult != null) {
+ HashMap<String, String> map = new HashMap<>();
+ for (Map.Entry<String, ResultData> entry : mapResult.entrySet()) {
+ map.put(entry.getKey(), entry.getValue().accept(this));
+ }
+ result = JsonUtil.toJsonObject(map);
+ }
+ return result;
}
/*
@@ -92,14 +92,14 @@ public class JsonizerVisitor implements
*/
@Override
public String visitValueResult(ValueResultData valueResult) {
- String result = "";
- if (valueResult != null) {
- Object value = valueResult.getValue();
- result = String.valueOf(value);
- if (value instanceof String) {
- result = '"' + result + '"';
- }
- }
- return result;
+ String result = "";
+ if (valueResult != null) {
+ Object value = valueResult.getValue();
+ result = String.valueOf(value);
+ if (value instanceof String) {
+ result = '"' + result + '"';
+ }
+ }
+ return result;
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java Thu Dec 10 18:55:22 2015
@@ -70,19 +70,19 @@ import org.apache.log.Logger;
public class ReportGenerator {
private static final Logger log = LoggingManager.getLoggerForClass();
-// /** A properties file indicator for true. * */
-// private static final String TRUE = "true"; // $NON_NLS-1$
-//
-// /** A properties file indicator for false. * */
-// private static final String FALSE = "false"; // $NON_NLS-1$
-
-// private static final boolean PRINT_FIELD_NAMES = TRUE
-// .equalsIgnoreCase(JMeterUtils.getPropDefault(
-// "jmeter.save.saveservice.print_field_names", FALSE));
+ // /** A properties file indicator for true. * */
+ // private static final String TRUE = "true"; // $NON_NLS-1$
+ //
+ // /** A properties file indicator for false. * */
+ // private static final String FALSE = "false"; // $NON_NLS-1$
+
+ // private static final boolean PRINT_FIELD_NAMES = TRUE
+ // .equalsIgnoreCase(JMeterUtils.getPropDefault(
+ // "jmeter.save.saveservice.print_field_names", FALSE));
private static final boolean CSV_OUTPUT_FORMAT = "csv"
- .equalsIgnoreCase(JMeterUtils.getPropDefault(
- "jmeter.save.saveservice.output_format", "csv"));
+ .equalsIgnoreCase(JMeterUtils.getPropDefault(
+ "jmeter.save.saveservice.output_format", "csv"));
private static final String INVALID_CLASS_FMT = "Class name \"%s\" is not valid.";
private static final String INVALID_EXPORT_FMT = "Data exporter \"%s\" is unable to export data.";
@@ -115,36 +115,36 @@ public class ReportGenerator {
* Can be null, used if generation occurs at end of test
*/
public ReportGenerator(String resultsFile, ResultCollector resultCollector)
- throws ConfigurationException {
- if (!CSV_OUTPUT_FORMAT) {
- throw new IllegalArgumentException(
- "Report generation requires csv output format, check 'jmeter.save.saveservice.output_format' property");
- }
-// if (!PRINT_FIELD_NAMES) {
-// throw new IllegalArgumentException(
-// "Report generation requires csv to print field names, check 'jmeter.save.saveservice.print_field_names' property");
-// }
-
- File file = new File(resultsFile);
- if (resultCollector == null) {
- if (!(file.isFile() && file.canRead())) {
- throw new IllegalArgumentException(String.format(
- "Invalid test results file : %s", file));
- }
- log.info("Will only generate report from results file:"
- + resultsFile);
- } else {
- if (file.exists() && file.length() > 0) {
- throw new IllegalArgumentException("Results file:"
- + resultsFile + " is not empty");
- }
- log.info("Will generate report at end of test from results file:"
- + resultsFile);
- }
- this.resultCollector = resultCollector;
- this.testFile = file;
- configuration = ReportGeneratorConfiguration
- .LoadFromProperties(JMeterUtils.getJMeterProperties());
+ throws ConfigurationException {
+ if (!CSV_OUTPUT_FORMAT) {
+ throw new IllegalArgumentException(
+ "Report generation requires csv output format, check 'jmeter.save.saveservice.output_format' property");
+ }
+ // if (!PRINT_FIELD_NAMES) {
+ // throw new IllegalArgumentException(
+ // "Report generation requires csv to print field names, check 'jmeter.save.saveservice.print_field_names' property");
+ // }
+
+ File file = new File(resultsFile);
+ if (resultCollector == null) {
+ if (!(file.isFile() && file.canRead())) {
+ throw new IllegalArgumentException(String.format(
+ "Invalid test results file : %s", file));
+ }
+ log.info("Will only generate report from results file:"
+ + resultsFile);
+ } else {
+ if (file.exists() && file.length() > 0) {
+ throw new IllegalArgumentException("Results file:"
+ + resultsFile + " is not empty");
+ }
+ log.info("Will generate report at end of test from results file:"
+ + resultsFile);
+ }
+ this.resultCollector = resultCollector;
+ this.testFile = file;
+ configuration = ReportGeneratorConfiguration
+ .LoadFromProperties(JMeterUtils.getJMeterProperties());
}
/**
@@ -160,15 +160,15 @@ public class ReportGenerator {
* @return the name of the property setter
*/
private static String getSetterName(String propertyKey) {
- // TODO use jmeter regex cache
- Pattern pattern = Pattern.compile("_(.)");
- Matcher matcher = pattern.matcher(propertyKey);
- StringBuffer buffer = new StringBuffer();
- while (matcher.find()) {
- matcher.appendReplacement(buffer, matcher.group(1).toUpperCase());
- }
- matcher.appendTail(buffer);
- return buffer.toString();
+ // TODO use jmeter regex cache
+ Pattern pattern = Pattern.compile("_(.)");
+ Matcher matcher = pattern.matcher(propertyKey);
+ StringBuffer buffer = new StringBuffer();
+ while (matcher.find()) {
+ matcher.appendReplacement(buffer, matcher.group(1).toUpperCase());
+ }
+ matcher.appendTail(buffer);
+ return buffer.toString();
}
/**
@@ -179,255 +179,255 @@ public class ReportGenerator {
*/
public void generate() throws GenerationException {
- if (resultCollector != null) {
- log.info("Flushing result collector before report Generation");
- resultCollector.flushFile();
- }
- log.debug("Start report generation");
-
- File tmpDir = configuration.getTempDirectory();
- boolean tmpDirCreated = false;
- if (tmpDir.exists() == false) {
- tmpDirCreated = tmpDir.mkdir();
- if (tmpDirCreated == false) {
- String message = String.format(
- "Cannot create temporary directory \"%s\".", tmpDir);
- log.error(message);
- throw new GenerationException(message);
- }
- }
-
- // Build consumers chain
- SampleContext sampleContext = new SampleContext();
- sampleContext.setWorkingDirectory(tmpDir);
- SampleSource source = new CsvFileSampleSource(testFile, JMeterUtils
- .getPropDefault("jmeter.save.saveservice.default_delimiter",
- ",").charAt(0));
- source.setSampleContext(sampleContext);
-
- NormalizerSampleConsumer normalizer = new NormalizerSampleConsumer();
- normalizer.setName(NORMALIZER_CONSUMER_NAME);
- source.addSampleConsumer(normalizer);
-
- AggregateConsumer beginDateConsumer = new AggregateConsumer(
- new MinAggregator(), new SampleSelector<Double>() {
-
- @Override
- public Double select(Sample sample) {
- return (double) sample.getStartTime();
- }
- });
- beginDateConsumer.setName(BEGIN_DATE_CONSUMER_NAME);
- normalizer.addSampleConsumer(beginDateConsumer);
-
- AggregateConsumer endDateConsumer = new AggregateConsumer(
- new MaxAggregator(), new SampleSelector<Double>() {
-
- @Override
- public Double select(Sample sample) {
- return (double) sample.getEndTime();
- }
- });
- endDateConsumer.setName(END_DATE_CONSUMER_NAME);
- normalizer.addSampleConsumer(endDateConsumer);
-
- FilterConsumer nameFilter = new FilterConsumer();
- nameFilter.setName(NAME_FILTER_CONSUMER_NAME);
- nameFilter.setSamplePredicate(new SamplePredicate() {
-
- @Override
- public boolean matches(Sample sample) {
- // Get filtered samples from configuration
- List<String> filteredSamples = configuration
- .getFilteredSamples();
- // Sample is kept if none filter is set or if the filter
- // contains its name
- return filteredSamples.size() == 0
- || filteredSamples.contains(sample.getName());
- }
- });
- normalizer.setSampleConsumer(nameFilter);
-
- ApdexSummaryConsumer apdexSummaryConsumer = new ApdexSummaryConsumer();
- apdexSummaryConsumer.setName(APDEX_SUMMARY_CONSUMER_NAME);
- apdexSummaryConsumer.setHasOverallResult(true);
- apdexSummaryConsumer.setThresholdSelector(new ThresholdSelector() {
-
- @Override
- public ApdexThresholdsInfo select(String sampleName) {
- ApdexThresholdsInfo info = new ApdexThresholdsInfo();
- info.setSatisfiedThreshold(configuration
- .getApdexSatisfiedThreshold());
- info.setToleratedThreshold(configuration
- .getApdexToleratedThreshold());
- return info;
- }
- });
- nameFilter.setSampleConsumer(apdexSummaryConsumer);
-
- RequestsSummaryConsumer requestsSummaryConsumer = new RequestsSummaryConsumer();
- requestsSummaryConsumer.setName(REQUESTS_SUMMARY_CONSUMER_NAME);
- nameFilter.setSampleConsumer(requestsSummaryConsumer);
-
- StatisticsSummaryConsumer statisticsSummaryConsumer = new StatisticsSummaryConsumer();
- statisticsSummaryConsumer.setName(STATISTICS_SUMMARY_CONSUMER_NAME);
- statisticsSummaryConsumer.setHasOverallResult(true);
- nameFilter.setSampleConsumer(statisticsSummaryConsumer);
-
- FilterConsumer excludeControllerFilter = new FilterConsumer();
- excludeControllerFilter
- .setName(START_INTERVAL_CONTROLLER_FILTER_CONSUMER_NAME);
- excludeControllerFilter
- .setSamplePredicate(new ControllerSamplePredicate());
- excludeControllerFilter.setReverseFilter(true);
- nameFilter.setSampleConsumer(excludeControllerFilter);
-
- ErrorsSummaryConsumer errorsSummaryConsumer = new ErrorsSummaryConsumer();
- errorsSummaryConsumer.setName(ERRORS_SUMMARY_CONSUMER_NAME);
- excludeControllerFilter.setSampleConsumer(errorsSummaryConsumer);
-
- // Get graph configurations
- Map<String, GraphConfiguration> graphConfigurations = configuration
- .getGraphConfigurations();
-
- // Process configuration to build graph consumers
- HashMap<GraphConfiguration, AbstractGraphConsumer> graphMap = new HashMap<>();
- for (Map.Entry<String, GraphConfiguration> entryGraphCfg : graphConfigurations
- .entrySet()) {
- String graphName = entryGraphCfg.getKey();
- GraphConfiguration graphConfiguration = entryGraphCfg.getValue();
-
- // Instantiate the class from the classname
- String className = graphConfiguration.getClassName();
- try {
- Class<?> clazz = Class.forName(className);
- Object obj = clazz.newInstance();
- AbstractGraphConsumer graph = (AbstractGraphConsumer) obj;
- graph.setName(graphName);
-
- // Set graph properties using reflection
- Method[] methods = clazz.getMethods();
- for (Map.Entry<String, String> entryProperty : graphConfiguration
- .getProperties().entrySet()) {
- String propertyName = entryProperty.getKey();
- String propertyValue = entryProperty.getValue();
- String setterName = getSetterName(propertyName);
-
- try {
- int i = 0;
- boolean invoked = false;
- while (i < methods.length && invoked == false) {
- Method method = methods[i];
- if (method.getName().equals(setterName)) {
- Class<?>[] parameterTypes = method
- .getParameterTypes();
- if (parameterTypes.length == 1) {
- Class<?> parameterType = parameterTypes[0];
- if (parameterType
- .isAssignableFrom(String.class)) {
- method.invoke(obj, propertyValue);
- } else {
- StringConverter<?> converter = Converters
- .getConverter(parameterType);
- if (converter == null) {
- throw new GenerationException(
- String.format(
- NOT_SUPPORTED_CONVERTION_FMT,
- parameterType
- .getName()));
+ if (resultCollector != null) {
+ log.info("Flushing result collector before report Generation");
+ resultCollector.flushFile();
+ }
+ log.debug("Start report generation");
+
+ File tmpDir = configuration.getTempDirectory();
+ boolean tmpDirCreated = false;
+ if (tmpDir.exists() == false) {
+ tmpDirCreated = tmpDir.mkdir();
+ if (tmpDirCreated == false) {
+ String message = String.format(
+ "Cannot create temporary directory \"%s\".", tmpDir);
+ log.error(message);
+ throw new GenerationException(message);
+ }
+ }
+
+ // Build consumers chain
+ SampleContext sampleContext = new SampleContext();
+ sampleContext.setWorkingDirectory(tmpDir);
+ SampleSource source = new CsvFileSampleSource(testFile, JMeterUtils
+ .getPropDefault("jmeter.save.saveservice.default_delimiter",
+ ",").charAt(0));
+ source.setSampleContext(sampleContext);
+
+ NormalizerSampleConsumer normalizer = new NormalizerSampleConsumer();
+ normalizer.setName(NORMALIZER_CONSUMER_NAME);
+ source.addSampleConsumer(normalizer);
+
+ AggregateConsumer beginDateConsumer = new AggregateConsumer(
+ new MinAggregator(), new SampleSelector<Double>() {
+
+ @Override
+ public Double select(Sample sample) {
+ return (double) sample.getStartTime();
}
- method.invoke(obj, converter
- .convert(propertyValue));
- }
- invoked = true;
- }
- }
- i++;
- }
- if (invoked == false) {
- log.warn(String
- .format("\"%s\" is not a valid property for class \"%s\", skip it",
- propertyName, className));
- }
- } catch (InvocationTargetException | ConvertException ex) {
- String message = String
- .format("Cannot assign \"%s\" to property \"%s\" (mapped as \"%s\"), skip it",
- propertyValue, propertyName, setterName);
- log.error(message, ex);
- throw new GenerationException(message, ex);
- }
- }
-
- // Choose which entry point to use to plug the graph
- AbstractSampleConsumer entryPoint = graphConfiguration
- .excludesControllers() ? excludeControllerFilter
- : nameFilter;
- entryPoint.addSampleConsumer(graph);
-
- // Add to the map
- graphMap.put(graphConfiguration, graph);
- } catch (ClassNotFoundException | IllegalAccessException
- | InstantiationException | ClassCastException ex) {
- String error = String.format(INVALID_CLASS_FMT, className);
- log.error(error, ex);
- throw new GenerationException(error, ex);
- }
- }
-
- // Generate data
- log.debug("Start samples processing");
- try {
- source.run();
- } catch (SampleException ex) {
- String message = "Error while processing samples";
- log.error(message, ex);
- throw new GenerationException(message, ex);
- }
- log.debug("End of samples processing");
-
- log.debug("Start data exporting");
-
- // Process configuration to build data exporters
- for (Map.Entry<String, ExporterConfiguration> entry : configuration
- .getExportConfigurations().entrySet()) {
- String exporterName = entry.getKey();
- ExporterConfiguration exporterConfiguration = entry.getValue();
-
- // Instantiate the class from the classname
- String className = exporterConfiguration.getClassName();
- try {
- Class<?> clazz = Class.forName(className);
- Object obj = clazz.newInstance();
- DataExporter exporter = (DataExporter) obj;
- exporter.setName(exporterName);
-
- // Export data
- exporter.export(sampleContext, testFile, configuration);
- } catch (ClassNotFoundException | IllegalAccessException
- | InstantiationException | ClassCastException ex) {
- String error = String.format(INVALID_CLASS_FMT, className);
- log.error(error, ex);
- throw new GenerationException(error, ex);
- } catch (ExportException ex) {
- String error = String.format(INVALID_EXPORT_FMT, exporterName);
- log.error(error, ex);
- throw new GenerationException(error, ex);
- }
- }
-
- log.debug("End of data exporting");
-
- if (tmpDirCreated == true) {
- try {
- FileUtils.deleteDirectory(tmpDir);
- } catch (IOException ex) {
- log.warn(String.format(
- "Cannot delete created temporary directory \"%s\".",
- tmpDir), ex);
- }
- }
+ });
+ beginDateConsumer.setName(BEGIN_DATE_CONSUMER_NAME);
+ normalizer.addSampleConsumer(beginDateConsumer);
+
+ AggregateConsumer endDateConsumer = new AggregateConsumer(
+ new MaxAggregator(), new SampleSelector<Double>() {
+
+ @Override
+ public Double select(Sample sample) {
+ return (double) sample.getEndTime();
+ }
+ });
+ endDateConsumer.setName(END_DATE_CONSUMER_NAME);
+ normalizer.addSampleConsumer(endDateConsumer);
+
+ FilterConsumer nameFilter = new FilterConsumer();
+ nameFilter.setName(NAME_FILTER_CONSUMER_NAME);
+ nameFilter.setSamplePredicate(new SamplePredicate() {
+
+ @Override
+ public boolean matches(Sample sample) {
+ // Get filtered samples from configuration
+ List<String> filteredSamples = configuration
+ .getFilteredSamples();
+ // Sample is kept if none filter is set or if the filter
+ // contains its name
+ return filteredSamples.size() == 0
+ || filteredSamples.contains(sample.getName());
+ }
+ });
+ normalizer.setSampleConsumer(nameFilter);
+
+ ApdexSummaryConsumer apdexSummaryConsumer = new ApdexSummaryConsumer();
+ apdexSummaryConsumer.setName(APDEX_SUMMARY_CONSUMER_NAME);
+ apdexSummaryConsumer.setHasOverallResult(true);
+ apdexSummaryConsumer.setThresholdSelector(new ThresholdSelector() {
+
+ @Override
+ public ApdexThresholdsInfo select(String sampleName) {
+ ApdexThresholdsInfo info = new ApdexThresholdsInfo();
+ info.setSatisfiedThreshold(configuration
+ .getApdexSatisfiedThreshold());
+ info.setToleratedThreshold(configuration
+ .getApdexToleratedThreshold());
+ return info;
+ }
+ });
+ nameFilter.setSampleConsumer(apdexSummaryConsumer);
+
+ RequestsSummaryConsumer requestsSummaryConsumer = new RequestsSummaryConsumer();
+ requestsSummaryConsumer.setName(REQUESTS_SUMMARY_CONSUMER_NAME);
+ nameFilter.setSampleConsumer(requestsSummaryConsumer);
+
+ StatisticsSummaryConsumer statisticsSummaryConsumer = new StatisticsSummaryConsumer();
+ statisticsSummaryConsumer.setName(STATISTICS_SUMMARY_CONSUMER_NAME);
+ statisticsSummaryConsumer.setHasOverallResult(true);
+ nameFilter.setSampleConsumer(statisticsSummaryConsumer);
+
+ FilterConsumer excludeControllerFilter = new FilterConsumer();
+ excludeControllerFilter
+ .setName(START_INTERVAL_CONTROLLER_FILTER_CONSUMER_NAME);
+ excludeControllerFilter
+ .setSamplePredicate(new ControllerSamplePredicate());
+ excludeControllerFilter.setReverseFilter(true);
+ nameFilter.setSampleConsumer(excludeControllerFilter);
+
+ ErrorsSummaryConsumer errorsSummaryConsumer = new ErrorsSummaryConsumer();
+ errorsSummaryConsumer.setName(ERRORS_SUMMARY_CONSUMER_NAME);
+ excludeControllerFilter.setSampleConsumer(errorsSummaryConsumer);
+
+ // Get graph configurations
+ Map<String, GraphConfiguration> graphConfigurations = configuration
+ .getGraphConfigurations();
+
+ // Process configuration to build graph consumers
+ HashMap<GraphConfiguration, AbstractGraphConsumer> graphMap = new HashMap<>();
+ for (Map.Entry<String, GraphConfiguration> entryGraphCfg : graphConfigurations
+ .entrySet()) {
+ String graphName = entryGraphCfg.getKey();
+ GraphConfiguration graphConfiguration = entryGraphCfg.getValue();
+
+ // Instantiate the class from the classname
+ String className = graphConfiguration.getClassName();
+ try {
+ Class<?> clazz = Class.forName(className);
+ Object obj = clazz.newInstance();
+ AbstractGraphConsumer graph = (AbstractGraphConsumer) obj;
+ graph.setName(graphName);
+
+ // Set graph properties using reflection
+ Method[] methods = clazz.getMethods();
+ for (Map.Entry<String, String> entryProperty : graphConfiguration
+ .getProperties().entrySet()) {
+ String propertyName = entryProperty.getKey();
+ String propertyValue = entryProperty.getValue();
+ String setterName = getSetterName(propertyName);
+
+ try {
+ int i = 0;
+ boolean invoked = false;
+ while (i < methods.length && invoked == false) {
+ Method method = methods[i];
+ if (method.getName().equals(setterName)) {
+ Class<?>[] parameterTypes = method
+ .getParameterTypes();
+ if (parameterTypes.length == 1) {
+ Class<?> parameterType = parameterTypes[0];
+ if (parameterType
+ .isAssignableFrom(String.class)) {
+ method.invoke(obj, propertyValue);
+ } else {
+ StringConverter<?> converter = Converters
+ .getConverter(parameterType);
+ if (converter == null) {
+ throw new GenerationException(
+ String.format(
+ NOT_SUPPORTED_CONVERTION_FMT,
+ parameterType
+ .getName()));
+ }
+ method.invoke(obj, converter
+ .convert(propertyValue));
+ }
+ invoked = true;
+ }
+ }
+ i++;
+ }
+ if (invoked == false) {
+ log.warn(String
+ .format("\"%s\" is not a valid property for class \"%s\", skip it",
+ propertyName, className));
+ }
+ } catch (InvocationTargetException | ConvertException ex) {
+ String message = String
+ .format("Cannot assign \"%s\" to property \"%s\" (mapped as \"%s\"), skip it",
+ propertyValue, propertyName, setterName);
+ log.error(message, ex);
+ throw new GenerationException(message, ex);
+ }
+ }
+
+ // Choose which entry point to use to plug the graph
+ AbstractSampleConsumer entryPoint = graphConfiguration
+ .excludesControllers() ? excludeControllerFilter
+ : nameFilter;
+ entryPoint.addSampleConsumer(graph);
+
+ // Add to the map
+ graphMap.put(graphConfiguration, graph);
+ } catch (ClassNotFoundException | IllegalAccessException
+ | InstantiationException | ClassCastException ex) {
+ String error = String.format(INVALID_CLASS_FMT, className);
+ log.error(error, ex);
+ throw new GenerationException(error, ex);
+ }
+ }
+
+ // Generate data
+ log.debug("Start samples processing");
+ try {
+ source.run();
+ } catch (SampleException ex) {
+ String message = "Error while processing samples";
+ log.error(message, ex);
+ throw new GenerationException(message, ex);
+ }
+ log.debug("End of samples processing");
+
+ log.debug("Start data exporting");
+
+ // Process configuration to build data exporters
+ for (Map.Entry<String, ExporterConfiguration> entry : configuration
+ .getExportConfigurations().entrySet()) {
+ String exporterName = entry.getKey();
+ ExporterConfiguration exporterConfiguration = entry.getValue();
+
+ // Instantiate the class from the classname
+ String className = exporterConfiguration.getClassName();
+ try {
+ Class<?> clazz = Class.forName(className);
+ Object obj = clazz.newInstance();
+ DataExporter exporter = (DataExporter) obj;
+ exporter.setName(exporterName);
+
+ // Export data
+ exporter.export(sampleContext, testFile, configuration);
+ } catch (ClassNotFoundException | IllegalAccessException
+ | InstantiationException | ClassCastException ex) {
+ String error = String.format(INVALID_CLASS_FMT, className);
+ log.error(error, ex);
+ throw new GenerationException(error, ex);
+ } catch (ExportException ex) {
+ String error = String.format(INVALID_EXPORT_FMT, exporterName);
+ log.error(error, ex);
+ throw new GenerationException(error, ex);
+ }
+ }
+
+ log.debug("End of data exporting");
+
+ if (tmpDirCreated == true) {
+ try {
+ FileUtils.deleteDirectory(tmpDir);
+ } catch (IOException ex) {
+ log.warn(String.format(
+ "Cannot delete created temporary directory \"%s\".",
+ tmpDir), ex);
+ }
+ }
- log.debug("End of report generation");
+ log.debug("End of report generation");
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/TemplateVisitor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/TemplateVisitor.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/TemplateVisitor.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/TemplateVisitor.java Thu Dec 10 18:55:22 2015
@@ -64,11 +64,11 @@ public class TemplateVisitor extends Sim
* the data to inject
*/
public TemplateVisitor(Path source, Path target,
- Configuration configuration, DataContext data) {
- this.source = source;
- this.target = target;
- this.configuration = configuration;
- this.data = data;
+ Configuration configuration, DataContext data) {
+ this.source = source;
+ this.target = target;
+ this.configuration = configuration;
+ this.data = data;
}
/*
@@ -79,16 +79,16 @@ public class TemplateVisitor extends Sim
*/
@Override
public FileVisitResult preVisitDirectory(Path arg0, BasicFileAttributes arg1)
- throws IOException {
- // Copy directory
- Path newDir = target.resolve(source.relativize(arg0));
- try {
- Files.copy(arg0, newDir);
- } catch (FileAlreadyExistsException ex) {
- // Set directory empty
- FileUtils.cleanDirectory(newDir.toFile());
- }
- return FileVisitResult.CONTINUE;
+ throws IOException {
+ // Copy directory
+ Path newDir = target.resolve(source.relativize(arg0));
+ try {
+ Files.copy(arg0, newDir);
+ } catch (FileAlreadyExistsException ex) {
+ // Set directory empty
+ FileUtils.cleanDirectory(newDir.toFile());
+ }
+ return FileVisitResult.CONTINUE;
}
/*
@@ -99,30 +99,30 @@ public class TemplateVisitor extends Sim
*/
@Override
public FileVisitResult visitFile(Path arg0, BasicFileAttributes arg1)
- throws IOException {
+ throws IOException {
- // Depending on file extension, copy or process file
- String extension = FilenameUtils.getExtension(arg0.toString());
- if (TEMPLATED_FILE_EXT.equalsIgnoreCase(extension)) {
- // Process template file
- String templatePath = source.relativize(arg0).toString();
- Template template = configuration.getTemplate(templatePath);
- Path newPath = target.resolve(FilenameUtils
- .removeExtension(templatePath));
- Writer file = new FileWriter(newPath.toString());
- try {
- template.process(data, file);
- } catch (TemplateException ex) {
- throw new IOException(ex);
- } finally {
- file.close();
- }
+ // Depending on file extension, copy or process file
+ String extension = FilenameUtils.getExtension(arg0.toString());
+ if (TEMPLATED_FILE_EXT.equalsIgnoreCase(extension)) {
+ // Process template file
+ String templatePath = source.relativize(arg0).toString();
+ Template template = configuration.getTemplate(templatePath);
+ Path newPath = target.resolve(FilenameUtils
+ .removeExtension(templatePath));
+ Writer file = new FileWriter(newPath.toString());
+ try {
+ template.process(data, file);
+ } catch (TemplateException ex) {
+ throw new IOException(ex);
+ } finally {
+ file.close();
+ }
- } else {
- // Copy regular file
- Path newFile = target.resolve(source.relativize(arg0));
- Files.copy(arg0, newFile, StandardCopyOption.REPLACE_EXISTING);
- }
- return FileVisitResult.CONTINUE;
+ } else {
+ // Copy regular file
+ Path newFile = target.resolve(source.relativize(arg0));
+ Files.copy(arg0, newFile, StandardCopyOption.REPLACE_EXISTING);
+ }
+ return FileVisitResult.CONTINUE;
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractAggregatorFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractAggregatorFactory.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractAggregatorFactory.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractAggregatorFactory.java Thu Dec 10 18:55:22 2015
@@ -47,7 +47,7 @@ public abstract class AbstractAggregator
*/
@Override
public final Aggregator createValueAggregator() {
- return createAggregator();
+ return createAggregator();
}
/*
@@ -59,7 +59,7 @@ public abstract class AbstractAggregator
*/
@Override
public final Aggregator createKeyAggregator() {
- return createAggregator();
+ return createAggregator();
}
/*
@@ -70,7 +70,7 @@ public abstract class AbstractAggregator
*/
@Override
public final Aggregator createAggregatedKeyValueAggregator() {
- return createAggregator();
+ return createAggregator();
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleConsumer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleConsumer.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleConsumer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleConsumer.java Thu Dec 10 18:55:22 2015
@@ -41,7 +41,7 @@ abstract public class AbstractSampleCons
implements SampleConsumer, SampleProducer {
private static final Logger log = LoggerFactory
- .getLogger(AbstractSampleConsumer.class);
+ .getLogger(AbstractSampleConsumer.class);
/** sample consumer name, used for logging */
private String name;
@@ -72,7 +72,7 @@ abstract public class AbstractSampleCons
* @return the data
*/
protected final Object getDataFromContext(String key) {
- return getSampleContext().getData().get(key);
+ return getSampleContext().getData().get(key);
}
/**
@@ -85,7 +85,7 @@ abstract public class AbstractSampleCons
* the value
*/
protected final void setDataToContext(String key, Object value) {
- getSampleContext().getData().put(key, value);
+ getSampleContext().getData().put(key, value);
}
/**
@@ -94,11 +94,11 @@ abstract public class AbstractSampleCons
* @return the name of the consumer
*/
public String getName() {
- if (name == null) {
- return getClass().getSimpleName() + "-" + hashCode();
- } else {
- return name;
- }
+ if (name == null) {
+ return getClass().getSimpleName() + "-" + hashCode();
+ } else {
+ return name;
+ }
}
/**
@@ -108,152 +108,152 @@ abstract public class AbstractSampleCons
* the new name
*/
public void setName(String name) {
- this.name = name;
+ this.name = name;
}
public final File getWorkingDirectory() {
- return workingDir;
+ return workingDir;
}
private void setWorkingDirectory(File baseDirectory) {
- this.workingDir = new File(baseDirectory, getName());
+ this.workingDir = new File(baseDirectory, getName());
}
@Override
public void setSampleContext(SampleContext sampleContext) {
- super.setSampleContext(sampleContext);
- initConsumers(sampleContext);
- setWorkingDirectory(sampleContext.getWorkingDirectory());
+ super.setSampleContext(sampleContext);
+ initConsumers(sampleContext);
+ setWorkingDirectory(sampleContext.getWorkingDirectory());
}
public void setSampleConsumers(List<SampleConsumer> consumers) {
- if (consumers == null) {
- throw new ArgumentNullException("consumers");
- }
+ if (consumers == null) {
+ throw new ArgumentNullException("consumers");
+ }
- this.sampleConsumers = consumers;
+ this.sampleConsumers = consumers;
}
public void addSampleConsumer(SampleConsumer consumer) {
- if (consumer == null) {
- return;
- }
- this.sampleConsumers.add(consumer);
+ if (consumer == null) {
+ return;
+ }
+ this.sampleConsumers.add(consumer);
}
public void setSampleConsumer(SampleConsumer consumer) {
- addSampleConsumer(consumer);
+ addSampleConsumer(consumer);
}
public void removeSampleConsumer(SampleConsumer consumer) {
- if (consumer == null) {
- return;
- }
- this.sampleConsumers.remove(consumer);
+ if (consumer == null) {
+ return;
+ }
+ this.sampleConsumers.remove(consumer);
}
@Override
public void setConsumedMetadata(SampleMetadata sampleMetadata, int channel) {
- consumedMetadata.put(channel, sampleMetadata);
+ consumedMetadata.put(channel, sampleMetadata);
}
public SampleMetadata getConsumedMetadata(int channel) {
- return consumedMetadata.get(channel);
+ return consumedMetadata.get(channel);
}
public int getConsumedChannelCount() {
- return consumedMetadata.size();
+ return consumedMetadata.size();
}
private void initConsumers(SampleContext context) {
- for (SampleConsumer consumer : this.sampleConsumers) {
- try {
- consumer.setSampleContext(context);
- } catch (Exception e) {
- log.error(
- "produce(): Consumer failed with message :"
- + e.getMessage(), e);
- throw new SampleException(e);
- }
- }
+ for (SampleConsumer consumer : this.sampleConsumers) {
+ try {
+ consumer.setSampleContext(context);
+ } catch (Exception e) {
+ log.error(
+ "produce(): Consumer failed with message :"
+ + e.getMessage(), e);
+ throw new SampleException(e);
+ }
+ }
}
@Override
public void setChannelAttribute(int channel, String key, Object value) {
- super.setChannelAttribute(channel, key, value);
- // propagate attribute to all of this SampleConsumer consumers
- for (SampleConsumer c : sampleConsumers) {
- c.setChannelAttribute(channel, key, value);
- }
+ super.setChannelAttribute(channel, key, value);
+ // propagate attribute to all of this SampleConsumer consumers
+ for (SampleConsumer c : sampleConsumers) {
+ c.setChannelAttribute(channel, key, value);
+ }
}
@Override
public void setProducedMetadata(SampleMetadata metadata, int channel) {
- for (SampleConsumer consumer : this.sampleConsumers) {
- try {
- consumer.setConsumedMetadata(metadata, channel);
- } catch (Exception e) {
- log.error(
- "setProducedMetadata(): Consumer failed with message :"
- + e.getMessage(), e);
- throw new SampleException(e);
- }
- }
+ for (SampleConsumer consumer : this.sampleConsumers) {
+ try {
+ consumer.setConsumedMetadata(metadata, channel);
+ } catch (Exception e) {
+ log.error(
+ "setProducedMetadata(): Consumer failed with message :"
+ + e.getMessage(), e);
+ throw new SampleException(e);
+ }
+ }
}
protected SampleConsumer getConsumer(int i) {
- if (i < sampleConsumers.size()) {
- return sampleConsumers.get(i);
- } else {
- return null;
- }
+ if (i < sampleConsumers.size()) {
+ return sampleConsumers.get(i);
+ } else {
+ return null;
+ }
}
@Override
public void startProducing() {
- producedSampleCount = 0;
- for (SampleConsumer consumer : this.sampleConsumers) {
- try {
- consumer.startConsuming();
- } catch (Exception e) {
- log.error("startProducing(): Consumer failed with message :"
- + e.getMessage(), e);
- throw new SampleException(e);
- }
- }
+ producedSampleCount = 0;
+ for (SampleConsumer consumer : this.sampleConsumers) {
+ try {
+ consumer.startConsuming();
+ } catch (Exception e) {
+ log.error("startProducing(): Consumer failed with message :"
+ + e.getMessage(), e);
+ throw new SampleException(e);
+ }
+ }
}
@Override
public void produce(Sample s, int channel) {
- for (SampleConsumer consumer : this.sampleConsumers) {
- try {
- consumer.consume(s, channel);
- producedSampleCount++;
- } catch (Exception e) {
- log.error(
- "produce(): Consumer failed with message :"
- + e.getMessage(), e);
- throw new SampleException(e);
- }
- }
+ for (SampleConsumer consumer : this.sampleConsumers) {
+ try {
+ consumer.consume(s, channel);
+ producedSampleCount++;
+ } catch (Exception e) {
+ log.error(
+ "produce(): Consumer failed with message :"
+ + e.getMessage(), e);
+ throw new SampleException(e);
+ }
+ }
}
@Override
public void stopProducing() {
- for (SampleConsumer consumer : this.sampleConsumers) {
- try {
- consumer.stopConsuming();
- } catch (Exception e) {
- log.error(
- "stopProducing(): Consumer failed with message :"
- + e.getMessage(), e);
- throw new SampleException(e);
- }
- }
- if (log.isInfoEnabled()) {
- log.info("stopProducing(): " + getName() + " produced "
- + producedSampleCount + " samples");
- }
+ for (SampleConsumer consumer : this.sampleConsumers) {
+ try {
+ consumer.stopConsuming();
+ } catch (Exception e) {
+ log.error(
+ "stopProducing(): Consumer failed with message :"
+ + e.getMessage(), e);
+ throw new SampleException(e);
+ }
+ }
+ if (log.isInfoEnabled()) {
+ log.info("stopProducing(): " + getName() + " produced "
+ + producedSampleCount + " samples");
+ }
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleProcessor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleProcessor.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleProcessor.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleProcessor.java Thu Dec 10 18:55:22 2015
@@ -40,7 +40,7 @@ public class AbstractSampleProcessor imp
*/
@Override
public SampleContext getSampleContext() {
- return sampleContext;
+ return sampleContext;
}
/*
@@ -52,7 +52,7 @@ public class AbstractSampleProcessor imp
*/
@Override
public void setSampleContext(SampleContext sampleContext) {
- this.sampleContext = sampleContext;
+ this.sampleContext = sampleContext;
}
/**
@@ -65,11 +65,11 @@ public class AbstractSampleProcessor imp
* @return The channel context associated to the specified channel.
*/
private ChannelContext getChannelContext(int channel) {
- while (channelContexts.size() <= channel) {
- channelContexts.add(new ChannelContext());
- }
- ChannelContext out = channelContexts.get(channel);
- return out;
+ while (channelContexts.size() <= channel) {
+ channelContexts.add(new ChannelContext());
+ }
+ ChannelContext out = channelContexts.get(channel);
+ return out;
}
/*
@@ -81,7 +81,7 @@ public class AbstractSampleProcessor imp
*/
@Override
public void setChannelAttribute(int channel, String key, Object value) {
- getChannelContext(channel).put(key, value);
+ getChannelContext(channel).put(key, value);
}
/*
@@ -93,6 +93,6 @@ public class AbstractSampleProcessor imp
*/
@Override
public Object getChannelAttribute(int channel, String key) {
- return getChannelContext(channel).get(key);
+ return getChannelContext(channel).get(key);
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleSource.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleSource.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleSource.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSampleSource.java Thu Dec 10 18:55:22 2015
@@ -31,7 +31,7 @@ public abstract class AbstractSampleSour
* Instantiates a new abstract sample source.
*/
protected AbstractSampleSource() {
- // TODO Auto-generated constructor stub
+ // TODO Auto-generated constructor stub
}
/*
@@ -49,7 +49,7 @@ public abstract class AbstractSampleSour
*/
@Override
public SampleContext getSampleContext() {
- return sampleContext;
+ return sampleContext;
}
/*
@@ -61,7 +61,7 @@ public abstract class AbstractSampleSour
*/
@Override
public void setSampleContext(SampleContext sampleContext) {
- this.sampleContext = sampleContext;
+ this.sampleContext = sampleContext;
}
/*
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSummaryConsumer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSummaryConsumer.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSummaryConsumer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/AbstractSummaryConsumer.java Thu Dec 10 18:55:22 2015
@@ -37,47 +37,47 @@ public abstract class AbstractSummaryCon
* The class SummaryInfo stores intermediate results.
*/
protected class SummaryInfo {
- final boolean isController;
- TData data;
+ final boolean isController;
+ TData data;
- /**
- * Checks if these information implies controller sample.
- *
- * @return true, if is controller
- */
- public final boolean isController() {
- return isController;
- }
-
- /**
- * Gets the data to store.
- *
- * @return the data to store
- */
- public final TData getData() {
- return data;
- }
-
- /**
- * Sets the data to store.
- *
- * @param data
- * the new data to store
- */
- public final void setData(TData data) {
- this.data = data;
- }
-
- /**
- * Instantiates a new summary info.
- *
- * @param isController
- * true, if these information implies only controller
- * samples; false otherwise
- */
- public SummaryInfo(boolean isController) {
- this.isController = isController;
- }
+ /**
+ * Checks if these information implies controller sample.
+ *
+ * @return true, if is controller
+ */
+ public final boolean isController() {
+ return isController;
+ }
+
+ /**
+ * Gets the data to store.
+ *
+ * @return the data to store
+ */
+ public final TData getData() {
+ return data;
+ }
+
+ /**
+ * Sets the data to store.
+ *
+ * @param data
+ * the new data to store
+ */
+ public final void setData(TData data) {
+ this.data = data;
+ }
+
+ /**
+ * Instantiates a new summary info.
+ *
+ * @param isController
+ * true, if these information implies only controller
+ * samples; false otherwise
+ */
+ public SummaryInfo(boolean isController) {
+ this.isController = isController;
+ }
}
@@ -100,7 +100,7 @@ public abstract class AbstractSummaryCon
* @return true, if the result contains an overall item
*/
public final boolean hasOverallResult() {
- return hasOverallResult;
+ return hasOverallResult;
}
/**
@@ -110,7 +110,7 @@ public abstract class AbstractSummaryCon
* true, if the result contains an overall item; false otherwise
*/
public final void setHasOverallResult(boolean hasOverallResult) {
- this.hasOverallResult = hasOverallResult;
+ this.hasOverallResult = hasOverallResult;
}
/**
@@ -120,7 +120,7 @@ public abstract class AbstractSummaryCon
* otherwise.
*/
public final boolean suppportsControllersDiscrimination() {
- return supportsControllersDiscrimination;
+ return supportsControllersDiscrimination;
}
/**
@@ -129,7 +129,7 @@ public abstract class AbstractSummaryCon
* @return the overall info
*/
protected final SummaryInfo getOverallInfo() {
- return overallInfo;
+ return overallInfo;
}
/**
@@ -138,7 +138,7 @@ public abstract class AbstractSummaryCon
* @return the summary infos
*/
protected final Map<String, SummaryInfo> getSummaryInfos() {
- return infos;
+ return infos;
}
/**
@@ -149,7 +149,7 @@ public abstract class AbstractSummaryCon
* samples
*/
protected AbstractSummaryConsumer(boolean supportsControllersDiscrimination) {
- this.supportsControllersDiscrimination = supportsControllersDiscrimination;
+ this.supportsControllersDiscrimination = supportsControllersDiscrimination;
}
/**
@@ -189,16 +189,16 @@ public abstract class AbstractSummaryCon
protected abstract void updateData(SummaryInfo info, Sample sample);
private MapResultData createResultFromKey(String key) {
- SummaryInfo info = (key == null) ? overallInfo : infos.get(key);
- MapResultData result = null;
- TData data = info.getData();
- if (data != null) {
- result = new MapResultData();
- result.setResult(RESULT_VALUE_IS_CONTROLLER, new ValueResultData(
- info.isController()));
- result.setResult(RESULT_VALUE_DATA, createDataResult(key, data));
- }
- return result;
+ SummaryInfo info = (key == null) ? overallInfo : infos.get(key);
+ MapResultData result = null;
+ TData data = info.getData();
+ if (data != null) {
+ result = new MapResultData();
+ result.setResult(RESULT_VALUE_IS_CONTROLLER, new ValueResultData(
+ info.isController()));
+ result.setResult(RESULT_VALUE_DATA, createDataResult(key, data));
+ }
+ return result;
}
/*
@@ -209,12 +209,12 @@ public abstract class AbstractSummaryCon
@Override
public void startConsuming() {
- // Broadcast metadata to consumes for each channel
- int channelCount = getConsumedChannelCount();
- for (int i = 0; i < channelCount; i++) {
- super.setProducedMetadata(getConsumedMetadata(i), i);
- }
- super.startProducing();
+ // Broadcast metadata to consumes for each channel
+ int channelCount = getConsumedChannelCount();
+ for (int i = 0; i < channelCount; i++) {
+ super.setProducedMetadata(getConsumedMetadata(i), i);
+ }
+ super.startProducing();
}
/*
@@ -226,17 +226,17 @@ public abstract class AbstractSummaryCon
*/
@Override
public void consume(Sample sample, int channel) {
- String key = getKeyFromSample(sample);
+ String key = getKeyFromSample(sample);
- // Get the object to store counters or create it if it does not exist.
- SummaryInfo info = infos.get(key);
- if (info == null) {
- info = new SummaryInfo(supportsControllersDiscrimination
- && sample.isController());
- infos.put(key, info);
- }
- updateData(info, sample);
- super.produce(sample, channel);
+ // Get the object to store counters or create it if it does not exist.
+ SummaryInfo info = infos.get(key);
+ if (info == null) {
+ info = new SummaryInfo(supportsControllersDiscrimination
+ && sample.isController());
+ infos.put(key, info);
+ }
+ updateData(info, sample);
+ super.produce(sample, channel);
}
/*
@@ -246,41 +246,41 @@ public abstract class AbstractSummaryCon
*/
@Override
public void stopConsuming() {
- MapResultData result = new MapResultData();
+ MapResultData result = new MapResultData();
- // Push the support flag in the result
- result.setResult(RESULT_VALUE_SUPPORTS_CONTROLLERS_DISCRIMINATION,
- new ValueResultData(supportsControllersDiscrimination));
-
- // Add headers
- result.setResult(RESULT_VALUE_TITLES, createResultTitles());
-
- // Add overall row if needed
- if (hasOverallResult) {
- MapResultData overallResult = createResultFromKey(null);
- if (overallResult != null) {
- result.setResult(RESULT_VALUE_OVERALL, overallResult);
- }
- }
-
- // Build rows from samples
- ListResultData itemsResult = new ListResultData();
- for (String key : infos.keySet()) {
- // Add result only if data exist
- MapResultData keyResult = createResultFromKey(key);
- if (keyResult != null) {
- itemsResult.addResult(keyResult);
- }
- }
- result.setResult(RESULT_VALUE_ITEMS, itemsResult);
-
- // Store the result in the context
- setDataToContext(getName(), result);
-
- super.stopProducing();
-
- // Reset infos
- infos.clear();
- overallInfo.setData(null);
+ // Push the support flag in the result
+ result.setResult(RESULT_VALUE_SUPPORTS_CONTROLLERS_DISCRIMINATION,
+ new ValueResultData(supportsControllersDiscrimination));
+
+ // Add headers
+ result.setResult(RESULT_VALUE_TITLES, createResultTitles());
+
+ // Add overall row if needed
+ if (hasOverallResult) {
+ MapResultData overallResult = createResultFromKey(null);
+ if (overallResult != null) {
+ result.setResult(RESULT_VALUE_OVERALL, overallResult);
+ }
+ }
+
+ // Build rows from samples
+ ListResultData itemsResult = new ListResultData();
+ for (String key : infos.keySet()) {
+ // Add result only if data exist
+ MapResultData keyResult = createResultFromKey(key);
+ if (keyResult != null) {
+ itemsResult.addResult(keyResult);
+ }
+ }
+ result.setResult(RESULT_VALUE_ITEMS, itemsResult);
+
+ // Store the result in the context
+ setDataToContext(getName(), result);
+
+ super.stopProducing();
+
+ // Reset infos
+ infos.clear();
+ overallInfo.setData(null);
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/AggregateConsumer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/AggregateConsumer.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/AggregateConsumer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/AggregateConsumer.java Thu Dec 10 18:55:22 2015
@@ -41,7 +41,7 @@ public class AggregateConsumer extends A
* @return the aggregator
*/
public final Aggregator getAggregator() {
- return aggregator;
+ return aggregator;
}
/**
@@ -50,7 +50,7 @@ public class AggregateConsumer extends A
* @return the selector
*/
public final SampleSelector<Double> getSelector() {
- return selector;
+ return selector;
}
/**
@@ -62,16 +62,16 @@ public class AggregateConsumer extends A
* the selector
*/
public AggregateConsumer(Aggregator aggregator,
- SampleSelector<Double> selector) {
- if (aggregator == null) {
- throw new ArgumentNullException("aggregator");
- }
- if (selector == null) {
- throw new ArgumentNullException("selector");
- }
+ SampleSelector<Double> selector) {
+ if (aggregator == null) {
+ throw new ArgumentNullException("aggregator");
+ }
+ if (selector == null) {
+ throw new ArgumentNullException("selector");
+ }
- this.aggregator = aggregator;
- this.selector = selector;
+ this.aggregator = aggregator;
+ this.selector = selector;
}
/*
@@ -81,13 +81,13 @@ public class AggregateConsumer extends A
*/
@Override
public void startConsuming() {
- // Broadcast metadata to consumes for each channel
- int channelCount = getConsumedChannelCount();
- for (int i = 0; i < channelCount; i++) {
- super.setProducedMetadata(getConsumedMetadata(i), i);
- }
+ // Broadcast metadata to consumes for each channel
+ int channelCount = getConsumedChannelCount();
+ for (int i = 0; i < channelCount; i++) {
+ super.setProducedMetadata(getConsumedMetadata(i), i);
+ }
- super.startProducing();
+ super.startProducing();
}
/*
@@ -99,8 +99,8 @@ public class AggregateConsumer extends A
*/
@Override
public void consume(Sample sample, int channel) {
- aggregator.addValue(selector.select(sample));
- super.produce(sample, channel);
+ aggregator.addValue(selector.select(sample));
+ super.produce(sample, channel);
}
/*
@@ -110,8 +110,8 @@ public class AggregateConsumer extends A
*/
@Override
public void stopConsuming() {
- setDataToContext(getName(), new ValueResultData(aggregator.getResult()));
- super.stopProducing();
+ setDataToContext(getName(), new ValueResultData(aggregator.getResult()));
+ super.stopProducing();
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryConsumer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryConsumer.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryConsumer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryConsumer.java Thu Dec 10 18:55:22 2015
@@ -44,7 +44,7 @@ public class ApdexSummaryConsumer extend
* @return the threshold selector
*/
public final ThresholdSelector getThresholdSelector() {
- return thresholdSelector;
+ return thresholdSelector;
}
/**
@@ -54,26 +54,26 @@ public class ApdexSummaryConsumer extend
* the APDEX threshold selector to set
*/
public final void setThresholdSelector(ThresholdSelector thresholdSelector) {
- this.thresholdSelector = thresholdSelector;
+ this.thresholdSelector = thresholdSelector;
}
public ApdexSummaryConsumer() {
- super(true);
+ super(true);
}
@Override
protected ListResultData createDataResult(String key, ApdexSummaryData data) {
- ListResultData result = new ListResultData();
- result.addResult(new ValueResultData(getApdex(data)));
- ApdexThresholdsInfo thresholdsInfo = data.getApdexThresholdInfo();
- result.addResult(new ValueResultData(thresholdsInfo
- .getSatisfiedThreshold()));
- result.addResult(new ValueResultData(thresholdsInfo
- .getToleratedThreshold()));
- result.addResult(new ValueResultData(key != null ? key : JMeterUtils
- .getResString("reportgenerator_summary_total")));
+ ListResultData result = new ListResultData();
+ result.addResult(new ValueResultData(getApdex(data)));
+ ApdexThresholdsInfo thresholdsInfo = data.getApdexThresholdInfo();
+ result.addResult(new ValueResultData(thresholdsInfo
+ .getSatisfiedThreshold()));
+ result.addResult(new ValueResultData(thresholdsInfo
+ .getToleratedThreshold()));
+ result.addResult(new ValueResultData(key != null ? key : JMeterUtils
+ .getResString("reportgenerator_summary_total")));
- return result;
+ return result;
}
/*
@@ -85,7 +85,7 @@ public class ApdexSummaryConsumer extend
*/
@Override
protected String getKeyFromSample(Sample sample) {
- return sample.getName();
+ return sample.getName();
}
/*
@@ -99,57 +99,57 @@ public class ApdexSummaryConsumer extend
@Override
protected void updateData(SummaryInfo info, Sample sample) {
- // Initialize overall data if they don't exist
- SummaryInfo overallInfo = getOverallInfo();
- ApdexSummaryData overallData = overallInfo.getData();
- if (overallData == null) {
- overallData = new ApdexSummaryData(getThresholdSelector().select(
- null));
- overallInfo.setData(overallData);
- }
-
- // Initialize info data if they don't exist
- ApdexSummaryData data = info.getData();
- if (data == null) {
- data = new ApdexSummaryData(getThresholdSelector().select(
- sample.getName()));
- info.setData(data);
- }
-
- // Increment the total count of samples with the current name
- data.IncTotalCount();
-
- // Increment the total count of samples
- overallData.IncTotalCount();
-
- // Process only succeeded samples
- if (sample.getSuccess()) {
- long elapsedTime = sample.getElapsedTime();
-
- // Increment the counters depending on the elapsed time.
- ApdexThresholdsInfo thresholdsInfo = data.getApdexThresholdInfo();
- if (elapsedTime <= thresholdsInfo.getSatisfiedThreshold()) {
- data.IncSatisfiedCount();
- } else if (elapsedTime <= thresholdsInfo.getToleratedThreshold()) {
- data.IncToleratedCount();
- }
-
- // Increment the overall counters depending on the elapsed time.
- ApdexThresholdsInfo overallThresholdsInfo = overallData
- .getApdexThresholdInfo();
- if (elapsedTime <= overallThresholdsInfo.getSatisfiedThreshold()) {
- overallData.IncSatisfiedCount();
- } else if (elapsedTime <= overallThresholdsInfo
- .getToleratedThreshold()) {
- overallData.IncToleratedCount();
- }
- }
+ // Initialize overall data if they don't exist
+ SummaryInfo overallInfo = getOverallInfo();
+ ApdexSummaryData overallData = overallInfo.getData();
+ if (overallData == null) {
+ overallData = new ApdexSummaryData(getThresholdSelector().select(
+ null));
+ overallInfo.setData(overallData);
+ }
+
+ // Initialize info data if they don't exist
+ ApdexSummaryData data = info.getData();
+ if (data == null) {
+ data = new ApdexSummaryData(getThresholdSelector().select(
+ sample.getName()));
+ info.setData(data);
+ }
+
+ // Increment the total count of samples with the current name
+ data.IncTotalCount();
+
+ // Increment the total count of samples
+ overallData.IncTotalCount();
+
+ // Process only succeeded samples
+ if (sample.getSuccess()) {
+ long elapsedTime = sample.getElapsedTime();
+
+ // Increment the counters depending on the elapsed time.
+ ApdexThresholdsInfo thresholdsInfo = data.getApdexThresholdInfo();
+ if (elapsedTime <= thresholdsInfo.getSatisfiedThreshold()) {
+ data.IncSatisfiedCount();
+ } else if (elapsedTime <= thresholdsInfo.getToleratedThreshold()) {
+ data.IncToleratedCount();
+ }
+
+ // Increment the overall counters depending on the elapsed time.
+ ApdexThresholdsInfo overallThresholdsInfo = overallData
+ .getApdexThresholdInfo();
+ if (elapsedTime <= overallThresholdsInfo.getSatisfiedThreshold()) {
+ overallData.IncSatisfiedCount();
+ } else if (elapsedTime <= overallThresholdsInfo
+ .getToleratedThreshold()) {
+ overallData.IncToleratedCount();
+ }
+ }
}
private double getApdex(ApdexSummaryData data) {
- return (data.getSatisfiedCount() + (double) data.getToleratedCount() / 2)
- / data.getTotalCount();
+ return (data.getSatisfiedCount() + (double) data.getToleratedCount() / 2)
+ / data.getTotalCount();
}
/*
@@ -161,16 +161,16 @@ public class ApdexSummaryConsumer extend
*/
@Override
protected ListResultData createResultTitles() {
- ListResultData titles = new ListResultData();
- titles.addResult(new ValueResultData(JMeterUtils
- .getResString("reportgenerator_summary_apdex_apdex")));
- titles.addResult(new ValueResultData(JMeterUtils
- .getResString("reportgenerator_summary_apdex_satisfied")));
- titles.addResult(new ValueResultData(JMeterUtils
- .getResString("reportgenerator_summary_apdex_tolerated")));
- titles.addResult(new ValueResultData(JMeterUtils
- .getResString("reportgenerator_summary_apdex_samplers")));
- return titles;
+ ListResultData titles = new ListResultData();
+ titles.addResult(new ValueResultData(JMeterUtils
+ .getResString("reportgenerator_summary_apdex_apdex")));
+ titles.addResult(new ValueResultData(JMeterUtils
+ .getResString("reportgenerator_summary_apdex_satisfied")));
+ titles.addResult(new ValueResultData(JMeterUtils
+ .getResString("reportgenerator_summary_apdex_tolerated")));
+ titles.addResult(new ValueResultData(JMeterUtils
+ .getResString("reportgenerator_summary_apdex_samplers")));
+ return titles;
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryData.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryData.java?rev=1719183&r1=1719182&r2=1719183&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryData.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexSummaryData.java Thu Dec 10 18:55:22 2015
@@ -30,7 +30,7 @@ public class ApdexSummaryData {
private long totalCount;
public final ApdexThresholdsInfo getApdexThresholdInfo() {
- return apdexThresholdInfo;
+ return apdexThresholdInfo;
}
/**
@@ -39,7 +39,7 @@ public class ApdexSummaryData {
* @return the satisfiedCount
*/
public final long getSatisfiedCount() {
- return satisfiedCount;
+ return satisfiedCount;
}
/**
@@ -49,14 +49,14 @@ public class ApdexSummaryData {
* the satisfiedCount to set
*/
public final void setSatisfiedCount(long satisfiedCount) {
- this.satisfiedCount = satisfiedCount;
+ this.satisfiedCount = satisfiedCount;
}
/**
* @return the toleratedCount
*/
public final long getToleratedCount() {
- return toleratedCount;
+ return toleratedCount;
}
/**
@@ -66,7 +66,7 @@ public class ApdexSummaryData {
* the toleratedCount to set
*/
public final void setToleratedCount(long toleratedCount) {
- this.toleratedCount = toleratedCount;
+ this.toleratedCount = toleratedCount;
}
/**
@@ -75,7 +75,7 @@ public class ApdexSummaryData {
* @return the totalCount
*/
public final long getTotalCount() {
- return totalCount;
+ return totalCount;
}
/**
@@ -83,7 +83,7 @@ public class ApdexSummaryData {
* the totalCount to set
*/
public final void setTotalCount(long totalCount) {
- this.totalCount = totalCount;
+ this.totalCount = totalCount;
}
/**
@@ -93,18 +93,18 @@ public class ApdexSummaryData {
* the threshold information
*/
public ApdexSummaryData(ApdexThresholdsInfo info) {
- apdexThresholdInfo = info;
+ apdexThresholdInfo = info;
}
public void IncSatisfiedCount() {
- satisfiedCount++;
+ satisfiedCount++;
}
public void IncToleratedCount() {
- toleratedCount++;
+ toleratedCount++;
}
public void IncTotalCount() {
- totalCount++;
+ totalCount++;
}
}