org.sadun.util.watchdog.listeners
Class WaitAndRetryListener

java.lang.Object
  extended byorg.sadun.util.watchdog.listeners.WaitAndRetryListener
All Implemented Interfaces:
WatchDog.Listener
Direct Known Subclasses:
MailAlarmListener

public abstract class WaitAndRetryListener
extends java.lang.Object
implements WatchDog.Listener

A listener which implements a wait/retry policy on impossible checks and sends an alarm when a failure occurs or the check couldn't be performed for a certain number of times.

Version:
1.0
Author:
Cristiano Sadun

Field Summary
static int DEFAULT_MAX_RETRY_COUNT
          The default maximum number of retries to attempt.
 
Constructor Summary
WaitAndRetryListener()
          Create a listener which waits at most DEFAULT_MAX_RETRY_COUNT impossible checks before declaring a failure.
WaitAndRetryListener(int maxRetryCount)
          Create a listener which waits the given number of impossible checks before declaring a failure.
 
Method Summary
abstract  void checkFailed(java.lang.Object obj, java.lang.Throwable e)
          Notifies the listener that a check has failed.
 void checkImpossible(java.lang.Object obj, WatchDogException e)
          Notifies the listener that a check could not be performed.
 void checkOk(java.lang.Object obj)
          Notifies the listener that a check has been successful
 int getMaxRetryCount()
           
protected  void reset()
           
 void setMaxRetryCount(int maxRetryCount)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_RETRY_COUNT

public static final int DEFAULT_MAX_RETRY_COUNT
The default maximum number of retries to attempt. Its value is 3.

See Also:
Constant Field Values
Constructor Detail

WaitAndRetryListener

public WaitAndRetryListener()
Create a listener which waits at most DEFAULT_MAX_RETRY_COUNT impossible checks before declaring a failure.


WaitAndRetryListener

public WaitAndRetryListener(int maxRetryCount)
Create a listener which waits the given number of impossible checks before declaring a failure.

Parameters:
maxRetryCount - the max number of impossible checks before declaring a failure.
Method Detail

checkOk

public void checkOk(java.lang.Object obj)
Description copied from interface: WatchDog.Listener
Notifies the listener that a check has been successful

Specified by:
checkOk in interface WatchDog.Listener

checkFailed

public abstract void checkFailed(java.lang.Object obj,
                                 java.lang.Throwable e)
Description copied from interface: WatchDog.Listener
Notifies the listener that a check has failed.

Specified by:
checkFailed in interface WatchDog.Listener
Parameters:
e -

checkImpossible

public void checkImpossible(java.lang.Object obj,
                            WatchDogException e)
Description copied from interface: WatchDog.Listener
Notifies the listener that a check could not be performed.

Specified by:
checkImpossible in interface WatchDog.Listener
Parameters:
e -

reset

protected void reset()

getMaxRetryCount

public int getMaxRetryCount()
Returns:
Returns the maxRetryCount.

setMaxRetryCount

public void setMaxRetryCount(int maxRetryCount)
Parameters:
maxRetryCount - The maxRetryCount to set.