Class ExclusiveDataProvider<T>
- java.lang.Object
-
- com.xceptance.xlt.api.data.ExclusiveDataProvider<T>
-
- Type Parameters:
T- type of managed data
public class ExclusiveDataProvider<T> extends java.lang.ObjectProvides exclusive data access. The given file is partitioned so that every agent has an exclusive set of lines. These lines get parsed into the dates to manage by this provider.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classExclusiveDataProvider.Parser<T>Implement this parser to use parsed
-
Field Summary
Fields Modifier and Type Field Description static ExclusiveDataProvider.Parser<java.lang.String>DEFAULT_PARSERParser that just returns the received lines.
-
Constructor Summary
Constructors Constructor Description ExclusiveDataProvider(java.lang.String fileName, boolean filterLineComments, ExclusiveDataProvider.Parser<T> parser)Creates a newExclusiveDataProviderinstance and initializes it with the agent's exclusive data partition loaded from the given data file.ExclusiveDataProvider(java.lang.String fileName, ExclusiveDataProvider.Parser<T> parser)Creates a newExclusiveDataProviderinstance and initializes it with the agent's exclusive data partition loaded from the given data file.ExclusiveDataProvider(java.lang.String fileName, java.lang.String encoding, boolean filterLineComments, ExclusiveDataProvider.Parser<T> parser)Creates a newExclusiveDataProviderinstance and initializes it with the agent's exclusive data partition loaded from the given data file.ExclusiveDataProvider(java.lang.String fileName, java.lang.String encoding, ExclusiveDataProvider.Parser<T> parser)Creates a newExclusiveDataProviderinstance and initializes it with the agent's exclusive data partition loaded from the given data file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(T item)Add a new or release a previously received exclusive item.Tget()Allocate the next available item for exclusive use.static ExclusiveDataProvider.Parser<java.lang.String>getDefaultParser()Default parser that just returns the lines it receives.static ExclusiveDataProvider<java.lang.String>getInstance(java.lang.String fileName)Returns the exclusive data provider responsible for the given file name.static ExclusiveDataProvider<java.lang.String>getInstance(java.lang.String fileName, boolean filterLineComments)Returns the exclusive data provider responsible for the given file name.static <T> ExclusiveDataProvider<T>getInstance(java.lang.String fileName, boolean filterLineComments, ExclusiveDataProvider.Parser<T> parser)Returns the exclusive data provider responsible for the given file name.static <T> ExclusiveDataProvider<T>getInstance(java.lang.String fileName, ExclusiveDataProvider.Parser<T> parser)Returns the exclusive data provider responsible for the given file name.static ExclusiveDataProvider<java.lang.String>getInstance(java.lang.String fileName, java.lang.String encoding)Returns the exclusive data provider responsible for the given file name.static <T> ExclusiveDataProvider<T>getInstance(java.lang.String fileName, java.lang.String encoding, boolean filterLineComments, ExclusiveDataProvider.Parser<T> parser)Returns the exclusive data provider responsible for the given file name.static <T> ExclusiveDataProvider<T>getInstance(java.lang.String fileName, java.lang.String encoding, ExclusiveDataProvider.Parser<T> parser)Returns the exclusive data provider responsible for the given file name.static ExclusiveDataProvider<java.lang.String>getNewInstance(java.lang.String fileName)Creates a newExclusiveDataProviderinstance for String data and initializes it with the agent's exclusive data partition loaded from the given data file.static ExclusiveDataProvider<java.lang.String>getNewInstance(java.lang.String fileName, java.lang.String encoding)Creates a newExclusiveDataProviderinstance for String data and initializes it with the agent's exclusive data partition loaded from the given data file.TgetRandom()Allocate a random item for exclusive use.protected static <T> java.util.List<T>loadData(java.lang.String fileName, java.lang.String encoding, boolean filterLineComments, ExclusiveDataProvider.Parser<T> parser)Get the agent's exclusive data partition loaded from the given data file and parse this partition using the given parser.protected static <T> java.util.List<T>loadData(java.lang.String fileName, java.lang.String encoding, ExclusiveDataProvider.Parser<T> parser)Get the agent's exclusive data partition loaded from the given data file and parse this partition using the given parser.protected static <T> java.util.List<T>parse(java.util.List<java.lang.String> lines, ExclusiveDataProvider.Parser<T> parser)Parse the given lines and return the resulting data objects.intsize()Get the number of available items.
-
-
-
Field Detail
-
DEFAULT_PARSER
public static final ExclusiveDataProvider.Parser<java.lang.String> DEFAULT_PARSER
Parser that just returns the received lines.
-
-
Constructor Detail
-
ExclusiveDataProvider
public ExclusiveDataProvider(java.lang.String fileName, boolean filterLineComments, ExclusiveDataProvider.Parser<T> parser) throws java.io.FileNotFoundException, java.io.IOExceptionCreates a newExclusiveDataProviderinstance and initializes it with the agent's exclusive data partition loaded from the given data file. The data file is expected to be saved usingDataProvider.DEFAULT_FILE_ENCODING.- Parameters:
fileName- the name/path of the data filefilterLineComments- whether line comments in given file should be automatically filtered out before content is handed over to given parserparser- parser to parse the content of the given file with- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read- See Also:
DataProvider.DEFAULT_LINE_COMMENT_MARKER
-
ExclusiveDataProvider
public ExclusiveDataProvider(java.lang.String fileName, ExclusiveDataProvider.Parser<T> parser) throws java.io.FileNotFoundException, java.io.IOExceptionCreates a newExclusiveDataProviderinstance and initializes it with the agent's exclusive data partition loaded from the given data file. The data file is expected to be saved usingDataProvider.DEFAULT_FILE_ENCODING.Line comments won't be automatically filtered out and need to be handled by the given parser.
- Parameters:
fileName- the name/path of the data fileparser- parser to parse the content of given file with- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read- See Also:
DataProvider.DEFAULT_LINE_COMMENT_MARKER
-
ExclusiveDataProvider
public ExclusiveDataProvider(java.lang.String fileName, java.lang.String encoding, ExclusiveDataProvider.Parser<T> parser) throws java.io.FileNotFoundException, java.io.IOExceptionCreates a newExclusiveDataProviderinstance and initializes it with the agent's exclusive data partition loaded from the given data file.Line comments won't be automatically filtered out and need to be handled by the given parser.
- Parameters:
fileName- the name/path of the data fileencoding- the file's encodingparser- parser to parse the content of given file with- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read- See Also:
DataProvider.DEFAULT_LINE_COMMENT_MARKER
-
ExclusiveDataProvider
public ExclusiveDataProvider(java.lang.String fileName, java.lang.String encoding, boolean filterLineComments, ExclusiveDataProvider.Parser<T> parser) throws java.io.FileNotFoundException, java.io.IOExceptionCreates a newExclusiveDataProviderinstance and initializes it with the agent's exclusive data partition loaded from the given data file.- Parameters:
fileName- the name/path of the data fileencoding- the file's encodingfilterLineComments- whether line comments in given file should be automatically filtered out before content is handed over to given parserparser- parser to parse the content of the given file with- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read- See Also:
DataProvider.DEFAULT_LINE_COMMENT_MARKER
-
-
Method Detail
-
getNewInstance
public static ExclusiveDataProvider<java.lang.String> getNewInstance(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
Creates a newExclusiveDataProviderinstance for String data and initializes it with the agent's exclusive data partition loaded from the given data file. The data file is expected to be saved usingDataProvider.DEFAULT_FILE_ENCODING.Line comments won't be handled in any way.
- Parameters:
fileName- the name/path of the data file- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read
-
getNewInstance
public static ExclusiveDataProvider<java.lang.String> getNewInstance(java.lang.String fileName, java.lang.String encoding) throws java.io.FileNotFoundException, java.io.IOException
Creates a newExclusiveDataProviderinstance for String data and initializes it with the agent's exclusive data partition loaded from the given data file. The data file is expected to be saved usingDataProvider.DEFAULT_FILE_ENCODING.Line comments won't be handled in any way.
- Parameters:
fileName- the name/path of the data fileencoding- the encoding the file was saved with- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read
-
loadData
protected static <T> java.util.List<T> loadData(java.lang.String fileName, java.lang.String encoding, boolean filterLineComments, ExclusiveDataProvider.Parser<T> parser) throws java.io.FileNotFoundException, java.io.IOExceptionGet the agent's exclusive data partition loaded from the given data file and parse this partition using the given parser.- Parameters:
fileName- the name/path of the data fileencoding- the file's encodingfilterLineComments- whether line comments in given file should be automatically filtered out before content is handed over to given parserparser- parser to parse the content of the given file with- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read- See Also:
DataProvider.DEFAULT_LINE_COMMENT_MARKER
-
loadData
protected static <T> java.util.List<T> loadData(java.lang.String fileName, java.lang.String encoding, ExclusiveDataProvider.Parser<T> parser) throws java.io.FileNotFoundException, java.io.IOExceptionGet the agent's exclusive data partition loaded from the given data file and parse this partition using the given parser.Line comments won't be automatically filtered out and need to be handled by the given parser.
- Parameters:
fileName- the name/path of the data fileencoding- the file's encodingparser- parser to parse the content of the given file with- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read- See Also:
DataProvider.DEFAULT_LINE_COMMENT_MARKER
-
parse
protected static <T> java.util.List<T> parse(java.util.List<java.lang.String> lines, ExclusiveDataProvider.Parser<T> parser)Parse the given lines and return the resulting data objects.- Parameters:
lines- the lines to parseparser- parser to convert the read lines to the desired object
-
getInstance
public static ExclusiveDataProvider<java.lang.String> getInstance(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
Returns the exclusive data provider responsible for the given file name. If an exclusive data provider has not been requested yet for this file name, then a new exclusive data provider is created, otherwise the previously created provider will be returned. Note that the exclusive data providers will be initialized usingDataProvider.DEFAULT_FILE_ENCODINGand the default parser (getDefaultParser()).Use this method to ensure, that only a single exclusive data provider instance is created.
Line comments won't be handled in any way.
- Parameters:
fileName- the file name/path of the data file- Returns:
- the exclusive data provider
- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read
-
getInstance
public static ExclusiveDataProvider<java.lang.String> getInstance(java.lang.String fileName, boolean filterLineComments) throws java.io.FileNotFoundException, java.io.IOException
Returns the exclusive data provider responsible for the given file name. If an exclusive data provider has not been requested yet for this file name, then a new exclusive data provider is created, otherwise the previously created provider will be returned. Note that the exclusive data providers will be initialized using the default parsergetDefaultParser().Use this method to ensure, that only a single exclusive data provider instance is created.
- Parameters:
fileName- the file name/path of the data filefilterLineComments- whether line comments in given file should be automatically filtered out before content is handed over to given parser- Returns:
- the exclusive data provider
- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read
-
getInstance
public static ExclusiveDataProvider<java.lang.String> getInstance(java.lang.String fileName, java.lang.String encoding) throws java.io.FileNotFoundException, java.io.IOException
Returns the exclusive data provider responsible for the given file name. If an exclusive data provider has not been requested yet for this file name, then a new exclusive data provider is created, otherwise the previously created provider will be returned. Note that the exclusive data providers will be initialized using the default parsergetDefaultParser().Use this method to ensure, that only a single exclusive data provider instance is created.
Line comments won't be handled in any way.
- Parameters:
fileName- the file name/path of the data fileencoding- file encoding- Returns:
- the exclusive data provider
- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read
-
getInstance
public static <T> ExclusiveDataProvider<T> getInstance(java.lang.String fileName, java.lang.String encoding, ExclusiveDataProvider.Parser<T> parser) throws java.io.FileNotFoundException, java.io.IOException
Returns the exclusive data provider responsible for the given file name. If an exclusive data provider has not been requested yet for this file name, then a new exclusive data provider is created, otherwise the previously created provider will be returned.Use this method to ensure, that only a single exclusive data provider instance is created.
Line comments won't be automatically filtered out and need to be handled by the given parser.
- Parameters:
fileName- the file name/path of the data fileencoding- file encodingparser- parser to parse the lines with- Returns:
- the exclusive data provider
- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read- See Also:
DataProvider.DEFAULT_LINE_COMMENT_MARKER
-
getInstance
public static <T> ExclusiveDataProvider<T> getInstance(java.lang.String fileName, boolean filterLineComments, ExclusiveDataProvider.Parser<T> parser) throws java.io.FileNotFoundException, java.io.IOException
Returns the exclusive data provider responsible for the given file name. If an exclusive data provider has not been requested yet for this file name, then a new exclusive data provider is created, otherwise the previously created provider will be returned. Note that the exclusive data providers will be initialized usingDataProvider.DEFAULT_FILE_ENCODING.Use this method to ensure, that only a single exclusive data provider instance is created.
- Parameters:
fileName- the file name/path of the data fileparser- parser to parse the lines withfilterLineComments- whether line comments in given file should be automatically filtered out before content is handed over to given parser- Returns:
- the exclusive data provider
- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read- See Also:
DataProvider.DEFAULT_LINE_COMMENT_MARKER
-
getInstance
public static <T> ExclusiveDataProvider<T> getInstance(java.lang.String fileName, ExclusiveDataProvider.Parser<T> parser) throws java.io.FileNotFoundException, java.io.IOException
Returns the exclusive data provider responsible for the given file name. If an exclusive data provider has not been requested yet for this file name, then a new exclusive data provider is created, otherwise the previously created provider will be returned. Note that the exclusive data providers will be initialized usingDataProvider.DEFAULT_FILE_ENCODING.Use this method to ensure, that only a single exclusive data provider instance is created.
Line comments won't be automatically filtered out and need to be handled by the given parser.
- Parameters:
fileName- the file name/path of the data fileparser- parser to parse the lines with- Returns:
- the exclusive data provider
- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read- See Also:
DataProvider.DEFAULT_LINE_COMMENT_MARKER
-
getInstance
public static <T> ExclusiveDataProvider<T> getInstance(java.lang.String fileName, java.lang.String encoding, boolean filterLineComments, ExclusiveDataProvider.Parser<T> parser) throws java.io.FileNotFoundException, java.io.IOException
Returns the exclusive data provider responsible for the given file name. If an exclusive data provider has not been requested yet for this file name, then a new exclusive data provider is created, otherwise the previously created provider will be returned.Use this method to ensure, that only a single exclusive data provider instance is created.
- Parameters:
fileName- the file name/path of the data fileencoding- file encodingfilterLineComments- whether line comments in given file should be automatically filtered out before content is handed over to given parserparser- parser to parse the lines with- Returns:
- the exclusive data provider
- Throws:
java.io.FileNotFoundException- if the data file cannot be foundjava.io.IOException- if the data file cannot be opened or read- See Also:
DataProvider.DEFAULT_LINE_COMMENT_MARKER
-
get
public T get()
Allocate the next available item for exclusive use.- Returns:
- the first item or
nullif no item is available
-
getRandom
public T getRandom()
Allocate a random item for exclusive use.- Returns:
- a random item or
nullif no item is available
-
add
public void add(T item)
Add a new or release a previously received exclusive item.- Parameters:
item- the item to add
-
size
public int size()
Get the number of available items.- Returns:
- number of available items
-
getDefaultParser
public static ExclusiveDataProvider.Parser<java.lang.String> getDefaultParser()
Default parser that just returns the lines it receives.- Returns:
- list of lines
-
-