Kieker 1.2

kieker.monitoring.core
Class MonitoringController

java.lang.Object
  extended by kieker.monitoring.core.MonitoringController
All Implemented Interfaces:
IMonitoringRecordReceiver

public final class MonitoringController
extends Object
implements IMonitoringRecordReceiver

Simple class to store monitoring data in the file system. Although a buffered writer is used, outliers (delays of 1000 ms) occur from time to time if many monitoring events have to be writen. We believe that outliers result from a flush on the buffer of the writer. A more sophisticated writer to store data in the file system is the AsyncFsWriter. This does not introduce the outliers that result from flushing the writing buffer, since provides an asynchronous insertMonitoringData method. However, the AsyncFsWriter introduces a little more overhead because a writing queue is required and it isn't tested as much as the FileSystenWriter. The AsyncFsWriter should usually be used instead of this class to avoid the outliers described above.

Author:
Matthias Rohr, Andre van Hoorn History: 2008/09/01: Removed a lot "synchronized" from the Aspects 2008/08/29: Controller now singleton class Many (performance) improvements to synchronization 2008/08/06: Using tpmon.properties instead of dbconnector.properties and support of using java.io.tmpdir as file system storage directory. The storage directory may be set via the properties file, or (higher priority) via a java command line parameter (-Dtpmon.storeInJavaIoTmpdir=false -Dtpmon.customStoragePath=/var/log/) 2008/07/07: New feature to encode method and component names before making data persistent. This speeds up storage and saves space. 2008/05/29: Changed vmid to vmName (defaults to hostname), which may be changed during runtime 2008/01/04: Refactoring for the first release of Kieker and publication under an open source licence 2007/03/13: Refactoring 2006/12/20: Initial Prototype

Nested Class Summary
static class MonitoringController.ControllerMode
           
 
Field Summary
static AbstractMonitoringRecord END_OF_MONITORING_MARKER
           
static String WRITER_ASYNCDB
           
static String WRITER_ASYNCFS
           
static String WRITER_SYNCDB
           
static String WRITER_SYNCFS
           
 
Method Summary
 long currentTimeNanos()
          Returns the timestamp for the current time.
 void disable()
          Disables monitoring.
 void enable()
          Enables monitoring.
 String getConnectorInfo()
          Returns a human-readable information string about the controller configuration.
 String getDateString()
          Returns a human-readable string with the current date and time.
 int getExperimentId()
           
static MonitoringController getInstance()
          Returns the singleton instance.
 long getNumberOfInserts()
          Shows how many inserts have been performed since last restart of the execution environment.
 String getVersion()
          Return the version name of this controller instance.
 String getVmName()
          The vmName which defaults to the hostname, and may be set by the control-servlet.
 int incExperimentId()
          Increments the experiment ID by 1 and returns the new value.
 boolean isDebug()
           
 boolean isMonitoringEnabled()
           
 boolean isMonitoringPermanentlyTerminated()
           
 boolean newMonitoringRecord(IMonitoringRecord record)
          Passes the given monitoring record to the configured writer if the controller is enabled.
 void setControllerMode(MonitoringController.ControllerMode mode)
          Enables or disables the replay mode (for monitoring the value should be false, i.e. the replay mode is disabled).
 void setDebug(boolean debug)
          Sets the debug mode to the given parameter value.
 void setExperimentId(int newExperimentID)
           
 void setVmname(String newVmname)
          Allows to set an own vmName, a field in the monitoring data to distinguish multiple hosts / vms in a system.
 void terminate()
          Permanently terminates monitoring (e.g., due to a failure).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

END_OF_MONITORING_MARKER

public static final AbstractMonitoringRecord END_OF_MONITORING_MARKER

WRITER_SYNCDB

public static final String WRITER_SYNCDB
See Also:
Constant Field Values

WRITER_ASYNCDB

public static final String WRITER_ASYNCDB
See Also:
Constant Field Values

WRITER_SYNCFS

public static final String WRITER_SYNCFS
See Also:
Constant Field Values

WRITER_ASYNCFS

public static final String WRITER_ASYNCFS
See Also:
Constant Field Values
Method Detail

getInstance

public static MonitoringController getInstance()
Returns the singleton instance.


getVmName

public final String getVmName()
The vmName which defaults to the hostname, and may be set by the control-servlet. The vmName will be part of the monitoring data and allows to assing observations in cases where the software system is deployed on more than one host. When you want to distinguish multiple Virtual Machines on one host, you have to set the vmName manually (e.g., via the control-servlet, or by directly implementing a call to MonitoringController.setVmname(...).


setVmname

public final void setVmname(String newVmname)
Allows to set an own vmName, a field in the monitoring data to distinguish multiple hosts / vms in a system. This method is for instance used by the Kieker.Monitoring control servlet. The vmName defaults to the hostname. When you want to distinguish multiple Virtual Machines on one host, you have to set the vmName manually (e.g., via the control-servlet, or by directly implementing a call to MonitoringController.setVmname(...).

Parameters:
newVmname -

isDebug

public final boolean isDebug()

getNumberOfInserts

public long getNumberOfInserts()
Shows how many inserts have been performed since last restart of the execution environment.


isMonitoringEnabled

public final boolean isMonitoringEnabled()

isMonitoringPermanentlyTerminated

public final boolean isMonitoringPermanentlyTerminated()

getExperimentId

public final int getExperimentId()

incExperimentId

public int incExperimentId()
Increments the experiment ID by 1 and returns the new value.


setExperimentId

public void setExperimentId(int newExperimentID)

enable

public final void enable()
Enables monitoring.

Throws:
IllegalStateException - if controller has been terminated prior to call

disable

public final void disable()
Disables monitoring. Monitoring may be enabled again by calling enableMonitoring().

Throws:
IllegalStateException - if controller has been terminated prior to call

terminate

public final void terminate()
Permanently terminates monitoring (e.g., due to a failure). Subsequent tries to enable monitoring will be refused.


setControllerMode

public final void setControllerMode(MonitoringController.ControllerMode mode)
Enables or disables the replay mode (for monitoring the value should be false, i.e. the replay mode is disabled). If the controller is in replay mode, the logMonitoringRecord method does not set the logging timestamp of the passed monitoring record.

Parameters:
replayMode -

newMonitoringRecord

public final boolean newMonitoringRecord(IMonitoringRecord record)
Passes the given monitoring record to the configured writer if the controller is enabled. If the controller is in replay mode (usually, this is only required to replay already recorded log data), the logMonitoringRecord method does not set the logging timestamp of the passed monitoring record. Notice, that this method won't throw any exceptions.

Specified by:
newMonitoringRecord in interface IMonitoringRecordReceiver
Parameters:
monitoringRecord - the record to be logged
Returns:
true if the record has been passed the writer successfully; false in case an error occured or the controller is not enabled.

currentTimeNanos

public final long currentTimeNanos()
Returns the timestamp for the current time. The value corresponds to the number of nano seconds elapsed Jan 1, 1970 UTC.


getConnectorInfo

public String getConnectorInfo()
Returns a human-readable information string about the controller configuration.

Returns:
the information string

getDateString

public String getDateString()
Returns a human-readable string with the current date and time.

Returns:
the date/time string.

getVersion

public String getVersion()
Return the version name of this controller instance.

Returns:
the version name

setDebug

public final void setDebug(boolean debug)
Sets the debug mode to the given parameter value.

Parameters:
debug - iff true, debug mode is enabled

Kieker 1.2

Copyright 2010 the Kieker Project, http://kieker.sourceforge.net