com.atlassian.jira.web.monitor.watcher
Class RequestWatcher

java.lang.Object
  extended by com.atlassian.jira.web.monitor.watcher.RequestWatcher

public class RequestWatcher
extends Object

This class will periodically monitor a map of active requests, and will tell you when one of those requests is overdue.

This class is thread-safe.

Since:
v4.3
See Also:
OverdueRequestListener

Constructor Summary
RequestWatcher(long overdueThreshold, ActiveRequestsCallback callback)
          Creates a new RequestWatcher.
 
Method Summary
 void addOverdueRequestListener(OverdueRequestListener overdueRequestListener)
          Adds an OverdueRequestListener to this instance's list of listeners.
 void close()
          Frees any resources associated with this RequestWatcher.
protected  ScheduledExecutorService newSingleThreadExecutor()
          Creates a new single-thread executor service.
protected  void notifyOverdueListeners(List<Request> overdue, long overdueThreshold)
          Notifies each registered listener that the given requests are overdue.
 void removeOverdueRequestListener(OverdueRequestListener overdueRequestListener)
          Removes an OverdueRequestListener from this instance's list of listeners.
 void startWatching()
          Starts watching the activeRequests for overdue requests.
 void stopWatching()
          Stops watching the activeRequests map for overdue requests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestWatcher

public RequestWatcher(long overdueThreshold,
                      ActiveRequestsCallback callback)
Creates a new RequestWatcher.

Parameters:
overdueThreshold - the threshold beyond which a request is deemed overdue, in ms
callback - a RequestCallback
Method Detail

addOverdueRequestListener

public void addOverdueRequestListener(OverdueRequestListener overdueRequestListener)
Adds an OverdueRequestListener to this instance's list of listeners.

Parameters:
overdueRequestListener - a OverdueRequestListener

removeOverdueRequestListener

public void removeOverdueRequestListener(OverdueRequestListener overdueRequestListener)
Removes an OverdueRequestListener from this instance's list of listeners.

Parameters:
overdueRequestListener - a OverdueRequestListener

startWatching

public void startWatching()
Starts watching the activeRequests for overdue requests.


stopWatching

public void stopWatching()
Stops watching the activeRequests map for overdue requests.


close

public void close()
Frees any resources associated with this RequestWatcher.


newSingleThreadExecutor

protected ScheduledExecutorService newSingleThreadExecutor()
Creates a new single-thread executor service.

Returns:
an ExecutorService

notifyOverdueListeners

protected void notifyOverdueListeners(List<Request> overdue,
                                      long overdueThreshold)
Notifies each registered listener that the given requests are overdue.

Parameters:
overdue - a List of Request
overdueThreshold - the number of ms after which a request is deemed to be overdue


Copyright © 2002-2012 Atlassian. All Rights Reserved.