lumis.portal.monitor
Interface IMonitor

Package class diagram package IMonitor

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);
 }
 

Since:
4.1.0

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

setDefaultSettings

void setDefaultSettings(EnumSet<IMonitor.Setting> defaultSettings)
                        throws PortalException
Specifies the default settings to be used when a 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.

Parameters:
defaultSettings - the default settings.
Throws:
PortalException
Since:
4.1.0

setTransaction

void setTransaction(ITransaction transaction,
                    EnumSet<IMonitor.Setting> settings)
                    throws PortalException
Sets the transaction this monitor depends on to save the data it collected. The outcome of the transaction may affect whether the data will be saved or discarded, according to the parameters used while collecting the data.

Parameters:
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.
Throws:
PortalException
Since:
4.1.0

start

void start()
           throws PortalException
Method used to indicate that the monitored event has started. The #stop(boolean) method must be called to indicate the end of the event.

Throws:
PortalException
Since:
4.1.0
See Also:
#stop(boolean)

stop

void stop(EnumSet<IMonitor.Setting> settings)
          throws PortalException
Method used to indicate that the monitored event has ended. The 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.

Parameters:
settings - configures how the collecting done by this method is executed. If null the default settings is used.
Throws:
PortalException
Since:
4.1.0
See Also:
collect(long, long, EnumSet), start()

collect

void collect(long startMillis,
             long endMillis,
             EnumSet<IMonitor.Setting> settings)
             throws PortalException
Collects the measures of 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.

Parameters:
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.
Throws:
PortalException
Since:
4.1.0

collect

void collect(String measureTypeKey,
             double value,
             EnumSet<IMonitor.Setting> settings)
             throws PortalException
Collects a measure data to this monitor.

Parameters:
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.
Throws:
PortalException
Since:
4.1.0

isEnabled

boolean isEnabled()
                  throws PortalException
Indicates if this monitor is currently enabled. Disabled monitors do not collect any data.

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.

Returns:
true if this monitor is enabled or false if it is disabled.
Throws:
PortalException
Since:
4.1.0


Lumisportal  5.5.0.091130 - Copyright © 2001-2007, Lumis. All Rights Reserved.