de.is24.util.monitoring
Class CorePlugin

java.lang.Object
  extended by de.is24.util.monitoring.AbstractMonitorPlugin
      extended by de.is24.util.monitoring.CorePlugin
All Implemented Interfaces:
MonitorPlugin

public class CorePlugin
extends AbstractMonitorPlugin

This plugin represents the former core functionality of InApplicationMonitor, on a way to a more flexible implementation by plugins, to simplify testing and the first step on the way fo a more dependency injection friendly implementation. This plugin will take over some functionality that only makes sense in the context of a plugin that stores data locally in the JVM. Other plugins (namely the statsd plugin) move data aggregation out of the JVM. And thus it makes no sense to let them implement some of the patterns like reportableObserver etc.


Field Summary
private  Monitors<Counter> countersTimers
           
private  Monitors<HistorizableList> historizableLists
           
private  InApplicationMonitorJMXConnector inApplicationMonitorJMXConnector
           
private  KeyHandler keyHandler
           
private static org.apache.log4j.Logger LOGGER
           
private  int maxHistoryEntriesToKeep
           
protected  boolean monitorActive
           
private  CopyOnWriteArrayList<ReportableObserver> reportableObservers
           
private  Monitors<StateValueProvider> stateValues
           
private  Monitors<Version> versions
           
 
Constructor Summary
CorePlugin(JmxAppMon4JNamingStrategy jmxAppMon4JNamingStrategy, KeyHandler keyHandler)
           
 
Method Summary
 void addHighRateTimerMeasurement(String name, long timing)
          Add a timer measurement for a rarely occuring event with given name.
 void addHistorizable(String name, Historizable historizable)
          add a Historizable instance to the list identified by historizable.getName()
 void addReportableObserver(ReportableObserver reportableObserver)
          adds a new ReportableObserver that wants to be notified about new Reportables that are registered on the InApplicationMonitor
 void addSingleEventTimerMeasurement(String name, long timing)
          Add a timer measurement for a rarely occuring event with given name.
 void addTimerMeasurement(String name, long timing)
          Add a timer measurement for the given name.
 void afterRemovalNotification()
           
 void destroy()
           
(package private)  Counter getCounter(String name)
          internally used method to retrieve or create and register a named Counter.
(package private)  HistorizableList getHistorizableList(String name)
          internally used method to retrieve or create and register a named HistorizableList.
 int getMaxHistoryEntriesToKeep()
           
(package private)  StateValueProvider getStateValue(String name)
           
(package private)  Timer getTimer(String name)
          internaly used method to retrieve or create and register a named Timer.
 String getUniqueName()
           
 void incrementCounter(String name, int increment)
          Increase the specified counter by a variable amount.
 void incrementHighRateCounter(String name, int increment)
           
private  void incrementInternalCounter(int increment, String name)
           
 void initDefaultStateValues()
           
 void initializeCounter(String name)
          Initialization of a counter.
 void initializeTimerMeasurement(String name)
          Initialization of a TimerMeasurement
 boolean isJMXInitialized()
           
private  void notifyReportableObservers(Reportable reportable)
           
 void registerStateValue(StateValueProvider stateValueProvider)
          Add a state value provider to this appmon4j instance.
 void registerVersion(Version versionToAdd)
          This method was intended to register module names with their current version identifier.
 void removeReportableObserver(ReportableObserver reportableObserver)
          Allow disconnection of observers, mainly for testing
 void reportInto(ReportVisitor reportVisitor)
          Implements the InApplicationMonitor side of the Visitor pattern.
 void setMaxHistoryEntriesToKeep(int aMaxHistoryEntriesToKeep)
          Set the Number of entries to keep for each Historizable list.
 
Methods inherited from class de.is24.util.monitoring.AbstractMonitorPlugin
equals, hashCode, register
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static org.apache.log4j.Logger LOGGER

monitorActive

protected volatile boolean monitorActive

maxHistoryEntriesToKeep

private volatile int maxHistoryEntriesToKeep

reportableObservers

private final CopyOnWriteArrayList<ReportableObserver> reportableObservers

countersTimers

private final Monitors<Counter> countersTimers

stateValues

private final Monitors<StateValueProvider> stateValues

versions

private final Monitors<Version> versions

historizableLists

private final Monitors<HistorizableList> historizableLists

inApplicationMonitorJMXConnector

private InApplicationMonitorJMXConnector inApplicationMonitorJMXConnector

keyHandler

private KeyHandler keyHandler
Constructor Detail

CorePlugin

public CorePlugin(JmxAppMon4JNamingStrategy jmxAppMon4JNamingStrategy,
                  KeyHandler keyHandler)
Method Detail

initDefaultStateValues

public void initDefaultStateValues()

afterRemovalNotification

public void afterRemovalNotification()

destroy

public void destroy()

getUniqueName

public String getUniqueName()

isJMXInitialized

public boolean isJMXInitialized()

getMaxHistoryEntriesToKeep

public int getMaxHistoryEntriesToKeep()
Returns:
Number of entries to keep for each Historizable list.

setMaxHistoryEntriesToKeep

public void setMaxHistoryEntriesToKeep(int aMaxHistoryEntriesToKeep)
Set the Number of entries to keep for each Historizable list. Default is 5.

Parameters:
aMaxHistoryEntriesToKeep - Number of entries to keep

addReportableObserver

public void addReportableObserver(ReportableObserver reportableObserver)
adds a new ReportableObserver that wants to be notified about new Reportables that are registered on the InApplicationMonitor

Parameters:
reportableObserver - the class that wants to be notified

notifyReportableObservers

private void notifyReportableObservers(Reportable reportable)

removeReportableObserver

public void removeReportableObserver(ReportableObserver reportableObserver)
Allow disconnection of observers, mainly for testing

Parameters:
reportableObserver -

reportInto

public void reportInto(ReportVisitor reportVisitor)
Implements the InApplicationMonitor side of the Visitor pattern. Iterates through all registered Reportable instances and calls the corresponding method on the ReportVisitor implementation.

Parameters:
reportVisitor - The ReportVisitor instance that shall be visited by all regieteres Reportable instances.

incrementCounter

public void incrementCounter(String name,
                             int increment)

Increase the specified counter by a variable amount.

Parameters:
name - the name of the Counter to increase
increment - the added to add

incrementHighRateCounter

public void incrementHighRateCounter(String name,
                                     int increment)

incrementInternalCounter

private void incrementInternalCounter(int increment,
                                      String name)

initializeCounter

public void initializeCounter(String name)
Initialization of a counter.

Parameters:
name - the name of the counter to be initialized

addTimerMeasurement

public void addTimerMeasurement(String name,
                                long timing)
Add a timer measurement for the given name. Timers allow adding timer measurements, implicitly incrementing the count Timers count and measure timed events. The application decides which unit to use for timing. Miliseconds are suggested and some ReportVisitor implementations may imply this.

Parameters:
name - name of the Timer
timing - number of elapsed time units for a single measurement

addSingleEventTimerMeasurement

public void addSingleEventTimerMeasurement(String name,
                                           long timing)
Add a timer measurement for a rarely occuring event with given name. This allows Plugins to to react on the estimated rate of the event. Namely the statsd plugin will not sent these , as the requires storage is in no relation to the value of the data. Timers allow adding timer measurements, implicitly incrementing the count Timers count and measure timed events. The application decides which unit to use for timing. Miliseconds are suggested and some ReportVisitor implementations may imply this.

Parameters:
name - name of the Timer
timing - number of elapsed time units for a single measurement

addHighRateTimerMeasurement

public void addHighRateTimerMeasurement(String name,
                                        long timing)
Add a timer measurement for a rarely occuring event with given name. This allows Plugins to to react on the estimated rate of the event. Namely the statsd plugin will not sent these , as the requires storage is in no relation to the value of the data. Timers allow adding timer measurements, implicitly incrementing the count Timers count and measure timed events. The application decides which unit to use for timing. Miliseconds are suggested and some ReportVisitor implementations may imply this.

Parameters:
name - name of the Timer
timing - number of elapsed time units for a single measurement

initializeTimerMeasurement

public void initializeTimerMeasurement(String name)
Initialization of a TimerMeasurement

Parameters:
name - the name of the timer to be initialized

registerStateValue

public void registerStateValue(StateValueProvider stateValueProvider)
Add a state value provider to this appmon4j instance. StateValueProvider instances allow access to a numeric value (long), that is already available in the application.

Parameters:
stateValueProvider - the StateValueProvider instance to add

registerVersion

public void registerVersion(Version versionToAdd)
This method was intended to register module names with their current version identifier. This could / should actually be generalized into an non numeric state value

Parameters:
versionToAdd - The Version Object to add

addHistorizable

public void addHistorizable(String name,
                            Historizable historizable)
add a Historizable instance to the list identified by historizable.getName()

Parameters:
historizable - the historizable to add

getStateValue

StateValueProvider getStateValue(String name)
Parameters:
name - the name of the StatsValueProvider
Returns:
the StatsValueProvider

getCounter

Counter getCounter(String name)
internally used method to retrieve or create and register a named Counter.

Parameters:
name - of the required Counter
Returns:
Counter instance registered for the given name

getTimer

Timer getTimer(String name)
internaly used method to retrieve or create and register a named Timer.

Parameters:
name - of the required Timer
Returns:
Timer instance registered for the given name

getHistorizableList

HistorizableList getHistorizableList(String name)
internally used method to retrieve or create and register a named HistorizableList.

Parameters:
name - of the required HistorizableList
Returns:
HistorizableList instance registered for the given name


Copyright © 2013 Immobilien Scout GmbH. All Rights Reserved.