Class ExternalSampleSorter
- All Implemented Interfaces:
- SampleConsumer,- SampleProcessor,- SampleProducer
 This SampleConsumer should be used to sort samples base on a
 SampleComparator
 
Samples are sorted with the external sort algorithm. Thus, samples are not all stored in memory to be sorted. Instead, they are sorted by chunk in memory and then written to the disk before being merged at the end.
This sorter makes it possible to sort any number of samples with a fixed amount of memory. Hard disk will be used instead of RAM, at the cost of performance
 When parallel mode is enabled and several CPU are available to the
 JVM, this sorter uses multiple CPU to reduce sort time.
 The parallel mode can be disabled if some sort of concurrency issue is
 encountered.
 
 As a last note, this SampleConsumer can be used as normal class with
 the different sort() methods
 
 It is important to set the chunkSize property according
 to the available memory as the algorithm does not take care of memory
 allocation (samples sizes are not predictable)
 
 Meanwhile, it is equally important to set a SampleComparator to
 define sample ordering 
- Since:
- 3.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidConsumes the specified sample ton the specified channel.booleanfinal booleanvoidmergeFiles(List<File> chunks, SampleMetadata metadata, SampleProducer producer) voidsetChunkSize(long chunkSize) Set the number of samples that will be stored in memory.voidsetParallelize(boolean parallelize) Enabled parallel modefinal voidsetRevertedSort(boolean revertedSort) final voidsetSampleComparator(SampleComparator sampleComparator) Set the sample comparator that will define sample orderingvoidSort an input CSV file to an sorted output CSV file.voidsort(SampleMetadata sampleMetadata, File inputFile, File outputFile, boolean writeHeader) Sort an input CSV file whose metadata structure is provided.voidStart the sample consuming.voidStops the consuming process.Methods inherited from class org.apache.jmeter.report.processor.AbstractSampleConsumeraddSampleConsumer, getConsumedChannelCount, getConsumedMetadata, getConsumer, getDataFromContext, getName, getWorkingDirectory, produce, removeSampleConsumer, setChannelAttribute, setConsumedMetadata, setDataToContext, setName, setProducedMetadata, setSampleConsumer, setSampleConsumers, setSampleContext, startProducing, stopProducingMethods inherited from class org.apache.jmeter.report.processor.AbstractSampleProcessorgetChannelAttribute, getSampleContextMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.jmeter.report.processor.SampleProcessorgetChannelAttribute, getSampleContext
- 
Constructor Details- 
ExternalSampleSorterpublic ExternalSampleSorter()
- 
ExternalSampleSorter
 
- 
- 
Method Details- 
setChunkSizepublic void setChunkSize(long chunkSize) Set the number of samples that will be stored in memory. This defines the number of samples that will be written in each chunk file before merging step as well.- Parameters:
- chunkSize- The number of samples sorted in memory before they are written to disk. 5000 is the minimum and will be used if given chunkSize is less than 5000
 
- 
setSampleComparatorSet the sample comparator that will define sample ordering- Parameters:
- sampleComparator- comparator to define the ordering
 
- 
setParallelizepublic void setParallelize(boolean parallelize) Enabled parallel mode- Parameters:
- parallelize-- trueto enable,- falseto disable
 
- 
isParallelizepublic boolean isParallelize()- Returns:
- truewhen parallel mode is enabled,- falseotherwise
 
- 
sortSort an input CSV file to an sorted output CSV file.
 The input CSV must have a header otherwise sorting will give unpredictable results - Parameters:
- inputFile- The CSV file to be sorted (must not be- null)
- outputFile- The sorted destination CSV file (must not be- null)
- writeHeader- Whether the CSV header should be written to the output CSV file
 
- 
sortpublic void sort(SampleMetadata sampleMetadata, File inputFile, File outputFile, boolean writeHeader) Sort an input CSV file whose metadata structure is provided. Use this method when input CSV file has no header : header information is then provided through the sampleMetadata parameter.- Parameters:
- sampleMetadata- The CSV metadata : header information + separator (must not be- null)
- inputFile- The input file to be sorted (must not be- null)
- outputFile- The output sorted file (must not be- null)
- writeHeader- Whether output CSV header should be written (based on provided sample metadata)
 
- 
startConsumingpublic void startConsuming()Description copied from interface:SampleConsumerStart the sample consuming. This step is used by consumer to initialize their process.
- 
consumeDescription copied from interface:SampleConsumerConsumes the specified sample ton the specified channel.- Parameters:
- s- The sample to be consumed
- channel- The channel on which the sample is consumed
 
- 
stopConsumingpublic void stopConsuming()Description copied from interface:SampleConsumerStops the consuming process. No sample will be processed after this service has been called.
- 
sort
- 
mergeFiles
- 
isRevertedSortpublic final boolean isRevertedSort()- Returns:
- flag, whether the order of the sort should be reverted
 
- 
setRevertedSortpublic final void setRevertedSort(boolean revertedSort) - Parameters:
- revertedSort- flag, whether the order of the sort should be reverted.- falseuses the order of the configured- SampleComparator
 
 
-