Class SequencedQueue
java.lang.Object
org.apache.uima.collection.impl.cpm.engine.BoundedWorkQueue
org.apache.uima.collection.impl.cpm.engine.SequencedQueue
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
FieldsModifier and TypeFieldDescriptionprivate boolean
The chunk state.private ChunkMetadata
The next chunk metadata.protected ArrayList
The status cb L.private HashMap
The timed out docs.Fields inherited from class org.apache.uima.collection.impl.cpm.engine.BoundedWorkQueue
cpm, numberElementsInQueue, queue, queueMaxSize, queueName, WAIT_TIMEOUT
-
Constructor Summary
ConstructorsConstructorDescriptionSequencedQueue
(int aQueueSize, String aQueueName, CPMEngine aCpmEngine) Initialize this queue. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addDocToTimedOutDocs
(int aLifespan, String aDocId) Adds the doc to timed out docs.dequeue()
Removes an object from the front of the queue according to FIFO model.dequeue
(long aTimeout) Returns an object from the queue.protected void
doNotifyListeners
(Object aCas, EntityProcessStatus aEntityProcStatus) Notifies all configured listeners.void
invalidate
(CAS[] aCasObjectList) Invalidate.private boolean
sequenceTimedOut
(ChunkMetadata achunkMetadata) Sequence timed out.private Object
timedOutCas
(int aQueueIndex) Returns a CAS that belong to a timedout chunk sequence.Methods inherited from class org.apache.uima.collection.impl.cpm.engine.BoundedWorkQueue
enqueue, getCapacity, getCurrentSize, getName
-
Field Details
-
chunkState
private boolean chunkStateThe chunk state. -
nextChunkMetadata
The next chunk metadata. -
timedOutDocs
The timed out docs. -
statusCbL
The status cb L.
-
-
Constructor Details
-
SequencedQueue
Initialize this queue.- Parameters:
aQueueSize
- - the size of the queueaQueueName
- - the name of the queueaCpmEngine
- - reference to the CPE
-
-
Method Details
-
sequenceTimedOut
Sequence timed out.- Parameters:
achunkMetadata
- the achunk metadata- Returns:
- true if it timed out
-
timedOutCas
Returns a CAS that belong to a timedout chunk sequence. It wraps the CAS in QueueEntity and indicates that the CAS arrived late. This must be called while holding the class lock (e.g. via synch on the calling methods within this class).- Parameters:
aQueueIndex
- - position in queue from the CAS should be extracted- Returns:
- QueueEntity containing CAS that arrived late
-
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 classBoundedWorkQueue
- Returns:
- object dequeued from the head of the queue
-
dequeue
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 classBoundedWorkQueue
- Parameters:
aTimeout
- - max millis to wait for an object- Returns:
- - Object from the queue, or null if time out
-
invalidate
Description copied from class:BoundedWorkQueue
Invalidate.- Overrides:
invalidate
in classBoundedWorkQueue
- Parameters:
aCasObjectList
- the a cas object list
-
addDocToTimedOutDocs
Adds the doc to timed out docs.- Parameters:
aLifespan
- the a lifespanaDocId
- the a doc id
-
doNotifyListeners
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 listeneraEntityProcStatus
- - status object containing exceptions and trace info
-