org.apache.manifoldcf.crawler.system
Class ResetManager

java.lang.Object
  extended by org.apache.manifoldcf.crawler.system.ResetManager
Direct Known Subclasses:
DocCleanupResetManager, DocDeleteResetManager, JobNotificationThread.NotificationResetManager, SeedingThread.SeedingResetManager, StartDeleteThread.DeleteStartupResetManager, StartupThread.StartupResetManager, WorkerResetManager

public abstract class ResetManager
extends java.lang.Object

The reset manager basically keeps track of threads that work together. If the threads get hosed as a result of problems, then certain resets need to be done. Each instance of this manager therefore tracks all the threads which depend or affect a condition that needs explicit resetting. When a thread recognizes that the database (or whatever resource) is potentially in a state where a reset for the particular condition is required, then the corresponding reset manager object will cause all dependent threads to block, until they are all accounted for. Then, the corrective reset is done, and the threads are released (with a signal corresponding to the fact that a reset occurred returned). This class is meant to be extended in order to implement the exact reset functionality required.


Field Summary
static java.lang.String _rcsid
           
protected  int involvedThreadCount
          This is the count of the threads that care about this resource.
protected  boolean resetRequired
          Boolean which describes whether an event requiring reset has occurred.
protected  int waitingThreads
          This is the number of threads that are waiting for the reset.
 
Constructor Summary
ResetManager()
          Constructor.
 
Method Summary
 void noteEvent()
          Note a resettable event.
protected abstract  void performResetLogic(IThreadContext tc)
          Do the reset logic.
 void registerMe()
          Register a thread with this reset manager.
 boolean waitForReset(IThreadContext tc)
          Enter "wait" state for current thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rcsid

public static final java.lang.String _rcsid
See Also:
Constant Field Values

resetRequired

protected boolean resetRequired
Boolean which describes whether an event requiring reset has occurred.


involvedThreadCount

protected int involvedThreadCount
This is the count of the threads that care about this resource.


waitingThreads

protected int waitingThreads
This is the number of threads that are waiting for the reset.

Constructor Detail

ResetManager

public ResetManager()
Constructor.

Method Detail

registerMe

public void registerMe()
Register a thread with this reset manager.


noteEvent

public void noteEvent()
Note a resettable event.


waitForReset

public boolean waitForReset(IThreadContext tc)
                     throws ManifoldCFException,
                            java.lang.InterruptedException
Enter "wait" state for current thread. This method is the main logic for the reset manager. A thread calls this method, which may block until all other threads are waiting too. Then, the reset method is called by exactly ONE of the waiting threads, and they all are released.

Returns:
false if no reset took place, or true if one did.
Throws:
ManifoldCFException
java.lang.InterruptedException

performResetLogic

protected abstract void performResetLogic(IThreadContext tc)
                                   throws ManifoldCFException
Do the reset logic.

Throws:
ManifoldCFException