public class CsvFileSampleSource extends AbstractSampleSource
SampleConsumers.
The root name of the files is determined by the source file name and is made
of its name without the file extension :
Example: If results.csv is the source file name then
results is the root file name.
The CsvFileSampleSource looks for all the files in the same
directory of the main source file that have the same root file name
Example : if the directory contains results.csv,
results-1.csv, results-2.csv, etc. then all
these files will be read and produced on their corresponding channels.
The channel on which an input file will be produce is determined by its
suffix
results-1.csv then it will
be produced on the channel 1.results-2.csv then it will
be produced on the channel 2.results.csv then it will
be produced on the channel 0.| Modifier and Type | Field and Description |
|---|---|
static String |
SOURCE_FILE_ATTRIBUTE
File name whose sample are being produced on the channel
|
| Constructor and Description |
|---|
CsvFileSampleSource(File inputFile,
char separator)
Build a sample source from the specified input file and character
separator.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addSampleConsumer(SampleConsumer consumer)
Add a sample consumer to this sample source.
|
void |
removeSampleConsumer(SampleConsumer consumer)
Remove a sample consumer from this sample source.
|
void |
run()
Run this sample source.
This sample source will start reading all inputs CSV files and produce their samples to this sample source registered sample consumers. |
void |
setSampleConsumers(List<SampleConsumer> consumers)
Sets the specified sample consumers that will consume samples produced by
this sample source.
|
getSampleContext, setSampleContextpublic static final String SOURCE_FILE_ATTRIBUTE
public CsvFileSampleSource(File inputFile, char separator)
inputFile - The input sample file (CSV file) (must not be null)separator - The character separator to be used for delimiting samples
columnspublic void setSampleConsumers(List<SampleConsumer> consumers)
SampleSourcesetSampleConsumers in interface SampleSourcesetSampleConsumers in class AbstractSampleSourceconsumers - consumers to be setpublic void addSampleConsumer(SampleConsumer consumer)
SampleSourceaddSampleConsumer in interface SampleSourceaddSampleConsumer in class AbstractSampleSourceconsumer - consumer to be addedpublic void removeSampleConsumer(SampleConsumer consumer)
SampleSourceremoveSampleConsumer in interface SampleSourceremoveSampleConsumer in class AbstractSampleSourceconsumer - consumer to be removedpublic void run()
run in interface Runnablerun in class AbstractSampleSourceCopyright © 1998-2020 Apache Software Foundation. All Rights Reserved.