Class MonitoringController
java.lang.Object
kieker.monitoring.core.controller.AbstractController
kieker.monitoring.core.controller.MonitoringController
- All Implemented Interfaces:
IMonitoringRecordReceiver
,IMonitoringController
,IProbeController
,IRemoteController
,ISamplingController
,IStateController
,IStateListener
,ITimeSourceController
,IWriterController
public final class MonitoringController extends AbstractController implements IMonitoringController, IStateListener
- Since:
- 1.3
- Author:
- Jan Waller
-
Field Summary
Fields inherited from class kieker.monitoring.core.controller.AbstractController
monitoringController
-
Method Summary
Modifier and Type Method Description boolean
activateProbe(java.lang.String pattern)
Activates a probe.void
addPatternParameter(java.lang.String pattern, java.lang.String parameterName, java.util.List<java.lang.String> parameters)
Adds or updates a parameter for the given pattern.void
addPatternParameterValue(java.lang.String pattern, java.lang.String name, java.lang.String value)
Add one value to a list of parameter values for a pattern.void
beforeEnableMonitoring()
Triggers if the monitoring is guaranteed to be enabled, but has not yet been published to other threads.protected void
cleanup()
This method should clean up.void
clearPatternParameters(java.lang.String pattern)
Deletes all parameters from the given pattern.static MonitoringController
createInstance(Configuration configuration)
This is a factory method creating a new monitoring controller instance using the given configuration.boolean
deactivateProbe(java.lang.String pattern)
Deactivates a probe.void
deletePatternParameter(java.lang.String pattern, java.lang.String parameterName)
Deletes a parameter from the given pattern.boolean
disableMonitoring()
Disables monitoring.boolean
enableMonitoring()
Enables monitoring.java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getAllPatternParameters(java.lang.String pattern)
Looks up the parameters for a probe /the pattern of the probe and returns them, may be null.java.lang.String
getApplicationName()
This method returns the application name stored in the controller.java.lang.String
getControllerDomain()
int
getExperimentId()
java.lang.String
getHostname()
The hostname will be part of the monitoring data and allows to distinguish observations in cases where the software system is deployed on more than one host.static IMonitoringController
getInstance()
java.lang.String
getName()
Returns the name of this controller.java.util.List<java.lang.String>
getProbePatternList()
Returns the current list of patterns with a prefix indicating whether the pattern is active or not.protected SamplingController
getSamplingController()
ITimeSource
getTimeSource()
Returns the ITimeSource used in this controller.static java.lang.String
getVersion()
Return the version name of this controller instance.int
incExperimentId()
Increments the experiment ID by 1 and returns the new value.protected void
init()
This method should to the initialization work.boolean
isDebug()
Is the debug mode enabled?boolean
isMonitoringEnabled()
Returns whether monitoring is enabled or disabled/terminated.boolean
isMonitoringTerminated()
Returns whether monitoring is permanently terminated.boolean
isProbeActivated(java.lang.String signature)
Tests if a probe is active.boolean
newMonitoringRecord(IMonitoringRecord record)
Called for each new record to write it out to the pre-configured target (e.g., file system, database, or messaging queue).void
removePatternParameterValue(java.lang.String pattern, java.lang.String name, java.lang.String value)
Remove one value to a list of parameter values for a pattern.boolean
removeScheduledSampler(ScheduledSamplerJob sampler)
Stops future executions of the given periodicScheduledSamplerJob
.ScheduledSamplerJob
schedulePeriodicSampler(ISampler sampler, long initialDelay, long period, java.util.concurrent.TimeUnit timeUnit)
Schedules the givenISampler
with given initial delay, and period.boolean
sendMetadataAsRecord()
This method sends the meta data (like the controller and host name, the experiment ID, etc.) as a record.void
setExperimentId(int newExperimentID)
Sets the experiment ID to the given value.void
setProbePatternList(java.util.List<java.lang.String> patternList)
Overwrites the current list of patterns with a new pattern list.boolean
terminateMonitoring()
Permanently terminates monitoring.java.lang.String
toString()
This method is used to log the status of the controllers to the console.void
waitForTermination(long timeoutInMs)
Waits for the termination of the monitoring controller.Methods inherited from class kieker.monitoring.core.controller.AbstractController
createAndInitialize, isTerminated, setMonitoringController, terminate
-
Method Details
-
createInstance
This is a factory method creating a new monitoring controller instance using the given configuration.- Parameters:
configuration
- The configuration for the new controller.- Returns:
- A new controller.
-
getVersion
public static java.lang.String getVersion()Return the version name of this controller instance.- Returns:
- the version name
-
beforeEnableMonitoring
public void beforeEnableMonitoring()Description copied from interface:IStateListener
Triggers if the monitoring is guaranteed to be enabled, but has not yet been published to other threads. This method is provided especially to guarantee that the meta data record is sent before any other record.- Specified by:
beforeEnableMonitoring
in interfaceIStateListener
-
init
protected void init()Description copied from class:AbstractController
This method should to the initialization work.- Specified by:
init
in classAbstractController
-
cleanup
protected void cleanup()Description copied from class:AbstractController
This method should clean up.- Specified by:
cleanup
in classAbstractController
-
toString
public java.lang.String toString()Description copied from interface:IMonitoringController
This method is used to log the status of the controllers to the console. It is included in this interface to ensure its publication over JMX.- Specified by:
toString
in interfaceIMonitoringController
- Specified by:
toString
in classAbstractController
- Returns:
- a String representation of the current controller
-
sendMetadataAsRecord
public boolean sendMetadataAsRecord()This method sends the meta data (like the controller and host name, the experiment ID, etc.) as a record.- Specified by:
sendMetadataAsRecord
in interfaceIMonitoringController
- Returns:
- true on success; false in case of an error.
-
getSamplingController
-
terminateMonitoring
public boolean terminateMonitoring()Description copied from interface:IStateController
Permanently terminates monitoring.- Specified by:
terminateMonitoring
in interfaceIStateController
- Returns:
- true if now terminated; false if already terminated
- See Also:
IStateController.isMonitoringTerminated()
-
isMonitoringTerminated
public boolean isMonitoringTerminated()Description copied from interface:IStateController
Returns whether monitoring is permanently terminated.- Specified by:
isMonitoringTerminated
in interfaceIStateController
- Returns:
- true if monitoring is permanently terminated, false if monitoring is enabled or disabled.
- See Also:
IStateController.terminateMonitoring()
-
enableMonitoring
public boolean enableMonitoring()Description copied from interface:IStateController
Enables monitoring.- Specified by:
enableMonitoring
in interfaceIStateController
- Returns:
- true if monitoring is enabled, false otherwise
-
disableMonitoring
public boolean disableMonitoring()Description copied from interface:IStateController
Disables monitoring. If monitoring is disabled, the MonitoringController simply pauses. Furthermore, probes should stop collecting new data and monitoring writers stop should stop writing existing data.- Specified by:
disableMonitoring
in interfaceIStateController
- Returns:
- true if monitoring is disabled, false otherwise
-
isMonitoringEnabled
public boolean isMonitoringEnabled()Description copied from interface:IStateController
Returns whether monitoring is enabled or disabled/terminated.- Specified by:
isMonitoringEnabled
in interfaceIStateController
- Returns:
- true of monitoring is enabled, false if monitoring is disabled or terminated.
- See Also:
IStateController.disableMonitoring()
,IStateController.enableMonitoring()
-
isDebug
public boolean isDebug()Description copied from interface:IStateController
Is the debug mode enabled?Debug mode is for internal use only and changes a few internal id generation mechanisms to enable easier debugging. Additionally, it is possible to enable debug logging in the settings of the used logger.
- Specified by:
isDebug
in interfaceIStateController
- Returns:
- debug mode
-
getName
public java.lang.String getName()Description copied from interface:IStateController
Returns the name of this controller.- Specified by:
getName
in interfaceIStateController
- Returns:
- String
-
getHostname
public java.lang.String getHostname()Description copied from interface:IStateController
The hostname will be part of the monitoring data and allows to distinguish 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 hostname manually in the Configuration.- Specified by:
getHostname
in interfaceIStateController
- Returns:
- The hostname.
-
getApplicationName
public java.lang.String getApplicationName()Description copied from interface:IMonitoringController
This method returns the application name stored in the controller.- Specified by:
getApplicationName
in interfaceIMonitoringController
- Returns:
- the application name
-
incExperimentId
public int incExperimentId()Description copied from interface:IStateController
Increments the experiment ID by 1 and returns the new value.- Specified by:
incExperimentId
in interfaceIStateController
- Returns:
- experimentID
-
setExperimentId
public void setExperimentId(int newExperimentID)Description copied from interface:IStateController
Sets the experiment ID to the given value.- Specified by:
setExperimentId
in interfaceIStateController
- Parameters:
newExperimentID
- The new ID.
-
getExperimentId
public int getExperimentId()- Specified by:
getExperimentId
in interfaceIStateController
- Returns:
- The experiment ID.
-
newMonitoringRecord
Description copied from interface:IWriterController
Called for each new record to write it out to the pre-configured target (e.g., file system, database, or messaging queue). This method could invoke the given
record
's methods declared inIMonitoringRecord
and thus alter itsloggingTimestamp
property.Notice, that this method should not throw an exception, but indicate an error by the return value false.
- Specified by:
newMonitoringRecord
in interfaceIMonitoringRecordReceiver
- Specified by:
newMonitoringRecord
in interfaceIWriterController
- Parameters:
record
- the record.- Returns:
- true on success; false in case of an error.
-
waitForTermination
public void waitForTermination(long timeoutInMs) throws java.lang.InterruptedExceptionDescription copied from interface:IWriterController
Waits for the termination of the monitoring controller. The termination must be previously triggered byterminateMonitoring()
.- Specified by:
waitForTermination
in interfaceIWriterController
- Parameters:
timeoutInMs
- timeout in milliseconds to wait (a timeout of 0 means to wait forever)- Throws:
java.lang.InterruptedException
- if the calling thread was interrupted while waiting for the termination
-
schedulePeriodicSampler
public ScheduledSamplerJob schedulePeriodicSampler(ISampler sampler, long initialDelay, long period, java.util.concurrent.TimeUnit timeUnit)Description copied from interface:ISamplingController
Schedules the givenISampler
with given initial delay, and period.- Specified by:
schedulePeriodicSampler
in interfaceISamplingController
- Parameters:
sampler
- The sampler to schedule.initialDelay
- The initial delay.period
- The period.timeUnit
- The time unit which determines how to interpret the given parameter.- Returns:
- a
ScheduledSamplerJob
as a handler for removing the scheduled sampler later on by using the methodISamplingController.removeScheduledSampler(ScheduledSamplerJob)
.
-
removeScheduledSampler
Description copied from interface:ISamplingController
Stops future executions of the given periodicScheduledSamplerJob
.- Specified by:
removeScheduledSampler
in interfaceISamplingController
- Parameters:
sampler
- The sampler to be removed.- Returns:
- true if the sensor is not registered
-
getTimeSource
Description copied from interface:ITimeSourceController
Returns the ITimeSource used in this controller.- Specified by:
getTimeSource
in interfaceITimeSourceController
- Returns:
- ITimeSource
-
getControllerDomain
public java.lang.String getControllerDomain()- Specified by:
getControllerDomain
in interfaceIRemoteController
- Returns:
- the domain used by the controller
-
activateProbe
public boolean activateProbe(java.lang.String pattern)Description copied from interface:IProbeController
Activates a probe.- Specified by:
activateProbe
in interfaceIProbeController
- Parameters:
pattern
- pattern for the probe- Returns:
- true on success
-
deactivateProbe
public boolean deactivateProbe(java.lang.String pattern)Description copied from interface:IProbeController
Deactivates a probe.- Specified by:
deactivateProbe
in interfaceIProbeController
- Parameters:
pattern
- pattern for the probe- Returns:
- true on success
-
isProbeActivated
public boolean isProbeActivated(java.lang.String signature)Description copied from interface:IProbeController
Tests if a probe is active. This test is ignorant of the fact whether monitoring itself is enabled/disabled/terminated.- Specified by:
isProbeActivated
in interfaceIProbeController
- Parameters:
signature
- signature of the probe- Returns:
- true if the probe with this signature is active
-
setProbePatternList
public void setProbePatternList(java.util.List<java.lang.String> patternList)Description copied from interface:IProbeController
Overwrites the current list of patterns with a new pattern list.- Specified by:
setProbePatternList
in interfaceIProbeController
- Parameters:
patternList
- list of strings with patterns where each string starts either with a + or -. The list can be empty (in which case the internal pattern list and the internal cache are cleared) - but not null.
-
getProbePatternList
public java.util.List<java.lang.String> getProbePatternList()Description copied from interface:IProbeController
Returns the current list of patterns with a prefix indicating whether the pattern is active or not.- Specified by:
getProbePatternList
in interfaceIProbeController
- Returns:
- list of strings with patterns where each string starts either with a + or -
-
getAllPatternParameters
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getAllPatternParameters(java.lang.String pattern)Description copied from interface:IProbeController
Looks up the parameters for a probe /the pattern of the probe and returns them, may be null.- Specified by:
getAllPatternParameters
in interfaceIProbeController
- Parameters:
pattern
- The pattern of the probe.- Returns:
- The parameters of the probe, may be null.
-
deletePatternParameter
public void deletePatternParameter(java.lang.String pattern, java.lang.String parameterName)Description copied from interface:IProbeController
Deletes a parameter from the given pattern.- Specified by:
deletePatternParameter
in interfaceIProbeController
- Parameters:
pattern
- The parameters to be deleted.parameterName
- The name of the parameter.
-
clearPatternParameters
public void clearPatternParameters(java.lang.String pattern)Description copied from interface:IProbeController
Deletes all parameters from the given pattern.- Specified by:
clearPatternParameters
in interfaceIProbeController
- Parameters:
pattern
- The parameters to be deleted.
-
addPatternParameter
public void addPatternParameter(java.lang.String pattern, java.lang.String parameterName, java.util.List<java.lang.String> parameters)Description copied from interface:IProbeController
Adds or updates a parameter for the given pattern.- Specified by:
addPatternParameter
in interfaceIProbeController
- Parameters:
pattern
- The pattern of the probe.parameterName
- The name of the parameter.parameters
- a List of entries for this parameter.
-
addPatternParameterValue
public void addPatternParameterValue(java.lang.String pattern, java.lang.String name, java.lang.String value)Description copied from interface:IProbeController
Add one value to a list of parameter values for a pattern.- Specified by:
addPatternParameterValue
in interfaceIProbeController
- Parameters:
pattern
- identifying the pattern for the parametername
- name of the parametervalue
- value to be added to the list of parameter values.
-
removePatternParameterValue
public void removePatternParameterValue(java.lang.String pattern, java.lang.String name, java.lang.String value)Description copied from interface:IProbeController
Remove one value to a list of parameter values for a pattern.- Specified by:
removePatternParameterValue
in interfaceIProbeController
- Parameters:
pattern
- identifying the pattern for the parametername
- name of the parametervalue
- value to be removed from the list of parameter values.
-
getInstance
-