public abstract class ContentItemsSource extends Object implements Closeable
Keeps track of various statistics, such as how many data items were generated, size in bytes etc.
Supports the following configuration parameters:
Modifier and Type | Field and Description |
---|---|
protected String |
encoding |
protected boolean |
forever |
protected int |
logStep |
protected boolean |
verbose |
Constructor and Description |
---|
ContentItemsSource() |
Modifier and Type | Method and Description |
---|---|
protected void |
addBytes(long numBytes)
update count of bytes generated by this source
|
protected void |
addItem()
update count of items generated by this source
|
abstract void |
close()
Called when reading from this content source is no longer required.
|
protected void |
collectFiles(File dir,
ArrayList<File> files)
A convenience method for collecting all the files of a content source from
a given directory.
|
long |
getBytesCount()
Returns the number of bytes generated since last reset.
|
Config |
getConfig() |
int |
getItemsCount()
Returns the number of generated items since last reset.
|
long |
getTotalBytesCount()
Returns the total number of bytes that were generated by this source.
|
int |
getTotalItemsCount()
Returns the total number of generated items.
|
void |
printStatistics(String itemsName) |
void |
resetInputs()
Resets the input for this content source, so that the test would behave as
if it was just started, input-wise.
|
void |
setConfig(Config config)
Sets the
Config for this content source. |
protected boolean |
shouldLog()
Returns true whether it's time to log a message (depending on verbose and
the number of items generated).
|
protected boolean forever
protected int logStep
protected boolean verbose
protected String encoding
protected final void addBytes(long numBytes)
protected final void addItem()
protected final void collectFiles(File dir, ArrayList<File> files)
File
instances are stored in the
given files
.protected final boolean shouldLog()
public abstract void close() throws IOException
close
in interface Closeable
IOException
public final long getBytesCount()
public final int getItemsCount()
public final Config getConfig()
public final long getTotalBytesCount()
public final int getTotalItemsCount()
public void resetInputs() throws IOException
NOTE: the default implementation resets the number of bytes and items generated since the last reset, so it's important to call super.resetInputs in case you override this method.
IOException
public void setConfig(Config config)
Config
for this content source. If you override this
method, you must call super.setConfig.public void printStatistics(String itemsName)