public abstract class AbstractServiceMonitor extends Object implements ServiceMonitor
This class provides a basic implementation for most of the interface methods
of the ServiceMonitor
class. Since most pollers do not do any
special initialization, and only require that the interface is an
InetAddress
object this class provides everything by the
poll
interface.
-
-
Constructor Summary
Constructors
Constructor and Description
AbstractServiceMonitor()
-
Method Summary
Methods
Modifier and Type
Method and Description
static Boolean
getKeyedBoolean(Map<String,Object> parameterMap,
String key,
Boolean defaultValue)
static Integer
getKeyedInteger(Map<String,Object> parameterMap,
String key,
Integer defaultValue)
static Long
getKeyedLong(Map<String,Object> parameterMap,
String key,
Long defaultValue)
static Object
getKeyedObject(Map<String,Object> parameterMap,
String key,
Object defaultValue)
static String
getKeyedString(Map<String,Object> parameterMap,
String key,
String defaultValue)
void
initialize(Map<String,Object> parameters)
This method is called after the framework creates an instance of the
plug-in.
void
initialize(MonitoredService svc)
This method is called whenever a new interface that supports the plug-in
service is added to the scheduling system.
abstract PollStatus
poll(MonitoredService svc,
Map<String,Object> parameters)
This method is the heart of the plug-in monitor.
void
release()
This method is called whenever the plug-in is being unloaded, normally
during framework exit.
void
release(MonitoredService svc)
This method is the called whenever an interface is being removed from the
scheduler.
-
-
Method Detail
-
initialize
public void initialize(Map<String,Object> parameters)
This method is called after the framework creates an instance of the
plug-in. The framework passes the object a proxy object that can be used
to retrieve configuration information specific to the plug-in.
Additionally, any parameters for the plug-in from the package definition
are passed using the parameters element.
If there is a critical error, like missing service libraries, the the
Monitor may throw a ServiceMonitorException. If the plug-in throws an
exception then the plug-in will be disabled in the framework.
This method is called after the framework creates an instance of the
plug-in. The framework passes the object a proxy object that can be used
to retrieve configuration information specific to the plug-in.
Additionally, any parameters for the plug-in from the package definition
are passed using the parameters element.
If there is a critical error, like missing service libraries, the
monitor may throw a ServiceMonitorException. If the plug-in throws an
exception then the plug-in will be disabled in the framework.
- Specified by:
initialize
in interface ServiceMonitor
- Parameters:
parameters
- Not currently used
- Throws:
RuntimeException
- Thrown if an unrecoverable error occurs that prevents the
plug-in from functioning.
-
release
public void release()
This method is called whenever the plug-in is being unloaded, normally
during framework exit. During this time the framework may release any
resource and save any state information using the proxy object from the
initialization routine.
Even if the plug-in throws a monitor exception, it will not prevent the
plug-in from being unloaded. The plug-in should not return until all of
its state information is saved. Once the plug-in returns from this call
its configuration proxy object is considered invalid.
- Specified by:
release
in interface ServiceMonitor
- Throws:
RuntimeException
- Thrown if an error occurs during deallocation.
-
initialize
public void initialize(MonitoredService svc)
This method is called whenever a new interface that supports the plug-in
service is added to the scheduling system. The plug-in has the option to
load and/or associate configuration information with the interface before
the framework begins scheduling the new device.
Should a monitor exception be thrown during an initialization call then
the framework will log an error and discard the interface from
scheduling.
- Specified by:
initialize
in interface ServiceMonitor
- Parameters:
svc
- a MonitoredService
object.
- Throws:
RuntimeException
- Thrown if an unrecoverable error occurs that prevents the
interface from being monitored.
-
release
public void release(MonitoredService svc)
This method is the called whenever an interface is being removed from the
scheduler. For example, if a service is determined as being no longer
supported then this method will be invoked to cleanup any information
associated with this device. This gives the implementor of the interface
the ability to serialize any data prior to the interface being discarded.
If an exception is thrown during the release the exception will be
logged, but the interface will still be discarded for garbage collection.
This method is the called whenever an interface is being removed from the
scheduler. For example, if a service is determined as being no longer
supported then this method will be invoked to cleanup any information
associated with this device. This gives the implementor of the interface
the ability to serialize any data prior to the interface being discarded.
If an exception is thrown during the release the exception will be
logged, but the interface will still be discarded for garbage collection.
- Specified by:
release
in interface ServiceMonitor
- Parameters:
svc
- TODO
- Throws:
RuntimeException
- Thrown if an unrecoverable error occurs that prevents the
interface from being monitored.
-
poll
public abstract PollStatus poll(MonitoredService svc,
Map<String,Object> parameters)
This method is the heart of the plug-in monitor. Each time an interface
requires a check to be performed as defined by the scheduler the poll
method is invoked. The poll is passed the interface to check
By default when the status transition from up to down or vice versa the
framework will generate an event. Additionally, if the polling interval
changes due to an extended unavailability, the framework will generate an
additional down event. The plug-in can suppress the generation of the
default events by setting the suppress event bit in the returned integer.
- Specified by:
poll
in interface ServiceMonitor
- Parameters:
svc
- TODOparameters
- The package parameters (timeout, retry, etc...) to be used for
this poll.
- Returns:
- The availability of the interface and if a transition event
should be suppressed.
- See Also:
PollStatus.SERVICE_AVAILABLE
,
PollStatus.SERVICE_UNAVAILABLE
,
PollStatus.SERVICE_AVAILABLE
,
PollStatus.SERVICE_UNAVAILABLE
-
getKeyedObject
public static Object getKeyedObject(Map<String,Object> parameterMap,
String key,
Object defaultValue)
-
getKeyedBoolean
public static Boolean getKeyedBoolean(Map<String,Object> parameterMap,
String key,
Boolean defaultValue)
-
getKeyedString
public static String getKeyedString(Map<String,Object> parameterMap,
String key,
String defaultValue)
-
getKeyedInteger
public static Integer getKeyedInteger(Map<String,Object> parameterMap,
String key,
Integer defaultValue)
Copyright © 2015. All rights reserved.