Class RMeasurementStore
- java.lang.Object
-
- edu.kit.ipd.sdq.eventsim.measurement.r.RMeasurementStore
-
- All Implemented Interfaces:
MeasurementStorage
public class RMeasurementStore extends Object implements MeasurementStorage
StoresMeasurement
s into R using Rserve (for details on Rserve see https://rforge.net/Rserve).Measurements are buffered and sent to R as a batch once the buffer size reaches its capacity. Increasing the buffer capacity improves performance at the cost of higher memory consumption (this needs to be further evaluated, however).
-
-
Constructor Summary
Constructors Constructor Description RMeasurementStore(RserveConnection connection)
Use this constructor when no RDS file is to be created upon finish.RMeasurementStore(RserveConnection connection, String rdsFilePath)
Use this constructor when an RDS file is to be created upon finish.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIdExtractor(Class<? extends Object> elementClass, Function<Object,String> extractionFunction)
void
addMetadata(Metadata... metadata)
Adds global metadata that will be appended to eachMeasurement
added viaMeasurementStorage.put(Measurement)
.void
addMetadata(List<Metadata> metadata)
void
addNameExtractor(Class<? extends Object> elementClass, Function<Object,String> extractionFunction)
void
addTypeExtractor(Class<? extends Object> elementClass, Function<Object,String> extractionFunction)
void
finish()
static RMeasurementStore
fromLaunchConfiguration(Map<String,Object> configuration, RserveConnection connection)
Constructs aRMeasurementStore
by extracting configuration options from the provided launch configuration.void
put(Measurement<?> m)
Stores the given measurement.void
start()
-
-
-
Constructor Detail
-
RMeasurementStore
public RMeasurementStore(RserveConnection connection)
Use this constructor when no RDS file is to be created upon finish.
-
RMeasurementStore
public RMeasurementStore(RserveConnection connection, String rdsFilePath)
Use this constructor when an RDS file is to be created upon finish.- Parameters:
rdsFilePath
- the location of the file to be created.
-
-
Method Detail
-
fromLaunchConfiguration
public static RMeasurementStore fromLaunchConfiguration(Map<String,Object> configuration, RserveConnection connection)
Constructs aRMeasurementStore
by extracting configuration options from the provided launch configuration.- Parameters:
configuration
- the launch configuration- Returns:
- the constructed
RMeasurementStore
, ornull
if expected configuration options could not be found in the provided launch configuration.
-
addIdExtractor
public void addIdExtractor(Class<? extends Object> elementClass, Function<Object,String> extractionFunction)
Description copied from interface:MeasurementStorage
Adds a mapping (by means of aFunction
) fromObject
s of a fixed type toString
s that uniquely identify (id) objects of the specifiedtype
. This allows to extract ids from arbitraryObject
s without dictating an interface.- Specified by:
addIdExtractor
in interfaceMeasurementStorage
- Parameters:
elementClass
- the type's classextractionFunction
- the function that mapstype
instances to id-Strings.
-
addNameExtractor
public void addNameExtractor(Class<? extends Object> elementClass, Function<Object,String> extractionFunction)
- Specified by:
addNameExtractor
in interfaceMeasurementStorage
- Parameters:
elementClass
- the type's classextractionFunction
- the function that mapstype
instances to name-Strings.- See Also:
MeasurementStorage.addIdExtractor(Class, Function)
-
addTypeExtractor
public void addTypeExtractor(Class<? extends Object> elementClass, Function<Object,String> extractionFunction)
- Specified by:
addTypeExtractor
in interfaceMeasurementStorage
extractionFunction
- the function that mapstype
instances to type-Strings.- See Also:
MeasurementStorage.addIdExtractor(Class, Function)
-
put
public void put(Measurement<?> m)
Description copied from interface:MeasurementStorage
Stores the given measurement.- Specified by:
put
in interfaceMeasurementStorage
- Parameters:
m
- the measurement to be added
-
addMetadata
public void addMetadata(Metadata... metadata)
Description copied from interface:MeasurementStorage
Adds global metadata that will be appended to eachMeasurement
added viaMeasurementStorage.put(Measurement)
.- Specified by:
addMetadata
in interfaceMeasurementStorage
- Parameters:
metadata
- the global metadata to be appended
-
addMetadata
public void addMetadata(List<Metadata> metadata)
- Specified by:
addMetadata
in interfaceMeasurementStorage
- See Also:
MeasurementStorage.addMetadata(Metadata...)
-
start
public void start() throws MeasurementStorageStartException
- Specified by:
start
in interfaceMeasurementStorage
- Throws:
MeasurementStorageStartException
-
finish
public void finish()
- Specified by:
finish
in interfaceMeasurementStorage
-
-