org.apache.uima.collection.impl.cpm.engine
Class SequencedQueue

java.lang.Object
  extended by org.apache.uima.collection.impl.cpm.engine.BoundedWorkQueue
      extended by org.apache.uima.collection.impl.cpm.engine.SequencedQueue

public class SequencedQueue
extends BoundedWorkQueue

This component extends the Bound Queue by guaranteeing delivery of CASes in sequential order. Large documents may be split into smaller chunks and and each is processed asynchronously. Since these chunks are processed at different speeds (in multi-pipeline CPE configurations), they may arrive at the queue out of order. The Cas Consumer may need those chunks in the correct order. This component checks each CAS metadata for a clue to see if the CAS is part of a larger sequence. If so, it sets its internal state so that it can expect the proper chunk to come in. A timer thread is used to make sure that this component does not wait indefinitely for expected chunk. If the timer goes off, the entire document ( and all its CASes) are invalidated.


Field Summary
protected  java.util.ArrayList statusCbL
           
 
Fields inherited from class org.apache.uima.collection.impl.cpm.engine.BoundedWorkQueue
cpm, numberElementsInQueue, queue, queueMaxSize, queueName, WAIT_TIMEOUT
 
Constructor Summary
SequencedQueue(int aQueueSize, java.lang.String aQueueName, CPMEngine aCpmEngine)
          Initialize this queue
 
Method Summary
 java.lang.Object dequeue()
          Removes an object from the front of the queue according to FIFO model.
 java.lang.Object dequeue(long aTimeout)
          Returns an object from the queue.
protected  void doNotifyListeners(java.lang.Object aCas, EntityProcessStatus aEntityProcStatus)
          Notifies all configured listeners.
 void invalidate(CAS[] aCasObjectList)
           
 
Methods inherited from class org.apache.uima.collection.impl.cpm.engine.BoundedWorkQueue
enqueue, getCapacity, getCurrentSize, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

statusCbL

protected java.util.ArrayList statusCbL
Constructor Detail

SequencedQueue

public SequencedQueue(int aQueueSize,
                      java.lang.String aQueueName,
                      CPMEngine aCpmEngine)
Initialize this queue

Parameters:
aQueueSize - - the size of the queue
aQueueName - - the name of the queue
aCpmEngine - - reference to the CPE
Method Detail

dequeue

public java.lang.Object dequeue()
Removes an object from the front of the queue according to FIFO model. It sequences chunks so that they are returned in the right sequential order. It handles out of sequence CAS arrivals and returns it in a wraper.

Overrides:
dequeue in class BoundedWorkQueue
Returns:
object dequeued from the head of the queue

dequeue

public java.lang.Object dequeue(long aTimeout)
Returns an object from the queue. It will wait for the object to show up in the queue until a given timer expires.

Overrides:
dequeue in class BoundedWorkQueue
Parameters:
aTimeout - - max millis to wait for an object
Returns:
- Object from the queue, or null if time out

invalidate

public void invalidate(CAS[] aCasObjectList)
Overrides:
invalidate in class BoundedWorkQueue

doNotifyListeners

protected void doNotifyListeners(java.lang.Object aCas,
                                 EntityProcessStatus aEntityProcStatus)
Notifies all configured listeners. Makes sure that appropriate type of Cas is sent to the listener. Conversions take place to ensure compatibility.

Parameters:
aCas - - Cas to pass to listener
isCasObject - - true is Cas is of type CAS
aEntityProcStatus - - status object containing exceptions and trace info


Copyright © 2010 The Apache Software Foundation. All Rights Reserved.