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 booleanactivateProbe(java.lang.String pattern)Activates a probe.voidaddPatternParameter(java.lang.String pattern, java.lang.String parameterName, java.util.List<java.lang.String> parameters)Adds or updates a parameter for the given pattern.voidaddPatternParameterValue(java.lang.String pattern, java.lang.String name, java.lang.String value)Add one value to a list of parameter values for a pattern.voidbeforeEnableMonitoring()Triggers if the monitoring is guaranteed to be enabled, but has not yet been published to other threads.protected voidcleanup()This method should clean up.voidclearPatternParameters(java.lang.String pattern)Deletes all parameters from the given pattern.static MonitoringControllercreateInstance(Configuration configuration)This is a factory method creating a new monitoring controller instance using the given configuration.booleandeactivateProbe(java.lang.String pattern)Deactivates a probe.voiddeletePatternParameter(java.lang.String pattern, java.lang.String parameterName)Deletes a parameter from the given pattern.booleandisableMonitoring()Disables monitoring.booleanenableMonitoring()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.StringgetApplicationName()This method returns the application name stored in the controller.java.lang.StringgetControllerDomain()intgetExperimentId()java.lang.StringgetHostname()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 IMonitoringControllergetInstance()java.lang.StringgetName()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 SamplingControllergetSamplingController()ITimeSourcegetTimeSource()Returns the ITimeSource used in this controller.static java.lang.StringgetVersion()Return the version name of this controller instance.intincExperimentId()Increments the experiment ID by 1 and returns the new value.protected voidinit()This method should to the initialization work.booleanisDebug()Is the debug mode enabled?booleanisMonitoringEnabled()Returns whether monitoring is enabled or disabled/terminated.booleanisMonitoringTerminated()Returns whether monitoring is permanently terminated.booleanisProbeActivated(java.lang.String signature)Tests if a probe is active.booleannewMonitoringRecord(IMonitoringRecord record)Called for each new record to write it out to the pre-configured target (e.g., file system, database, or messaging queue).voidremovePatternParameterValue(java.lang.String pattern, java.lang.String name, java.lang.String value)Remove one value to a list of parameter values for a pattern.booleanremoveScheduledSampler(ScheduledSamplerJob sampler)Stops future executions of the given periodicScheduledSamplerJob.ScheduledSamplerJobschedulePeriodicSampler(ISampler sampler, long initialDelay, long period, java.util.concurrent.TimeUnit timeUnit)Schedules the givenISamplerwith given initial delay, and period.booleansendMetadataAsRecord()This method sends the meta data (like the controller and host name, the experiment ID, etc.) as a record.voidsetExperimentId(int newExperimentID)Sets the experiment ID to the given value.voidsetProbePatternList(java.util.List<java.lang.String> patternList)Overwrites the current list of patterns with a new pattern list.booleanterminateMonitoring()Permanently terminates monitoring.java.lang.StringtoString()This method is used to log the status of the controllers to the console.voidwaitForTermination(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:IStateListenerTriggers 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:
beforeEnableMonitoringin interfaceIStateListener
-
init
protected void init()Description copied from class:AbstractControllerThis method should to the initialization work.- Specified by:
initin classAbstractController
-
cleanup
protected void cleanup()Description copied from class:AbstractControllerThis method should clean up.- Specified by:
cleanupin classAbstractController
-
toString
public java.lang.String toString()Description copied from interface:IMonitoringControllerThis 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:
toStringin interfaceIMonitoringController- Specified by:
toStringin 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:
sendMetadataAsRecordin interfaceIMonitoringController- Returns:
- true on success; false in case of an error.
-
getSamplingController
-
terminateMonitoring
public boolean terminateMonitoring()Description copied from interface:IStateControllerPermanently terminates monitoring.- Specified by:
terminateMonitoringin interfaceIStateController- Returns:
- true if now terminated; false if already terminated
- See Also:
IStateController.isMonitoringTerminated()
-
isMonitoringTerminated
public boolean isMonitoringTerminated()Description copied from interface:IStateControllerReturns whether monitoring is permanently terminated.- Specified by:
isMonitoringTerminatedin 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:IStateControllerEnables monitoring.- Specified by:
enableMonitoringin interfaceIStateController- Returns:
- true if monitoring is enabled, false otherwise
-
disableMonitoring
public boolean disableMonitoring()Description copied from interface:IStateControllerDisables 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:
disableMonitoringin interfaceIStateController- Returns:
- true if monitoring is disabled, false otherwise
-
isMonitoringEnabled
public boolean isMonitoringEnabled()Description copied from interface:IStateControllerReturns whether monitoring is enabled or disabled/terminated.- Specified by:
isMonitoringEnabledin 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:IStateControllerIs 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:
isDebugin interfaceIStateController- Returns:
- debug mode
-
getName
public java.lang.String getName()Description copied from interface:IStateControllerReturns the name of this controller.- Specified by:
getNamein interfaceIStateController- Returns:
- String
-
getHostname
public java.lang.String getHostname()Description copied from interface:IStateControllerThe 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:
getHostnamein interfaceIStateController- Returns:
- The hostname.
-
getApplicationName
public java.lang.String getApplicationName()Description copied from interface:IMonitoringControllerThis method returns the application name stored in the controller.- Specified by:
getApplicationNamein interfaceIMonitoringController- Returns:
- the application name
-
incExperimentId
public int incExperimentId()Description copied from interface:IStateControllerIncrements the experiment ID by 1 and returns the new value.- Specified by:
incExperimentIdin interfaceIStateController- Returns:
- experimentID
-
setExperimentId
public void setExperimentId(int newExperimentID)Description copied from interface:IStateControllerSets the experiment ID to the given value.- Specified by:
setExperimentIdin interfaceIStateController- Parameters:
newExperimentID- The new ID.
-
getExperimentId
public int getExperimentId()- Specified by:
getExperimentIdin interfaceIStateController- Returns:
- The experiment ID.
-
newMonitoringRecord
Description copied from interface:IWriterControllerCalled 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 inIMonitoringRecordand thus alter itsloggingTimestampproperty.Notice, that this method should not throw an exception, but indicate an error by the return value false.
- Specified by:
newMonitoringRecordin interfaceIMonitoringRecordReceiver- Specified by:
newMonitoringRecordin 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:IWriterControllerWaits for the termination of the monitoring controller. The termination must be previously triggered byterminateMonitoring().- Specified by:
waitForTerminationin 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:ISamplingControllerSchedules the givenISamplerwith given initial delay, and period.- Specified by:
schedulePeriodicSamplerin 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
ScheduledSamplerJobas a handler for removing the scheduled sampler later on by using the methodISamplingController.removeScheduledSampler(ScheduledSamplerJob).
-
removeScheduledSampler
Description copied from interface:ISamplingControllerStops future executions of the given periodicScheduledSamplerJob.- Specified by:
removeScheduledSamplerin interfaceISamplingController- Parameters:
sampler- The sampler to be removed.- Returns:
- true if the sensor is not registered
-
getTimeSource
Description copied from interface:ITimeSourceControllerReturns the ITimeSource used in this controller.- Specified by:
getTimeSourcein interfaceITimeSourceController- Returns:
- ITimeSource
-
getControllerDomain
public java.lang.String getControllerDomain()- Specified by:
getControllerDomainin interfaceIRemoteController- Returns:
- the domain used by the controller
-
activateProbe
public boolean activateProbe(java.lang.String pattern)Description copied from interface:IProbeControllerActivates a probe.- Specified by:
activateProbein interfaceIProbeController- Parameters:
pattern- pattern for the probe- Returns:
- true on success
-
deactivateProbe
public boolean deactivateProbe(java.lang.String pattern)Description copied from interface:IProbeControllerDeactivates a probe.- Specified by:
deactivateProbein interfaceIProbeController- Parameters:
pattern- pattern for the probe- Returns:
- true on success
-
isProbeActivated
public boolean isProbeActivated(java.lang.String signature)Description copied from interface:IProbeControllerTests if a probe is active. This test is ignorant of the fact whether monitoring itself is enabled/disabled/terminated.- Specified by:
isProbeActivatedin 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:IProbeControllerOverwrites the current list of patterns with a new pattern list.- Specified by:
setProbePatternListin 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:IProbeControllerReturns the current list of patterns with a prefix indicating whether the pattern is active or not.- Specified by:
getProbePatternListin 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:IProbeControllerLooks up the parameters for a probe /the pattern of the probe and returns them, may be null.- Specified by:
getAllPatternParametersin 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:IProbeControllerDeletes a parameter from the given pattern.- Specified by:
deletePatternParameterin 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:IProbeControllerDeletes all parameters from the given pattern.- Specified by:
clearPatternParametersin 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:IProbeControllerAdds or updates a parameter for the given pattern.- Specified by:
addPatternParameterin 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:IProbeControllerAdd one value to a list of parameter values for a pattern.- Specified by:
addPatternParameterValuein 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:IProbeControllerRemove one value to a list of parameter values for a pattern.- Specified by:
removePatternParameterValuein interfaceIProbeController- Parameters:
pattern- identifying the pattern for the parametername- name of the parametervalue- value to be removed from the list of parameter values.
-
getInstance
-