Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexThresholdsInfo.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexThresholdsInfo.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexThresholdsInfo.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/ApdexThresholdsInfo.java Thu Dec 10 18:55:22 2015 @@ -33,7 +33,7 @@ public class ApdexThresholdsInfo { * @return the satisfied threshold */ public final long getSatisfiedThreshold() { - return satisfiedThreshold; + return satisfiedThreshold; } /** @@ -43,7 +43,7 @@ public class ApdexThresholdsInfo { * the satisfied threshold to set */ public final void setSatisfiedThreshold(long satisfiedThreshold) { - this.satisfiedThreshold = satisfiedThreshold; + this.satisfiedThreshold = satisfiedThreshold; } /** @@ -52,7 +52,7 @@ public class ApdexThresholdsInfo { * @return the tolerated threshold */ public final long getToleratedThreshold() { - return toleratedThreshold; + return toleratedThreshold; } /** @@ -62,6 +62,6 @@ public class ApdexThresholdsInfo { * the tolerated threshold to set */ public final void setToleratedThreshold(long toleratedThreshold) { - this.toleratedThreshold = toleratedThreshold; + this.toleratedThreshold = toleratedThreshold; } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/CsvFileSampleSource.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/CsvFileSampleSource.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/CsvFileSampleSource.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/CsvFileSampleSource.java Thu Dec 10 18:55:22 2015 @@ -67,7 +67,7 @@ public class CsvFileSampleSource extends public static final String SOURCE_FILE_ATTRIBUTE = "samplesource.file"; private static final Logger log = LoggerFactory - .getLogger(CsvFileSampleSource.class); + .getLogger(CsvFileSampleSource.class); /** input csv files to be produced */ private File[] inputFiles; @@ -89,72 +89,72 @@ public class CsvFileSampleSource extends * columns */ public CsvFileSampleSource(final File inputFile, final char separator) { - if (inputFile == null) { - throw new ArgumentNullException("inputFile"); - } - - final String inputRootName = getFileRootName(inputFile.getName()); - final String inputExtension = getFileExtension(inputFile.getName()); - - // Find secondary inputs by regex match - File[] secondaryInputs = null; - try { - final Pattern pattern = Pattern.compile(inputRootName - + "-[0-9]+\\." + inputExtension); - secondaryInputs = inputFile.getAbsoluteFile().getParentFile() - .listFiles(new FileFilter() { - - @Override - public boolean accept(File pathname) { - return pathname.isFile() - && pattern.matcher(pathname.getName()) - .matches(); - } - }); - } catch (PatternSyntaxException e) { - throw new SampleException("Could not locate input sample files !", - e); - } - inputFiles = new File[secondaryInputs.length + 1]; - csvReaders = new CsvSampleReader[secondaryInputs.length + 1]; - int k = 0; - // primary input file (ex. input.csv) - csvReaders[k] = new CsvSampleReader(inputFile, separator, true); - inputFiles[k] = inputFile; - // secondary input files (ex. input-1.csv, input-2.csv, input-3.csv) - for (File input : secondaryInputs) { - k++; - csvReaders[k] = new CsvSampleReader(input, separator, true); - inputFiles[k] = secondaryInputs[k - 1]; - } - producer = new PrivateProducer(); + if (inputFile == null) { + throw new ArgumentNullException("inputFile"); + } + + final String inputRootName = getFileRootName(inputFile.getName()); + final String inputExtension = getFileExtension(inputFile.getName()); + + // Find secondary inputs by regex match + File[] secondaryInputs = null; + try { + final Pattern pattern = Pattern.compile(inputRootName + + "-[0-9]+\\." + inputExtension); + secondaryInputs = inputFile.getAbsoluteFile().getParentFile() + .listFiles(new FileFilter() { + + @Override + public boolean accept(File pathname) { + return pathname.isFile() + && pattern.matcher(pathname.getName()) + .matches(); + } + }); + } catch (PatternSyntaxException e) { + throw new SampleException("Could not locate input sample files !", + e); + } + inputFiles = new File[secondaryInputs.length + 1]; + csvReaders = new CsvSampleReader[secondaryInputs.length + 1]; + int k = 0; + // primary input file (ex. input.csv) + csvReaders[k] = new CsvSampleReader(inputFile, separator, true); + inputFiles[k] = inputFile; + // secondary input files (ex. input-1.csv, input-2.csv, input-3.csv) + for (File input : secondaryInputs) { + k++; + csvReaders[k] = new CsvSampleReader(input, separator, true); + inputFiles[k] = secondaryInputs[k - 1]; + } + producer = new PrivateProducer(); } private static String getFileRootName(String fName) { - int idx = fName.lastIndexOf('.'); - if (idx < 0) { - return fName; - } - fName = fName.substring(0, idx); - return fName; + int idx = fName.lastIndexOf('.'); + if (idx < 0) { + return fName; + } + fName = fName.substring(0, idx); + return fName; } private static String getFileExtension(String fName) { - int idx = fName.lastIndexOf('.'); - if (idx < 0) { - return ""; - } - if (idx < fName.length() - 1) { - return fName.substring(idx + 1); - } - return ""; + int idx = fName.lastIndexOf('.'); + if (idx < 0) { + return ""; + } + if (idx < fName.length() - 1) { + return fName.substring(idx + 1); + } + return ""; } /** * Get the current time in milliseconds */ private final long now() { - return System.currentTimeMillis(); + return System.currentTimeMillis(); } /** @@ -165,7 +165,7 @@ public class CsvFileSampleSource extends * milliseconds */ private final String time(long t) { - return TimeHelper.time(t); + return TimeHelper.time(t); } /** @@ -173,37 +173,37 @@ public class CsvFileSampleSource extends * consumers */ private void produce() { - SampleContext context = getSampleContext(); - if (context == null) { - throw new IllegalStateException( - "Set a sample context before produce samples."); - } - - for (int i = 0; i < csvReaders.length; i++) { - long sampleCount = 0; - long start = now(); - CsvSampleReader csvReader = csvReaders[i]; - producer.setSampleContext(context); - producer.setProducedMetadata(csvReader.getMetadata(), i); - producer.setChannelAttribute(i, SOURCE_FILE_ATTRIBUTE, - inputFiles[i]); - producer.startProducing(); - try { - Sample s = null; - while ((s = csvReader.readSample()) != null) { - producer.produce(s, i); - sampleCount++; - } - } finally { - producer.stopProducing(); - csvReader.close(); - } - long time = now() - start; - if (log.isInfoEnabled()) { - log.info("produce(): " + sampleCount + " samples produced in " - + time(time) + " on channel " + i); - } - } + SampleContext context = getSampleContext(); + if (context == null) { + throw new IllegalStateException( + "Set a sample context before produce samples."); + } + + for (int i = 0; i < csvReaders.length; i++) { + long sampleCount = 0; + long start = now(); + CsvSampleReader csvReader = csvReaders[i]; + producer.setSampleContext(context); + producer.setProducedMetadata(csvReader.getMetadata(), i); + producer.setChannelAttribute(i, SOURCE_FILE_ATTRIBUTE, + inputFiles[i]); + producer.startProducing(); + try { + Sample s = null; + while ((s = csvReader.readSample()) != null) { + producer.produce(s, i); + sampleCount++; + } + } finally { + producer.stopProducing(); + csvReader.close(); + } + long time = now() - start; + if (log.isInfoEnabled()) { + log.info("produce(): " + sampleCount + " samples produced in " + + time(time) + " on channel " + i); + } + } } /* @@ -215,7 +215,7 @@ public class CsvFileSampleSource extends */ @Override public void setSampleConsumers(List consumers) { - producer.setSampleConsumers(consumers); + producer.setSampleConsumers(consumers); } /* @@ -227,7 +227,7 @@ public class CsvFileSampleSource extends */ @Override public void addSampleConsumer(SampleConsumer consumer) { - producer.addSampleConsumer(consumer); + producer.addSampleConsumer(consumer); } /* @@ -239,7 +239,7 @@ public class CsvFileSampleSource extends */ @Override public void removeSampleConsumer(SampleConsumer consumer) { - producer.removeSampleConsumer(consumer); + producer.removeSampleConsumer(consumer); } /** @@ -249,120 +249,120 @@ public class CsvFileSampleSource extends */ @Override public void run() { - produce(); + produce(); } private class PrivateProducer extends AbstractSampleProcessor implements - SampleProducer { + SampleProducer { - private List sampleConsumers = new ArrayList<>(); + private List sampleConsumers = new ArrayList<>(); - public void setSampleConsumers(List consumers) { - if (consumers == null) { - throw new ArgumentNullException("consumers"); - } - - this.sampleConsumers = consumers; - } - - public void addSampleConsumer(SampleConsumer consumer) { - if (consumer == null) { - return; - } - this.sampleConsumers.add(consumer); - } - - public void removeSampleConsumer(SampleConsumer consumer) { - if (consumer == null) { - return; - } - this.sampleConsumers.remove(consumer); - } - - @Override - public void setSampleContext(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); - } - } - } - - @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); - } - } - } - - @Override - public void setChannelAttribute(int channel, String key, Object value) { - super.setChannelAttribute(channel, key, value); - // propagate to this mock producer's consumers - for (SampleConsumer consumer : this.sampleConsumers) { - try { - consumer.setChannelAttribute(channel, key, value); - } catch (Exception e) { - log.error( - "setChannelAttribute(): Consumer failed with message :" - + e.getMessage(), e); - throw new SampleException(e); - } - } - } - - @Override - public void startProducing() { - 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); - } 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); - } - } - } + public void setSampleConsumers(List consumers) { + if (consumers == null) { + throw new ArgumentNullException("consumers"); + } + + this.sampleConsumers = consumers; + } + + public void addSampleConsumer(SampleConsumer consumer) { + if (consumer == null) { + return; + } + this.sampleConsumers.add(consumer); + } + + public void removeSampleConsumer(SampleConsumer consumer) { + if (consumer == null) { + return; + } + this.sampleConsumers.remove(consumer); + } + + @Override + public void setSampleContext(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); + } + } + } + + @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); + } + } + } + + @Override + public void setChannelAttribute(int channel, String key, Object value) { + super.setChannelAttribute(channel, key, value); + // propagate to this mock producer's consumers + for (SampleConsumer consumer : this.sampleConsumers) { + try { + consumer.setChannelAttribute(channel, key, value); + } catch (Exception e) { + log.error( + "setChannelAttribute(): Consumer failed with message :" + + e.getMessage(), e); + throw new SampleException(e); + } + } + } + + @Override + public void startProducing() { + 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); + } 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); + } + } + } } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/ErrorsSummaryConsumer.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/ErrorsSummaryConsumer.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/ErrorsSummaryConsumer.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/ErrorsSummaryConsumer.java Thu Dec 10 18:55:22 2015 @@ -40,7 +40,7 @@ public class ErrorsSummaryConsumer exten * Instantiates a new errors summary consumer. */ public ErrorsSummaryConsumer() { - super(false); + super(false); } /* @@ -52,14 +52,14 @@ public class ErrorsSummaryConsumer exten */ @Override protected ListResultData createDataResult(String key, Long data) { - ListResultData result = new ListResultData(); - result.addResult(new ValueResultData(key != null ? key : JMeterUtils - .getResString("reportgenerator_summary_total"))); - result.addResult(new ValueResultData(data)); - result.addResult(new ValueResultData((double) data * 100 / errorCount)); - result.addResult(new ValueResultData((double) data * 100 - / getOverallInfo().getData())); - return result; + ListResultData result = new ListResultData(); + result.addResult(new ValueResultData(key != null ? key : JMeterUtils + .getResString("reportgenerator_summary_total"))); + result.addResult(new ValueResultData(data)); + result.addResult(new ValueResultData((double) data * 100 / errorCount)); + result.addResult(new ValueResultData((double) data * 100 + / getOverallInfo().getData())); + return result; } /* @@ -71,20 +71,20 @@ public class ErrorsSummaryConsumer exten */ @Override protected String getKeyFromSample(Sample sample) { - String code = sample.getResponseCode(); - if (isSuccessCode(code)) { - code = ASSERTION_FAILED; - if (JMeterUtils - .getPropDefault( - SampleSaveConfiguration.ASSERTION_RESULTS_FAILURE_MESSAGE_PROP, - false)) { - String msg = sample.getFailureMessage(); - if (!StringUtils.isEmpty(msg)) { - code = StringEscapeUtils.escapeJson(msg); - } - } - } - return code; + String code = sample.getResponseCode(); + if (isSuccessCode(code)) { + code = ASSERTION_FAILED; + if (JMeterUtils + .getPropDefault( + SampleSaveConfiguration.ASSERTION_RESULTS_FAILURE_MESSAGE_PROP, + false)) { + String msg = sample.getFailureMessage(); + if (!StringUtils.isEmpty(msg)) { + code = StringEscapeUtils.escapeJson(msg); + } + } + } + return code; } /* @@ -97,24 +97,24 @@ public class ErrorsSummaryConsumer exten */ @Override protected void updateData(SummaryInfo info, Sample sample) { - // Initialize overall data if they don't exist - SummaryInfo overallInfo = getOverallInfo(); - Long overallData = overallInfo.getData(); - if (overallData == null) { - overallData = Long.valueOf(0); - } - overallInfo.setData(overallData + 1); - - // Process only failed samples - if (!sample.getSuccess()) { - errorCount++; - - Long data = info.getData(); - if (data == null) { - data = Long.valueOf(1); - } - info.setData(data + 1); - } + // Initialize overall data if they don't exist + SummaryInfo overallInfo = getOverallInfo(); + Long overallData = overallInfo.getData(); + if (overallData == null) { + overallData = Long.valueOf(0); + } + overallInfo.setData(overallData + 1); + + // Process only failed samples + if (!sample.getSuccess()) { + errorCount++; + + Long data = info.getData(); + if (data == null) { + data = Long.valueOf(1); + } + info.setData(data + 1); + } } /** @@ -129,15 +129,15 @@ public class ErrorsSummaryConsumer exten * protocol */ protected boolean isSuccessCode(String codeAsString) { - if (StringUtils.isNumeric(codeAsString)) { - try { - int code = Integer.parseInt(codeAsString); - return (code >= 200 && code <= 399); - } catch (NumberFormatException ex) { - return false; - } - } - return false; + if (StringUtils.isNumeric(codeAsString)) { + try { + int code = Integer.parseInt(codeAsString); + return (code >= 200 && code <= 399); + } catch (NumberFormatException ex) { + return false; + } + } + return false; } /* @@ -147,10 +147,10 @@ public class ErrorsSummaryConsumer exten */ @Override public void stopConsuming() { - super.stopConsuming(); + super.stopConsuming(); - // Reset state - errorCount = 0L; + // Reset state + errorCount = 0L; } /* @@ -162,15 +162,15 @@ public class ErrorsSummaryConsumer exten */ @Override protected ListResultData createResultTitles() { - ListResultData titles = new ListResultData(); - titles.addResult(new ValueResultData(JMeterUtils - .getResString("reportgenerator_summary_errors_type"))); - titles.addResult(new ValueResultData(JMeterUtils - .getResString("reportgenerator_summary_errors_count"))); - titles.addResult(new ValueResultData(JMeterUtils - .getResString("reportgenerator_summary_errors_rate_error"))); - titles.addResult(new ValueResultData(JMeterUtils - .getResString("reportgenerator_summary_errors_rate_all"))); - return titles; + ListResultData titles = new ListResultData(); + titles.addResult(new ValueResultData(JMeterUtils + .getResString("reportgenerator_summary_errors_type"))); + titles.addResult(new ValueResultData(JMeterUtils + .getResString("reportgenerator_summary_errors_count"))); + titles.addResult(new ValueResultData(JMeterUtils + .getResString("reportgenerator_summary_errors_rate_error"))); + titles.addResult(new ValueResultData(JMeterUtils + .getResString("reportgenerator_summary_errors_rate_all"))); + return titles; } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/ExternalSampleSorter.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/ExternalSampleSorter.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/ExternalSampleSorter.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/ExternalSampleSorter.java Thu Dec 10 18:55:22 2015 @@ -82,7 +82,7 @@ import org.slf4j.LoggerFactory; public class ExternalSampleSorter extends AbstractSampleConsumer { private static final Logger log = LoggerFactory - .getLogger(ExternalSampleSorter.class); + .getLogger(ExternalSampleSorter.class); private static final int DEFAULT_CHUNK_SIZE = 50000; @@ -111,17 +111,17 @@ public class ExternalSampleSorter extend private boolean revertedSort; public ExternalSampleSorter() { - chunkSize = DEFAULT_CHUNK_SIZE; - this.nbProcessors = Runtime.getRuntime().availableProcessors(); - this.parallelize = nbProcessors > 1; - this.pool = new ThreadPoolExecutor(nbProcessors, nbProcessors + 5, 10, - TimeUnit.SECONDS, workQueue); - setRevertedSort(false); + chunkSize = DEFAULT_CHUNK_SIZE; + this.nbProcessors = Runtime.getRuntime().availableProcessors(); + this.parallelize = nbProcessors > 1; + this.pool = new ThreadPoolExecutor(nbProcessors, nbProcessors + 5, 10, + TimeUnit.SECONDS, workQueue); + setRevertedSort(false); } public ExternalSampleSorter(SampleComparator comparator) { - this(); - setSampleComparator(comparator); + this(); + setSampleComparator(comparator); } /** @@ -135,17 +135,17 @@ public class ExternalSampleSorter extend * provided chunkSize is <5000 */ public void setChunkSize(long chunkSize) { - if (chunkSize < 50000) { - chunkSize = 50000; - } - this.chunkSize = chunkSize; + if (chunkSize < 50000) { + chunkSize = 50000; + } + this.chunkSize = chunkSize; } /** * Set the sample comparator that will define sample ordering */ public void setSampleComparator(SampleComparator sampleComparator) { - this.sampleComparator = sampleComparator; + this.sampleComparator = sampleComparator; } /** @@ -155,11 +155,11 @@ public class ExternalSampleSorter extend * true to enable, false to disable */ public void setParallelize(boolean parallelize) { - this.parallelize = parallelize; + this.parallelize = parallelize; } public boolean isParallelize() { - return parallelize; + return parallelize; } /** @@ -177,31 +177,31 @@ public class ExternalSampleSorter extend * Wether the CSV header should be written in the output CSV file */ public void sort(CsvFile inputFile, File outputFile, boolean writeHeader) { - if (inputFile == null) { - throw new ArgumentNullException("inputFile"); - } - - if (outputFile == null) { - throw new ArgumentNullException("outputFile"); - } - - if (!inputFile.isFile()) { - throw new SampleException( - inputFile.getAbsolutePath() - + " does not exist or is not a file. Please provide an existing samples file"); - } - if (outputFile.isDirectory()) { - throw new SampleException( - outputFile.getAbsolutePath() - + " is a directory. Please provide a valid output sample file path (not a directory)"); - } - CsvSampleReader csvReader = new CsvSampleReader(inputFile, - inputFile.getSeparator(), false); - try { - sort(csvReader, outputFile, writeHeader); - } finally { - csvReader.close(); - } + if (inputFile == null) { + throw new ArgumentNullException("inputFile"); + } + + if (outputFile == null) { + throw new ArgumentNullException("outputFile"); + } + + if (!inputFile.isFile()) { + throw new SampleException( + inputFile.getAbsolutePath() + + " does not exist or is not a file. Please provide an existing samples file"); + } + if (outputFile.isDirectory()) { + throw new SampleException( + outputFile.getAbsolutePath() + + " is a directory. Please provide a valid output sample file path (not a directory)"); + } + CsvSampleReader csvReader = new CsvSampleReader(inputFile, + inputFile.getSeparator(), false); + try { + sort(csvReader, outputFile, writeHeader); + } finally { + csvReader.close(); + } } /** @@ -220,36 +220,36 @@ public class ExternalSampleSorter extend * sample metadata) */ public void sort(SampleMetadata sampleMetadata, File inputFile, - File outputFile, boolean writeHeader) { - if (sampleMetadata == null) { - throw new ArgumentNullException("sampleMetadata"); - } - - if (inputFile == null) { - throw new ArgumentNullException("inputFile"); - } - - if (outputFile == null) { - throw new ArgumentNullException("outputFile"); - } - - if (!inputFile.isFile()) { - throw new SampleException( - inputFile.getAbsolutePath() - + " does not exist or is not a file. Please provide an existing samples file"); - } - if (outputFile.isDirectory()) { - throw new SampleException( - outputFile.getAbsolutePath() - + " is a directory. Please provide a valid output sample file path (not a directory)"); - } - CsvSampleReader csvReader = new CsvSampleReader(inputFile, - sampleMetadata); - try { - sort(csvReader, outputFile, writeHeader); - } finally { - csvReader.close(); - } + File outputFile, boolean writeHeader) { + if (sampleMetadata == null) { + throw new ArgumentNullException("sampleMetadata"); + } + + if (inputFile == null) { + throw new ArgumentNullException("inputFile"); + } + + if (outputFile == null) { + throw new ArgumentNullException("outputFile"); + } + + if (!inputFile.isFile()) { + throw new SampleException( + inputFile.getAbsolutePath() + + " does not exist or is not a file. Please provide an existing samples file"); + } + if (outputFile.isDirectory()) { + throw new SampleException( + outputFile.getAbsolutePath() + + " is a directory. Please provide a valid output sample file path (not a directory)"); + } + CsvSampleReader csvReader = new CsvSampleReader(inputFile, + sampleMetadata); + try { + sort(csvReader, outputFile, writeHeader); + } finally { + csvReader.close(); + } } /** @@ -264,254 +264,254 @@ public class ExternalSampleSorter extend * Wether to writer CSV header on the output file */ private void sort(CsvSampleReader csvReader, File output, - boolean writeHeader) { - if (csvReader == null) { - throw new ArgumentNullException("csvReader"); - } - - if (output == null) { - throw new ArgumentNullException("output"); - } - - SampleMetadata sampleMetadata = csvReader.getMetadata(); - SampleWriterConsumer writerConsumer = new SampleWriterConsumer(); - writerConsumer.setOutputFile(output); - writerConsumer.setWriteHeader(writeHeader); - addSampleConsumer(writerConsumer); - try { - super.setConsumedMetadata(sampleMetadata, 0); - startConsuming(); - Sample s = null; - while ((s = csvReader.readSample()) != null) { - consume(s, 0); - } - stopConsuming(); - } finally { - removeSampleConsumer(writerConsumer); - } + boolean writeHeader) { + if (csvReader == null) { + throw new ArgumentNullException("csvReader"); + } + + if (output == null) { + throw new ArgumentNullException("output"); + } + + SampleMetadata sampleMetadata = csvReader.getMetadata(); + SampleWriterConsumer writerConsumer = new SampleWriterConsumer(); + writerConsumer.setOutputFile(output); + writerConsumer.setWriteHeader(writeHeader); + addSampleConsumer(writerConsumer); + try { + super.setConsumedMetadata(sampleMetadata, 0); + startConsuming(); + Sample s = null; + while ((s = csvReader.readSample()) != null) { + consume(s, 0); + } + stopConsuming(); + } finally { + removeSampleConsumer(writerConsumer); + } } @Override public void startConsuming() { - if (sampleComparator == null) { - throw new IllegalStateException( - "sampleComparator is not set, call setSampleComparator() first."); - } - - File workDir = getWorkingDirectory(); - workDir.mkdir(); - this.pool.prestartAllCoreThreads(); - inputSampleCount = 0; - chunkedSampleCount = 0; - chunks = new LinkedList<>(); - samples = new LinkedList<>(); - sampleMetadata = getConsumedMetadata(0); - sampleComparator.initialize(sampleMetadata); + if (sampleComparator == null) { + throw new IllegalStateException( + "sampleComparator is not set, call setSampleComparator() first."); + } + + File workDir = getWorkingDirectory(); + workDir.mkdir(); + this.pool.prestartAllCoreThreads(); + inputSampleCount = 0; + chunkedSampleCount = 0; + chunks = new LinkedList<>(); + samples = new LinkedList<>(); + sampleMetadata = getConsumedMetadata(0); + sampleComparator.initialize(sampleMetadata); } @Override public void consume(Sample s, int channel) { - samples.add(s); - inputSampleCount++; - if (samples.size() >= chunkSize) { - chunks.add(sortAndDump(samples, sampleMetadata)); - samples.clear(); - } + samples.add(s); + inputSampleCount++; + if (samples.size() >= chunkSize) { + chunks.add(sortAndDump(samples, sampleMetadata)); + samples.clear(); + } } @Override public void stopConsuming() { - if (samples.size() > 0) { - chunks.add(sortAndDump(samples, sampleMetadata)); - } - if (log.isDebugEnabled()) { - log.debug("sort(): " + inputSampleCount - + " samples read from input, " + chunkedSampleCount - + " samples written to chunk files"); - if (inputSampleCount != chunkedSampleCount) { - log.error("Failure !"); - } else { - log.info("chunked samples dumps succeeded."); - } - } - super.setProducedMetadata(sampleMetadata, 0); - super.startProducing(); - sortFilesParallel(chunks, sampleMetadata, this); - super.stopProducing(); - if (this.pool != null) { - this.pool.shutdown(); - } - getWorkingDirectory().delete(); + if (samples.size() > 0) { + chunks.add(sortAndDump(samples, sampleMetadata)); + } + if (log.isDebugEnabled()) { + log.debug("sort(): " + inputSampleCount + + " samples read from input, " + chunkedSampleCount + + " samples written to chunk files"); + if (inputSampleCount != chunkedSampleCount) { + log.error("Failure !"); + } else { + log.info("chunked samples dumps succeeded."); + } + } + super.setProducedMetadata(sampleMetadata, 0); + super.startProducing(); + sortFilesParallel(chunks, sampleMetadata, this); + super.stopProducing(); + if (this.pool != null) { + this.pool.shutdown(); + } + getWorkingDirectory().delete(); } private File sortAndDump(final List samples, - final SampleMetadata sampleMetadata) { - long start = 0; - long stop = 0; - if (log.isDebugEnabled()) { - log.debug("sortAndDump(): Sorting " + samples.size() - + " samples..."); - start = System.currentTimeMillis(); - } - final List sortedSamples = sortSamplesParallel(samples); - if (sortedSamples.size() != samples.size()) { - throw new SampleException("sort failed ! " + sortedSamples.size() - + " != " + samples.size()); - } - if (log.isDebugEnabled()) { - stop = System.currentTimeMillis(); - log.debug("sortAndDump(): in " + (stop - start) / 1000f - + " s. Sorted " + samples.size() + " samples."); - } - File out = getChunkFile(); - if (log.isDebugEnabled()) { - log.debug("sortAndDump(): Dumping chunk " + out); - start = System.currentTimeMillis(); - } - CsvSampleWriter csvWriter = new CsvSampleWriter(out, sampleMetadata); - try { - for (Sample sample : sortedSamples) { - csvWriter.write(sample); - chunkedSampleCount++; - } - } finally { - csvWriter.close(); - } - if (log.isDebugEnabled()) { - stop = System.currentTimeMillis(); - log.debug("sortAndDump(): in " + (stop - start) / 1000f - + " s : Dumped chunk " + out.getAbsolutePath()); - } - return out; + final SampleMetadata sampleMetadata) { + long start = 0; + long stop = 0; + if (log.isDebugEnabled()) { + log.debug("sortAndDump(): Sorting " + samples.size() + + " samples..."); + start = System.currentTimeMillis(); + } + final List sortedSamples = sortSamplesParallel(samples); + if (sortedSamples.size() != samples.size()) { + throw new SampleException("sort failed ! " + sortedSamples.size() + + " != " + samples.size()); + } + if (log.isDebugEnabled()) { + stop = System.currentTimeMillis(); + log.debug("sortAndDump(): in " + (stop - start) / 1000f + + " s. Sorted " + samples.size() + " samples."); + } + File out = getChunkFile(); + if (log.isDebugEnabled()) { + log.debug("sortAndDump(): Dumping chunk " + out); + start = System.currentTimeMillis(); + } + CsvSampleWriter csvWriter = new CsvSampleWriter(out, sampleMetadata); + try { + for (Sample sample : sortedSamples) { + csvWriter.write(sample); + chunkedSampleCount++; + } + } finally { + csvWriter.close(); + } + if (log.isDebugEnabled()) { + stop = System.currentTimeMillis(); + log.debug("sortAndDump(): in " + (stop - start) / 1000f + + " s : Dumped chunk " + out.getAbsolutePath()); + } + return out; } private List sortSamplesParallel(final List samples) { - int sz = samples.size(); - if (sz <= 1) { - return samples; - } - int middle = sz / 2; - final List left = samples.subList(0, middle); - final List right = samples.subList(middle, sz); - Job> jobLeft = new Job>() { - @Override - protected List exec() { - return sort(left); - } - }; - Job> jobRight = new Job>() { - @Override - protected List exec() { - return sort(right); - } - }; - - List newLeft = null; - List newRight = null; - workQueue.add(jobLeft); - workQueue.add(jobRight); - if (parallelize) { - try { - newLeft = jobLeft.getResult(); - newRight = jobRight.getResult(); - } catch (InterruptedException ie) { - throw new SampleException("Unexpected interruption !", ie); - } - } else { - newLeft = sort(left); - newRight = sort(right); - } - return merge(newLeft, newRight); + int sz = samples.size(); + if (sz <= 1) { + return samples; + } + int middle = sz / 2; + final List left = samples.subList(0, middle); + final List right = samples.subList(middle, sz); + Job> jobLeft = new Job>() { + @Override + protected List exec() { + return sort(left); + } + }; + Job> jobRight = new Job>() { + @Override + protected List exec() { + return sort(right); + } + }; + + List newLeft = null; + List newRight = null; + workQueue.add(jobLeft); + workQueue.add(jobRight); + if (parallelize) { + try { + newLeft = jobLeft.getResult(); + newRight = jobRight.getResult(); + } catch (InterruptedException ie) { + throw new SampleException("Unexpected interruption !", ie); + } + } else { + newLeft = sort(left); + newRight = sort(right); + } + return merge(newLeft, newRight); } public List sort(List samples) { - int sz = samples.size(); - if (sz <= 1) { - return samples; - } - int middle = sz / 2; - List left = samples.subList(0, middle); - List right = samples.subList(middle, sz); - left = sort(left); - right = sort(right); - return merge(left, right); + int sz = samples.size(); + if (sz <= 1) { + return samples; + } + int middle = sz / 2; + List left = samples.subList(0, middle); + List right = samples.subList(middle, sz); + left = sort(left); + right = sort(right); + return merge(left, right); } private List merge(List left, List right) { - ArrayList out = new ArrayList<>(); - ListIterator l = left.listIterator(); - ListIterator r = right.listIterator(); - while (l.hasNext() || r.hasNext()) { - if (l.hasNext() && r.hasNext()) { - Sample firstLeft = l.next(); - Sample firstRight = r.next(); - if (revertedSort == false - && sampleComparator.compare(firstLeft, firstRight) < 0 - || revertedSort == true - && sampleComparator.compare(firstLeft, firstRight) >= 0) { - out.add(firstLeft); - r.previous(); - } else { - out.add(firstRight); - l.previous(); - } - } else if (l.hasNext()) { - out.add(l.next()); - } else if (r.hasNext()) { - out.add(r.next()); - } - } - return out; + ArrayList out = new ArrayList<>(); + ListIterator l = left.listIterator(); + ListIterator r = right.listIterator(); + while (l.hasNext() || r.hasNext()) { + if (l.hasNext() && r.hasNext()) { + Sample firstLeft = l.next(); + Sample firstRight = r.next(); + if (revertedSort == false + && sampleComparator.compare(firstLeft, firstRight) < 0 + || revertedSort == true + && sampleComparator.compare(firstLeft, firstRight) >= 0) { + out.add(firstLeft); + r.previous(); + } else { + out.add(firstRight); + l.previous(); + } + } else if (l.hasNext()) { + out.add(l.next()); + } else if (r.hasNext()) { + out.add(r.next()); + } + } + return out; } public void mergeFiles(List chunks, SampleMetadata metadata, - SampleProducer producer) { - sortFilesParallel(chunks, metadata, producer); + SampleProducer producer) { + sortFilesParallel(chunks, metadata, producer); } private void sortFilesParallel(List chunks, - final SampleMetadata metadata, SampleProducer out) { - int sz = chunks.size(); - if (sz > 1) { - int middle = sz / 2; - final List left = chunks.subList(0, middle); - final List right = chunks.subList(middle, sz); - File leftFile = null; - File rightFile = null; - Job leftJob = new Job() { - @Override - protected File exec() { - return mergeSortFiles(left, metadata); - } - }; - Job rightJob = new Job() { - @Override - protected File exec() { - return mergeSortFiles(right, metadata); - } - }; - if (parallelize) { - workQueue.add(leftJob); - workQueue.add(rightJob); - try { - leftFile = leftJob.getResult(); - rightFile = rightJob.getResult(); - } catch (InterruptedException ie) { - throw new SampleException("Unexpected interruption !", ie); - } - } else { - leftFile = leftJob.exec(); - rightFile = rightJob.exec(); - } - mergeFiles(metadata, leftFile, rightFile, out); - } else { - File f = chunks.get(0); - CsvSampleReader reader = new CsvSampleReader(f, metadata); - Sample s = null; - while ((s = reader.readSample()) != null) { - out.produce(s, 0); - } - } + final SampleMetadata metadata, SampleProducer out) { + int sz = chunks.size(); + if (sz > 1) { + int middle = sz / 2; + final List left = chunks.subList(0, middle); + final List right = chunks.subList(middle, sz); + File leftFile = null; + File rightFile = null; + Job leftJob = new Job() { + @Override + protected File exec() { + return mergeSortFiles(left, metadata); + } + }; + Job rightJob = new Job() { + @Override + protected File exec() { + return mergeSortFiles(right, metadata); + } + }; + if (parallelize) { + workQueue.add(leftJob); + workQueue.add(rightJob); + try { + leftFile = leftJob.getResult(); + rightFile = rightJob.getResult(); + } catch (InterruptedException ie) { + throw new SampleException("Unexpected interruption !", ie); + } + } else { + leftFile = leftJob.exec(); + rightFile = rightJob.exec(); + } + mergeFiles(metadata, leftFile, rightFile, out); + } else { + File f = chunks.get(0); + CsvSampleReader reader = new CsvSampleReader(f, metadata); + Sample s = null; + while ((s = reader.readSample()) != null) { + out.produce(s, 0); + } + } } // private static long countSamples(File f, SampleMetadata metadata) { @@ -530,109 +530,109 @@ public class ExternalSampleSorter extend // } private File mergeSortFiles(List chunks, SampleMetadata metadata) { - int sz = chunks.size(); - if (sz == 1) { - return chunks.get(0); - } - int middle = sz / 2; - List left = chunks.subList(0, middle); - List right = chunks.subList(middle, sz); - File leftFile = mergeSortFiles(left, metadata); - File rightFile = mergeSortFiles(right, metadata); - return mergeFiles(leftFile, rightFile, metadata); + int sz = chunks.size(); + if (sz == 1) { + return chunks.get(0); + } + int middle = sz / 2; + List left = chunks.subList(0, middle); + List right = chunks.subList(middle, sz); + File leftFile = mergeSortFiles(left, metadata); + File rightFile = mergeSortFiles(right, metadata); + return mergeFiles(leftFile, rightFile, metadata); } private File mergeFiles(File left, File right, SampleMetadata metadata) { - File out = getChunkFile(); - mergeFiles(metadata, left, right, out, false); - return out; + File out = getChunkFile(); + mergeFiles(metadata, left, right, out, false); + return out; } private void mergeFiles(SampleMetadata metadata, File left, File right, - File out, boolean writeHeader) { - if (out == null) { - out = getChunkFile(); - } - CsvSampleWriter csvWriter = new CsvSampleWriter(out, metadata); - CsvSampleReader l = new CsvSampleReader(left, metadata); - CsvSampleReader r = new CsvSampleReader(right, metadata); - try { - if (writeHeader) { - csvWriter.writeHeader(); - } - while (l.hasNext() || r.hasNext()) { - if (l.hasNext() && r.hasNext()) { - Sample firstLeft = l.peek(); - Sample firstRight = r.peek(); - if (revertedSort == false - && sampleComparator.compare(firstLeft, firstRight) < 0 - || revertedSort == true - && sampleComparator.compare(firstLeft, firstRight) >= 0) { - csvWriter.write(firstLeft); - l.readSample(); - } else { - csvWriter.write(firstRight); - r.readSample(); - } - } else if (l.hasNext()) { - csvWriter.write(l.readSample()); - } else if (r.hasNext()) { - csvWriter.write(r.readSample()); - } - } - } finally { - csvWriter.close(); - l.close(); - r.close(); - } + File out, boolean writeHeader) { + if (out == null) { + out = getChunkFile(); + } + CsvSampleWriter csvWriter = new CsvSampleWriter(out, metadata); + CsvSampleReader l = new CsvSampleReader(left, metadata); + CsvSampleReader r = new CsvSampleReader(right, metadata); + try { + if (writeHeader) { + csvWriter.writeHeader(); + } + while (l.hasNext() || r.hasNext()) { + if (l.hasNext() && r.hasNext()) { + Sample firstLeft = l.peek(); + Sample firstRight = r.peek(); + if (revertedSort == false + && sampleComparator.compare(firstLeft, firstRight) < 0 + || revertedSort == true + && sampleComparator.compare(firstLeft, firstRight) >= 0) { + csvWriter.write(firstLeft); + l.readSample(); + } else { + csvWriter.write(firstRight); + r.readSample(); + } + } else if (l.hasNext()) { + csvWriter.write(l.readSample()); + } else if (r.hasNext()) { + csvWriter.write(r.readSample()); + } + } + } finally { + csvWriter.close(); + l.close(); + r.close(); + } } private void mergeFiles(SampleMetadata metadata, File left, File right, - SampleProducer out) { - CsvSampleReader l = new CsvSampleReader(left, metadata); - CsvSampleReader r = new CsvSampleReader(right, metadata); - try { - while (l.hasNext() || r.hasNext()) { - if (l.hasNext() && r.hasNext()) { - Sample firstLeft = l.peek(); - Sample firstRight = r.peek(); - if (revertedSort == false - && sampleComparator.compare(firstLeft, firstRight) < 0 - || revertedSort == true - && sampleComparator.compare(firstLeft, firstRight) >= 0) { - out.produce(firstLeft, 0); - l.readSample(); - } else { - out.produce(firstRight, 0); - r.readSample(); - } - } else if (l.hasNext()) { - out.produce(l.readSample(), 0); - } else if (r.hasNext()) { - out.produce(r.readSample(), 0); - } - } - } finally { - l.close(); - r.close(); - } + SampleProducer out) { + CsvSampleReader l = new CsvSampleReader(left, metadata); + CsvSampleReader r = new CsvSampleReader(right, metadata); + try { + while (l.hasNext() || r.hasNext()) { + if (l.hasNext() && r.hasNext()) { + Sample firstLeft = l.peek(); + Sample firstRight = r.peek(); + if (revertedSort == false + && sampleComparator.compare(firstLeft, firstRight) < 0 + || revertedSort == true + && sampleComparator.compare(firstLeft, firstRight) >= 0) { + out.produce(firstLeft, 0); + l.readSample(); + } else { + out.produce(firstRight, 0); + r.readSample(); + } + } else if (l.hasNext()) { + out.produce(l.readSample(), 0); + } else if (r.hasNext()) { + out.produce(r.readSample(), 0); + } + } + } finally { + l.close(); + r.close(); + } } private AtomicInteger sequence = new AtomicInteger(); private File getChunkFile() { - DecimalFormat df = new DecimalFormat("00000"); - File out = new File(getWorkingDirectory(), "chunk-" - + df.format(sequence.incrementAndGet()) + ".csv"); - out.deleteOnExit(); - return out; + DecimalFormat df = new DecimalFormat("00000"); + File out = new File(getWorkingDirectory(), "chunk-" + + df.format(sequence.incrementAndGet()) + ".csv"); + out.deleteOnExit(); + return out; } /** * @return the revertedSort */ public final boolean isRevertedSort() { - return revertedSort; + return revertedSort; } /** @@ -640,7 +640,7 @@ public class ExternalSampleSorter extend * the revertedSort to set */ public final void setRevertedSort(boolean revertedSort) { - this.revertedSort = revertedSort; + this.revertedSort = revertedSort; } // private static void test(String wd, String in, String out) { Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/FieldSampleComparator.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/FieldSampleComparator.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/FieldSampleComparator.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/FieldSampleComparator.java Thu Dec 10 18:55:22 2015 @@ -33,16 +33,16 @@ public class FieldSampleComparator imple private final String fieldName; public FieldSampleComparator(String fieldName) { - this.fieldName = fieldName; + this.fieldName = fieldName; } @Override public final void initialize(SampleMetadata metadata) { - index = metadata.indexOf(fieldName); - if (index < 0) { - throw new SampleException(String.format(METADATA_EXCEPTION_MSG_FMT, - fieldName, metadata)); - } + index = metadata.indexOf(fieldName); + if (index < 0) { + throw new SampleException(String.format(METADATA_EXCEPTION_MSG_FMT, + fieldName, metadata)); + } } /* @@ -54,6 +54,6 @@ public class FieldSampleComparator imple */ @Override public long compare(Sample s1, Sample s2) { - return s1.getLong(index) - s2.getLong(index); + return s1.getLong(index) - s2.getLong(index); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/FilterConsumer.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/FilterConsumer.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/FilterConsumer.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/FilterConsumer.java Thu Dec 10 18:55:22 2015 @@ -49,7 +49,7 @@ public class FilterConsumer extends Abst * @return true if the filtering is reversed; otherwise false. */ public final boolean isReverseFilter() { - return reverseFilter; + return reverseFilter; } /** @@ -59,7 +59,7 @@ public class FilterConsumer extends Abst * the filter mode to set */ public final void setReverseFilter(boolean reverseFilter) { - this.reverseFilter = reverseFilter; + this.reverseFilter = reverseFilter; } /** @@ -68,7 +68,7 @@ public class FilterConsumer extends Abst * @return the sample predicate used to filter the samples. */ public final SamplePredicate getSamplePredicate() { - return samplePredicate; + return samplePredicate; } /** @@ -78,37 +78,37 @@ public class FilterConsumer extends Abst * the new sample predicate. */ public final void setSamplePredicate(SamplePredicate samplePredicate) { - this.samplePredicate = samplePredicate; + this.samplePredicate = samplePredicate; } @Override public void startConsuming() { - // Broadcast metadata to consumers for each channel - int channelCount = getConsumedChannelCount(); - for (int i = 0; i < channelCount; i++) { - super.setProducedMetadata(getConsumedMetadata(i), i); - } - super.startProducing(); + // Broadcast metadata to consumers for each channel + int channelCount = getConsumedChannelCount(); + for (int i = 0; i < channelCount; i++) { + super.setProducedMetadata(getConsumedMetadata(i), i); + } + super.startProducing(); } @Override public void consume(Sample sample, int channel) { - // The sample is reproduced if : - // A predicate is defined and the sample matches it when reverseFilter - // is false. - // OR - // None predicate is defined or the sample does not match when - // reverseFilter is true. - if ((reverseFilter == false && samplePredicate != null && samplePredicate - .matches(sample)) - || (reverseFilter == true && (samplePredicate == null || samplePredicate - .matches(sample) == false))) { - super.produce(sample, channel); - } + // The sample is reproduced if : + // A predicate is defined and the sample matches it when reverseFilter + // is false. + // OR + // None predicate is defined or the sample does not match when + // reverseFilter is true. + if ((reverseFilter == false && samplePredicate != null && samplePredicate + .matches(sample)) + || (reverseFilter == true && (samplePredicate == null || samplePredicate + .matches(sample) == false))) { + super.produce(sample, channel); + } } @Override public void stopConsuming() { - super.stopProducing(); + super.stopProducing(); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/Job.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/Job.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/Job.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/Job.java Thu Dec 10 18:55:22 2015 @@ -36,22 +36,22 @@ abstract class Job implements Runnabl @Override public final void run() { - resultReady = false; - result = exec(); - synchronized (lock) { - resultReady = true; - lock.notify(); - } + resultReady = false; + result = exec(); + synchronized (lock) { + resultReady = true; + lock.notify(); + } } protected abstract T exec(); public T getResult() throws InterruptedException { - synchronized (lock) { - while (!resultReady) { - lock.wait(); - } - } - return result; + synchronized (lock) { + while (!resultReady) { + lock.wait(); + } + } + return result; } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/ListResultData.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/ListResultData.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/ListResultData.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/ListResultData.java Thu Dec 10 18:55:22 2015 @@ -41,10 +41,10 @@ public class ListResultData implements R */ @Override public TVisit accept(ResultDataVisitor visitor) { - if (visitor == null) { - throw new ArgumentNullException("visitor"); - } - return visitor.visitListResult(this); + if (visitor == null) { + throw new ArgumentNullException("visitor"); + } + return visitor.visitListResult(this); } /** @@ -55,7 +55,7 @@ public class ListResultData implements R * @return true, if the result is added */ public boolean addResult(ResultData result) { - return items.add(result); + return items.add(result); } /** @@ -66,7 +66,7 @@ public class ListResultData implements R * @return the removed result data */ public ResultData removeResult(int index) { - return items.remove(index); + return items.remove(index); } /** @@ -77,7 +77,7 @@ public class ListResultData implements R * @return the result data */ public ResultData get(int index) { - return items.get(index); + return items.get(index); } /** @@ -86,7 +86,7 @@ public class ListResultData implements R * @return the size of the list */ public int getSize() { - return items.size(); + return items.size(); } /* @@ -96,6 +96,6 @@ public class ListResultData implements R */ @Override public Iterator iterator() { - return items.iterator(); + return items.iterator(); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/MapResultData.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/MapResultData.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/MapResultData.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/MapResultData.java Thu Dec 10 18:55:22 2015 @@ -42,10 +42,10 @@ public class MapResultData implements Re */ @Override public TVisit accept(ResultDataVisitor visitor) { - if (visitor == null) { - throw new ArgumentNullException("visitor"); - } - return visitor.visitMapResult(this); + if (visitor == null) { + throw new ArgumentNullException("visitor"); + } + return visitor.visitMapResult(this); } /** @@ -54,7 +54,7 @@ public class MapResultData implements Re * @return the sets of entries of the map */ public Set> entrySet() { - return map.entrySet(); + return map.entrySet(); } /** @@ -65,7 +65,7 @@ public class MapResultData implements Re * @return the result */ public ResultData getResult(String name) { - return map.get(name); + return map.get(name); } /** @@ -78,7 +78,7 @@ public class MapResultData implements Re * @return the previously result data associated with the specified name */ public ResultData setResult(String name, ResultData result) { - return map.put(name, result); + return map.put(name, result); } /** @@ -89,6 +89,6 @@ public class MapResultData implements Re * @return the removed result data */ public ResultData removeResult(String name) { - return map.remove(name); + return map.remove(name); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/MaxAggregator.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/MaxAggregator.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/MaxAggregator.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/MaxAggregator.java Thu Dec 10 18:55:22 2015 @@ -34,7 +34,7 @@ public class MaxAggregator implements Ag */ @Override public long getCount() { - return count; + return count; } /* @@ -44,7 +44,7 @@ public class MaxAggregator implements Ag */ @Override public double getResult() { - return value; + return value; } /* @@ -54,8 +54,8 @@ public class MaxAggregator implements Ag */ @Override public void addValue(double value) { - this.value = Math.max(this.value, value); - count++; + this.value = Math.max(this.value, value); + count++; } /* @@ -65,8 +65,8 @@ public class MaxAggregator implements Ag */ @Override public void reset() { - count = 0L; - value = Double.MIN_VALUE; + count = 0L; + value = Double.MIN_VALUE; } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/MeanAggregator.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/MeanAggregator.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/MeanAggregator.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/MeanAggregator.java Thu Dec 10 18:55:22 2015 @@ -35,7 +35,7 @@ public class MeanAggregator implements A */ @Override public long getCount() { - return mean.getN(); + return mean.getN(); } /* @@ -45,7 +45,7 @@ public class MeanAggregator implements A */ @Override public double getResult() { - return mean.getResult(); + return mean.getResult(); } /* @@ -55,7 +55,7 @@ public class MeanAggregator implements A */ @Override public void addValue(double value) { - mean.increment(value); + mean.increment(value); } /* @@ -65,7 +65,7 @@ public class MeanAggregator implements A */ @Override public void reset() { - mean.clear(); + mean.clear(); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/MeanAggregatorFactory.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/MeanAggregatorFactory.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/MeanAggregatorFactory.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/MeanAggregatorFactory.java Thu Dec 10 18:55:22 2015 @@ -33,7 +33,7 @@ public class MeanAggregatorFactory exten */ @Override protected Aggregator createAggregator() { - return new MeanAggregator(); + return new MeanAggregator(); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/MedianAggregatorFactory.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/MedianAggregatorFactory.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/MedianAggregatorFactory.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/MedianAggregatorFactory.java Thu Dec 10 18:55:22 2015 @@ -34,8 +34,8 @@ public class MedianAggregatorFactory ext */ @Override protected Aggregator createAggregator() { - // TODO Auto-generated method stub - return new PercentileAggregator(50); + // TODO Auto-generated method stub + return new PercentileAggregator(50); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/MinAggregator.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/MinAggregator.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/MinAggregator.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/MinAggregator.java Thu Dec 10 18:55:22 2015 @@ -34,7 +34,7 @@ public class MinAggregator implements Ag */ @Override public long getCount() { - return count; + return count; } /* @@ -44,7 +44,7 @@ public class MinAggregator implements Ag */ @Override public double getResult() { - return value; + return value; } /* @@ -54,8 +54,8 @@ public class MinAggregator implements Ag */ @Override public void addValue(double value) { - this.value = Math.min(this.value, value); - count++; + this.value = Math.min(this.value, value); + count++; } /* @@ -65,8 +65,8 @@ public class MinAggregator implements Ag */ @Override public void reset() { - count = 0L; - value = Double.MAX_VALUE; + count = 0L; + value = Double.MAX_VALUE; } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/NormalizerSampleConsumer.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/NormalizerSampleConsumer.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/NormalizerSampleConsumer.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/NormalizerSampleConsumer.java Thu Dec 10 18:55:22 2015 @@ -43,53 +43,53 @@ public class NormalizerSampleConsumer ex private int timestamp; private SimpleDateFormat df = new SimpleDateFormat( - JMeterUtils.getPropDefault( - "jmeter.save.saveservice.timestamp_format", - DEFAULT_DATE_FORMAT)); + JMeterUtils.getPropDefault( + "jmeter.save.saveservice.timestamp_format", + DEFAULT_DATE_FORMAT)); private SampleMetadata sampleMetadata; @Override public void startConsuming() { - sampleMetadata = getConsumedMetadata(0); - timestamp = sampleMetadata.indexOf(CSVSaveService.TIME_STAMP); - super.setProducedMetadata(sampleMetadata, 0); - startProducing(); + sampleMetadata = getConsumedMetadata(0); + timestamp = sampleMetadata.indexOf(CSVSaveService.TIME_STAMP); + super.setProducedMetadata(sampleMetadata, 0); + startProducing(); } @Override public void consume(Sample s, int channel) { - Date date = null; - try { - String tStr = s.getString(timestamp); - try { - // Try to parse the timestamp assuming is a long - date = new Date(Long.parseLong(tStr)); - } catch (NumberFormatException ex) { - // Try to parse the timestamp assuming it has HH:mm:ss format - date = df.parse(tStr); - } - } catch (Exception e) { - throw new SampleException(String.format( - PARSE_TIMESTAMP_EXCEPTION_MESSAGE, s.getString(timestamp), - s.toString()), e); - } - long time = date.getTime(); - int cc = sampleMetadata.getColumnCount(); - String[] data = new String[cc]; - for (int i = 0; i < cc; i++) { - if (i == timestamp) { - data[i] = Long.toString(time); - } else { - data[i] = s.getString(i); - } - } - Sample rewrited = new Sample(s.getSampleRow(), sampleMetadata, data); - super.produce(rewrited, 0); + Date date = null; + try { + String tStr = s.getString(timestamp); + try { + // Try to parse the timestamp assuming is a long + date = new Date(Long.parseLong(tStr)); + } catch (NumberFormatException ex) { + // Try to parse the timestamp assuming it has HH:mm:ss format + date = df.parse(tStr); + } + } catch (Exception e) { + throw new SampleException(String.format( + PARSE_TIMESTAMP_EXCEPTION_MESSAGE, s.getString(timestamp), + s.toString()), e); + } + long time = date.getTime(); + int cc = sampleMetadata.getColumnCount(); + String[] data = new String[cc]; + for (int i = 0; i < cc; i++) { + if (i == timestamp) { + data[i] = Long.toString(time); + } else { + data[i] = s.getString(i); + } + } + Sample rewrited = new Sample(s.getSampleRow(), sampleMetadata, data); + super.produce(rewrited, 0); } @Override public void stopConsuming() { - super.stopProducing(); + super.stopProducing(); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/PercentileAggregator.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/PercentileAggregator.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/PercentileAggregator.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/PercentileAggregator.java Thu Dec 10 18:55:22 2015 @@ -28,9 +28,9 @@ import org.apache.jmeter.util.JMeterUtil */ public class PercentileAggregator implements Aggregator { private static final int SLIDING_WINDOW_SIZE = JMeterUtils.getPropDefault( - ReportGeneratorConfiguration.REPORT_GENERATOR_KEY_PREFIX - + ReportGeneratorConfiguration.KEY_DELIMITER - + "statistic_window", 200000); + ReportGeneratorConfiguration.REPORT_GENERATOR_KEY_PREFIX + + ReportGeneratorConfiguration.KEY_DELIMITER + + "statistic_window", 200000); private final DescriptiveStatistics statistics; private final double percentileIndex; @@ -42,8 +42,8 @@ public class PercentileAggregator implem * the index of the percentile */ public PercentileAggregator(double index) { - statistics = new DescriptiveStatistics(SLIDING_WINDOW_SIZE); - percentileIndex = index; + statistics = new DescriptiveStatistics(SLIDING_WINDOW_SIZE); + percentileIndex = index; } /* @@ -53,7 +53,7 @@ public class PercentileAggregator implem */ @Override public long getCount() { - return statistics.getN(); + return statistics.getN(); } /* @@ -63,7 +63,7 @@ public class PercentileAggregator implem */ @Override public double getResult() { - return statistics.getPercentile(percentileIndex); + return statistics.getPercentile(percentileIndex); } /* @@ -73,7 +73,7 @@ public class PercentileAggregator implem */ @Override public void addValue(double value) { - statistics.addValue(value); + statistics.addValue(value); } /* @@ -83,7 +83,7 @@ public class PercentileAggregator implem */ @Override public void reset() { - statistics.clear(); + statistics.clear(); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/PercentileAggregatorFactory.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/PercentileAggregatorFactory.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/PercentileAggregatorFactory.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/PercentileAggregatorFactory.java Thu Dec 10 18:55:22 2015 @@ -32,7 +32,7 @@ public class PercentileAggregatorFactory * @return the percentile index */ public final double getPercentileIndex() { - return percentileIndex; + return percentileIndex; } /** @@ -42,7 +42,7 @@ public class PercentileAggregatorFactory * the index of the percentile to set */ public void setPercentileIndex(double percentileIndex) { - this.percentileIndex = percentileIndex; + this.percentileIndex = percentileIndex; } /* @@ -54,7 +54,7 @@ public class PercentileAggregatorFactory */ @Override protected Aggregator createAggregator() { - return new PercentileAggregator(percentileIndex); + return new PercentileAggregator(percentileIndex); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/RequestsSummaryConsumer.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/RequestsSummaryConsumer.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/RequestsSummaryConsumer.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/RequestsSummaryConsumer.java Thu Dec 10 18:55:22 2015 @@ -37,16 +37,16 @@ public class RequestsSummaryConsumer ext */ @Override public void startConsuming() { - count = 0L; - errorCount = 0L; + count = 0L; + errorCount = 0L; - // 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(); } /* (non-Javadoc) @@ -54,24 +54,26 @@ public class RequestsSummaryConsumer ext */ @Override public void consume(Sample sample, int channel) { - count++; - if (sample.getSuccess() == false) { - errorCount++; - } - super.produce(sample, channel); + count++; + if (sample.getSuccess() == false) { + errorCount++; + } + super.produce(sample, channel); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.apache.jmeter.report.processor.SampleConsumer#stopConsuming() */ @Override public void stopConsuming() { - MapResultData result = new MapResultData(); - result.setResult("KoPercent", new ValueResultData((double) errorCount - * 100 / count)); - result.setResult("OkPercent", new ValueResultData( - (double) (count - errorCount) * 100 / count)); - setDataToContext(getName(), result); - super.stopProducing(); + MapResultData result = new MapResultData(); + result.setResult("KoPercent", new ValueResultData((double) errorCount + * 100 / count)); + result.setResult("OkPercent", new ValueResultData( + (double) (count - errorCount) * 100 / count)); + setDataToContext(getName(), result); + super.stopProducing(); } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/SampleContext.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/SampleContext.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/SampleContext.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/SampleContext.java Thu Dec 10 18:55:22 2015 @@ -41,7 +41,7 @@ public class SampleContext { * @return A file pointing to an existing directory */ public final File getWorkingDirectory() { - return workingDirectory; + return workingDirectory; } /** @@ -51,11 +51,11 @@ public class SampleContext { * the new working directory */ public final void setWorkingDirectory(File workingDirectory) { - // if (workingDirectory == null) - // throw new ArgumentNullException("workingDirectory"); + // if (workingDirectory == null) + // throw new ArgumentNullException("workingDirectory"); - this.workingDirectory = workingDirectory; - // workingDirectory.mkdirs(); + this.workingDirectory = workingDirectory; + // workingDirectory.mkdirs(); } /** @@ -64,7 +64,7 @@ public class SampleContext { * @return the data */ public final Map getData() { - return data; + return data; } } Modified: jmeter/trunk/src/core/org/apache/jmeter/report/processor/StatisticsSummaryData.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/processor/StatisticsSummaryData.java?rev=1719183&r1=1719182&r2=1719183&view=diff ============================================================================== --- jmeter/trunk/src/core/org/apache/jmeter/report/processor/StatisticsSummaryData.java (original) +++ jmeter/trunk/src/core/org/apache/jmeter/report/processor/StatisticsSummaryData.java Thu Dec 10 18:55:22 2015 @@ -38,7 +38,7 @@ public class StatisticsSummaryData { private long max = Long.MIN_VALUE; public long getElapsedTime() { - return endTime - firstTime; + return endTime - firstTime; } /** @@ -47,7 +47,7 @@ public class StatisticsSummaryData { * @return the firstTime */ public final long getFirstTime() { - return firstTime; + return firstTime; } /** @@ -57,7 +57,7 @@ public class StatisticsSummaryData { * the firstTime to set */ public final void setFirstTime(long firstTime) { - this.firstTime = Math.min(this.firstTime, firstTime); + this.firstTime = Math.min(this.firstTime, firstTime); } /** @@ -66,7 +66,7 @@ public class StatisticsSummaryData { * @return the endTime */ public final long getEndTime() { - return endTime; + return endTime; } /** @@ -76,7 +76,7 @@ public class StatisticsSummaryData { * the endTime to set */ public final void setEndTime(long endTime) { - this.endTime = Math.max(this.endTime, endTime); + this.endTime = Math.max(this.endTime, endTime); } /** @@ -85,7 +85,7 @@ public class StatisticsSummaryData { * @return the bytes */ public final long getBytes() { - return bytes; + return bytes; } /** @@ -95,14 +95,14 @@ public class StatisticsSummaryData { * the bytes to set */ public final void setBytes(long bytes) { - this.bytes = bytes; + this.bytes = bytes; } /** * @return the errors */ public final long getErrors() { - return errors; + return errors; } /** @@ -110,14 +110,14 @@ public class StatisticsSummaryData { * the errors to set */ public final void setErrors(long errors) { - this.errors = errors; + this.errors = errors; } /** * @return the total */ public final long getTotal() { - return total; + return total; } /** @@ -125,14 +125,14 @@ public class StatisticsSummaryData { * the total to set */ public final void setTotal(long total) { - this.total = total; + this.total = total; } /** * @return the min */ public final long getMin() { - return min; + return min; } /** @@ -140,14 +140,14 @@ public class StatisticsSummaryData { * the min to set */ public final void setMin(long min) { - this.min = Math.min(this.min, min); + this.min = Math.min(this.min, min); } /** * @return the max */ public final long getMax() { - return max; + return max; } /** @@ -155,14 +155,14 @@ public class StatisticsSummaryData { * the max to set */ public final void setMax(long max) { - this.max = Math.max(this.max, max); + this.max = Math.max(this.max, max); } /** * @return the percentile1 */ public final PercentileAggregator getPercentile1() { - return percentile1; + return percentile1; } /** @@ -171,7 +171,7 @@ public class StatisticsSummaryData { * @return the percentile2 */ public final PercentileAggregator getPercentile2() { - return percentile2; + return percentile2; } /** @@ -180,17 +180,17 @@ public class StatisticsSummaryData { * @return the percentile3 */ public final PercentileAggregator getPercentile3() { - return percentile3; + return percentile3; } /** * Instantiates a new statistics info. */ public StatisticsSummaryData(long percentileIndex1, long percentileIndex2, - long percentileIndex3) { - percentile1 = new PercentileAggregator(percentileIndex1); - percentile2 = new PercentileAggregator(percentileIndex2); - percentile3 = new PercentileAggregator(percentileIndex3); + long percentileIndex3) { + percentile1 = new PercentileAggregator(percentileIndex1); + percentile2 = new PercentileAggregator(percentileIndex2); + percentile3 = new PercentileAggregator(percentileIndex3); } /** @@ -199,7 +199,7 @@ public class StatisticsSummaryData { * @return the bytes per second */ public double getBytesPerSecond() { - return bytes / ((double) getElapsedTime() / 1000); + return bytes / ((double) getElapsedTime() / 1000); } /** @@ -208,7 +208,7 @@ public class StatisticsSummaryData { * @return the kilo bytes per second */ public double getKBytesPerSecond() { - return getBytesPerSecond() / 1024; + return getBytesPerSecond() / 1024; } /** @@ -217,18 +217,18 @@ public class StatisticsSummaryData { * @return the throughput */ public double getThroughput() { - return (total / (double) getElapsedTime()) * 1000.0; + return (total / (double) getElapsedTime()) * 1000.0; } public void IncTotal() { - total++; + total++; } public void IncBytes(long value) { - bytes += value; + bytes += value; } public void IncErrors() { - errors++; + errors++; } }