uk.org.iscream.cms.server.client.monitors
Class Heartbeat__Monitor

java.lang.Object
  extended byjava.lang.Thread
      extended byuk.org.iscream.cms.server.client.MonitorSkeleton
          extended byuk.org.iscream.cms.server.client.monitors.Heartbeat__Monitor
All Implemented Interfaces:
PluginMonitor, Runnable

public class Heartbeat__Monitor
extends MonitorSkeleton

This Monitor watches heartbeats. It generates an alert when a heartbeat that is expected does not arrive. Unlike all the other monitors, this one is driven by an event *not* occuring, rather than an event occuring. This means it must be actively checking for missing heartbeat's, and thus has an extra inner class thread. This originally took "heartbeat" packets, but they've now been deprecated. Instead we look at UDP packets, or, rather the lack of them :-)

Version:
$Id: Heartbeat__Monitor.java,v 1.25 2003/02/24 20:18:48 tdb Exp $
Author:
$Author: tdb $

Nested Class Summary
private  class Heartbeat__Monitor.HeartbeatHolder
          This inner class simply holding some information about a specific host.
private  class Heartbeat__Monitor.HeartbeatWorker
          This worker thread just checks all the hosts and then waits a period of time before doing it again.
 
Field Summary
private  ConfigurationProxy _cp
          A reference to the configuration proxy in use
private  HashMap _hosts
          A HashMap of hosts, with associated HeartbeatHolder's.
private  Logger _logger
          A reference to the system logger.
private  String _name
          This is the friendly identifier of the component this class is running in.
 int DEFAULT_CHECK_PERIOD
          The default (used if not configured) period at which to check for old heartbeats.
 String DESC
          A description of this monitor
 String REVISION
          The current CVS revision of this class
 
Fields inherited from class uk.org.iscream.cms.server.client.MonitorSkeleton
_alerterQueue, _qID, _running
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Heartbeat__Monitor()
          Constructs a new Heartbeat monitor, and starts off the worker thread.
 
Method Summary
 void analysePacket(XMLPacket packet)
          Analyse a packet of data.
private  int checkAttributeThreshold(long timeSinceLastHB, Register reg)
          Checks whether the time since the last heartbeat is beyond the threshold(s).
private  void createInitialHosts()
          Gets an initial list of hosts from the config and adds a fake set of heartbeats for them.
 String getDescription()
          return the String representation of what the monitor does
protected  Queue getQueue()
          Returns a reference to the Queue we're getting data from.
 String toString()
          Overrides the Object.toString() method to provide clean logging (every class should have this).
 
Methods inherited from class uk.org.iscream.cms.server.client.MonitorSkeleton
getQueueId, processAlert, run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public final String REVISION
The current CVS revision of this class

See Also:
Constant Field Values

DESC

public final String DESC
A description of this monitor

See Also:
Constant Field Values

DEFAULT_CHECK_PERIOD

public final int DEFAULT_CHECK_PERIOD
The default (used if not configured) period at which to check for old heartbeats. (in seconds)

See Also:
Constant Field Values

_name

private String _name
This is the friendly identifier of the component this class is running in. eg, a Filter may be called "filter1", If this class does not have an owning component, a name from the configuration can be placed here. This name could also be changed to null for utility classes.


_cp

private ConfigurationProxy _cp
A reference to the configuration proxy in use


_hosts

private HashMap _hosts
A HashMap of hosts, with associated HeartbeatHolder's.


_logger

private Logger _logger
A reference to the system logger.

Constructor Detail

Heartbeat__Monitor

public Heartbeat__Monitor()
Constructs a new Heartbeat monitor, and starts off the worker thread.

Method Detail

analysePacket

public void analysePacket(XMLPacket packet)
Analyse a packet of data. In this case, this will just register the fact that a heartbeat has arrived.

Specified by:
analysePacket in class MonitorSkeleton
Parameters:
packet - The packet of data to analyse

toString

public String toString()
Overrides the Object.toString() method to provide clean logging (every class should have this). This uses the uk.org.iscream.cms.util.NameFormat class to format the toString()

Returns:
the name of this class and its CVS revision

getDescription

public String getDescription()
return the String representation of what the monitor does

Specified by:
getDescription in interface PluginMonitor
Specified by:
getDescription in class MonitorSkeleton
Returns:
the description

checkAttributeThreshold

private int checkAttributeThreshold(long timeSinceLastHB,
                                    Register reg)
Checks whether the time since the last heartbeat is beyond the threshold(s).

Parameters:
timeSinceLastHB - a long time since the last heartbeat arrived
reg - the Register for this host
Returns:
the level which has been breached, if any

createInitialHosts

private void createInitialHosts()
Gets an initial list of hosts from the config and adds a fake set of heartbeats for them. If the hosts don't respond within the timeout period an alert will be raised. The effect of this is to allow us to know about hosts which weren't on when we started up, and will thus never have generated a heartbeat - yet will still want to know they're not responding.


getQueue

protected Queue getQueue()
Returns a reference to the Queue we're getting data from. This is specific to this monitor.

Specified by:
getQueue in class MonitorSkeleton
Returns:
a reference to a Queue to get data from


Copyright © 2000-2003 i-scream. All Rights Reserved.