|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@StableMinor(version="6.2", sinceVersion="4.1") public interface IMonitor
A monitor that allows the collection of data related to a specific event. The monitor implementation is not thread safe and its instance should not be cached between event occurrences. But the same instance should be used during a single event occurrence, if it is in a single transaction.
Example for collection a measure data:
IMonitor monitor = ManagerFactory.getMonitorManager().getMonitor(...); // collect may be called multiple times monitor.collect("theMeasureKey", value, null);
Example including duration measure and transaction awareness:
IMonitor monitor = ManagerFactory.getMonitorManager().getMonitor(...); monitor.setTransaction(currentTransaction, null); // only if wants to associate the monitor with a transaction monitor.start(); try { ... // add measure may be called multiple times monitor.collect("theMeasureKey", value, null); ... } finally { // calling stop the duration and activity data will be collected monitor.stop(null); }
Nested Class Summary | |
---|---|
static class |
IMonitor.Setting
Settings that affect how the monitor collects data. |
Method Summary | |
---|---|
void |
collect(long startMillis,
long endMillis,
EnumSet<IMonitor.Setting> settings)
Collects the measures of IMeasureType.MEASURE_TYPE_DURATION_MS
and IMeasureType.MEASURE_TYPE_ACTIVITY_MS . |
void |
collect(String measureTypeKey,
double value,
EnumSet<IMonitor.Setting> settings)
Collects a measure data to this monitor. |
boolean |
isEnabled()
Indicates if this monitor is currently enabled. |
void |
setDefaultSettings(EnumSet<IMonitor.Setting> defaultSettings)
Specifies the default settings to be used when a null
settings argument is given to methods that accept a settings argument. |
void |
setTransaction(ITransaction transaction,
EnumSet<IMonitor.Setting> settings)
Sets the transaction this monitor depends on to save the data it collected. |
void |
start()
Method used to indicate that the monitored event has started. |
void |
stop(EnumSet<IMonitor.Setting> settings)
Method used to indicate that the monitored event has ended. |
Method Detail |
---|
void setDefaultSettings(EnumSet<IMonitor.Setting> defaultSettings) throws PortalException
null
settings argument is given to methods that accept a settings argument.
Changes in the default settings do not affect previous calls to this monitor, it will be used as default settings only to further calls.
If this method is not called, the initial default settings contains
the IMonitor.Setting.COLLECT_TO_MONITOR_BOUND_EVENT_DATA
and IMonitor.Setting.COLLECT_EVEN_IF_TRANSACTION_ROLLS_BACK
settings.
defaultSettings
- the default settings.
PortalException
void setTransaction(ITransaction transaction, EnumSet<IMonitor.Setting> settings) throws PortalException
transaction
- the transaction, or null to remove any associated
transaction from this monitor.settings
- the settings for collecting transaction
related measures. If null
the default settings is used.
of the transaction will also be collected.
PortalException
void start() throws PortalException
#stop(boolean)
method must be called to indicate the end of
the event.
PortalException
#stop(boolean)
void stop(EnumSet<IMonitor.Setting> settings) throws PortalException
start()
must have been called previously.
This method calls collect(long, long, EnumSet)
to collect the measures relative to the use beetween the start and stop
calls.
settings
- configures how the collecting done by this method is executed.
If null
the default settings is used.
PortalException
collect(long, long, EnumSet)
,
start()
void collect(long startMillis, long endMillis, EnumSet<IMonitor.Setting> settings) throws PortalException
IMeasureType.MEASURE_TYPE_DURATION_MS
and IMeasureType.MEASURE_TYPE_ACTIVITY_MS
.
The activity measures are always collected to the event data that contains their respective instant of time. The event data for the duration measure is selected according to the specified settings.
startMillis
- the start of the event in milliseconds since midnight
January 1, 1970 GMT.endMillis
- the end of the event in milliseconds since midnight
January 1, 1970 GMT.settings
- configures how the collecting done by this method is executed.
If null
the default settings is used.
PortalException
void collect(String measureTypeKey, double value, EnumSet<IMonitor.Setting> settings) throws PortalException
measureTypeKey
- the key for the measure type.value
- the measure value to be collected.settings
- configures how the collecting done by this method is executed.
If null
the default settings is used.
PortalException
boolean isEnabled() throws PortalException
If the data collection or calculation may consume resources, the implementation should check if the monitor is enabled, so the resources may be saved when the monitor is disabled.
PortalException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |