ncsa.tools.trebuchet.core.monitors
Class BlockingMonitor

java.lang.Object
  extended byncsa.tools.trebuchet.core.monitors.BlockingMonitor
All Implemented Interfaces:
IOperationListener, IOperationMonitor, Stoppable

public class BlockingMonitor
extends java.lang.Object
implements IOperationMonitor, IOperationListener

Serves as the interface between cache reading and submission agents. Responsible for providing entries to submission agents and for updating entries when state is called back from the submission agent.
Provides the standard blocking pull implementation of IOperationMonitor used in Operations.

Author:
arossi

Constructor Summary
BlockingMonitor()
           
BlockingMonitor(java.util.List queue)
           
 
Method Summary
 void cacheUpdated(java.lang.String operationId, long lastEntryId)
           
 void done(long id)
           
 void halt()
          User-defined method for allowing the run() method (or some other continuous looping process) to exit peacefully.
 ReverseLookupEntry next()
          Blocks unless all these conditions are met:
1.
 void operationFinished(java.lang.String operationId)
           
 void operationStarted(java.lang.String operationId)
           
 void requeue(long id)
           
 void scanningDirectory(java.lang.String operationId, long id)
           
 void setAgent(ICacheAgent agent)
           
 void update(ReverseLookupEntry entry)
          Pass-through to the cache agent.
 void waitUntilNoMoreActive()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockingMonitor

public BlockingMonitor()

BlockingMonitor

public BlockingMonitor(java.util.List queue)
Method Detail

setAgent

public void setAgent(ICacheAgent agent)

next

public ReverseLookupEntry next()
                        throws FatalErrorDuringOperationException
Blocks unless all these conditions are met:
1. queue is empty
2. cache agent throws EOC exception
3. active map is empty

Returns:
entry, or null when operation has exhausted all entries.
Throws:
FatalErrorDuringOperationException

requeue

public void requeue(long id)
Specified by:
requeue in interface IOperationMonitor

done

public void done(long id)
Specified by:
done in interface IOperationMonitor

halt

public void halt()
Description copied from interface: Stoppable
User-defined method for allowing the run() method (or some other continuous looping process) to exit peacefully.

Specified by:
halt in interface Stoppable

update

public void update(ReverseLookupEntry entry)
            throws FatalErrorDuringOperationException
Pass-through to the cache agent.

Specified by:
update in interface IOperationMonitor
Throws:
FatalErrorDuringOperationException

waitUntilNoMoreActive

public void waitUntilNoMoreActive()

cacheUpdated

public void cacheUpdated(java.lang.String operationId,
                         long lastEntryId)
Specified by:
cacheUpdated in interface IOperationListener

operationFinished

public void operationFinished(java.lang.String operationId)
Specified by:
operationFinished in interface IOperationListener

operationStarted

public void operationStarted(java.lang.String operationId)
Specified by:
operationStarted in interface IOperationListener

scanningDirectory

public void scanningDirectory(java.lang.String operationId,
                              long id)
Specified by:
scanningDirectory in interface IOperationListener