public class CsvFileSampleSource extends AbstractSampleSource
SampleConsumer
s.
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, setSampleContext
public 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)
SampleSource
setSampleConsumers
in interface SampleSource
setSampleConsumers
in class AbstractSampleSource
consumers
- consumers to be setpublic void addSampleConsumer(SampleConsumer consumer)
SampleSource
addSampleConsumer
in interface SampleSource
addSampleConsumer
in class AbstractSampleSource
consumer
- consumer to be addedpublic void removeSampleConsumer(SampleConsumer consumer)
SampleSource
removeSampleConsumer
in interface SampleSource
removeSampleConsumer
in class AbstractSampleSource
consumer
- consumer to be removedpublic void run()
run
in interface Runnable
run
in class AbstractSampleSource
Copyright (c) 1998-2021 Apache Software Foundation. All Rights Reserved.