public interface Reporter
Measurement Units
and combines
them into a single Measurement
. The core method
is report()
that is called each time a new measurement unit is ready.
Reporter should not report anything unless it has been started with the start()
method.
If it is properly started, it should regularly report to all
registered destinations depending on the configured reporting periods. Reporter can assume
that RunInfo
has been set before calling
the start()
method. It is the pure responsibility of Reporter to publish measurement
results to destination in the configured periods. All period types must be supported.
For easier development, it is advised to inherit from AbstractReporter
which provides
some common functionality including proper results publishing. One should directly implement
this interface only when there is a serious reason.
Reporter must be thread safe as it can be called from multiple threads at the same time.Modifier and Type | Method and Description |
---|---|
Set<Destination> |
getDestinations()
Gets an unmodifiable set of all registered destinations.
|
Set<BoundPeriod<Destination>> |
getReportingPeriods()
Gets an unmodifiable set of registered reporting periods.
|
void |
publishResult(PeriodType periodType,
Destination destination)
Publishes results to the destination.
|
void |
registerDestination(Destination destination,
Period period)
Registers a destination to receive resulting
Measurements in
a given period. |
void |
registerDestination(Destination destination,
Set<Period> periods)
Registers a destination to receive resulting
Measurements in
given periods. |
void |
report(MeasurementUnit measurementUnit)
This method is called each time a new
Measurement Unit is obtained. |
void |
reset()
Resets the reporter statistics to the initial state.
|
void |
setReportManager(ReportManager reportManager)
Sets
Report Manager for the report to be able to control and
monitor the current status of reporting. |
void |
setRunInfo(RunInfo runInfo)
Sets
Run Info for the current measurement run. |
void |
start()
Starts the reporter.
|
void |
stop()
Stops the reporter.
|
void |
unregisterDestination(Destination destination)
Removes a previously registered Destination.
|
void report(MeasurementUnit measurementUnit) throws ReportingException
Measurement Unit
is obtained. Each unit is reported once and only once to each of the reporters. The reporter
is not allowed to modify the Measurement Unit. This method must be thread-safe.measurementUnit
- Measurement Unit from a run iterationReportingException
- When it was not possible to report the MeasurementUnit
.void registerDestination(Destination destination, Period period)
Measurements
in
a given period.destination
- The Destination to which the results should be publishedperiod
- The period interval in which the destination should publish resultsvoid registerDestination(Destination destination, Set<Period> periods)
Measurements
in
given periods. It is the goal of Reporter to make sure the
results are published to the registered destinations. For an easier development it is advised
to extend AbstractReporter
which already takes care of this.
A destination cannot be registered with the same period type multiple times (i.e. one cannot register
a destination with a period of iteration type that reports every 10 iterations, and with a period of
iteration type that reports every 100 iterations at the same time).destination
- The Destination to which the results should be published.periods
- The set of period intervals in which the destination should publish results.void publishResult(PeriodType periodType, Destination destination) throws ReportingException
periodType
- A period type that caused the invocation of this method.destination
- A destination to which the result should be reported.ReportingException
- When it was not possible to publish results to the given destination.void unregisterDestination(Destination destination)
destination
- The Destination to be unregistered (and stopped)Set<Destination> getDestinations()
void start()
void stop()
void reset()
void setRunInfo(RunInfo runInfo)
Run Info
for the current measurement run. This must be set
prior to starting the reporter. Failed to do so can lead to an assertion error.runInfo
- RunInfo for the current measurement run.void setReportManager(ReportManager reportManager)
Report Manager
for the report to be able to control and
monitor the current status of reporting.reportManager
- ReportManager that owns this Reporter.Set<BoundPeriod<Destination>> getReportingPeriods()
Copyright © 2010–2017 PerfCake Community. All rights reserved.