Class BaseUIMAAsynchronousEngineCommon_impl
java.lang.Object
org.apache.uima.adapter.jms.client.BaseUIMAAsynchronousEngineCommon_impl
- All Implemented Interfaces:
javax.jms.MessageListener,UimaAsynchronousEngine
- Direct Known Subclasses:
BaseUIMAAsynchronousEngine_impl
public abstract class BaseUIMAAsynchronousEngineCommon_impl
extends Object
implements UimaAsynchronousEngine, javax.jms.MessageListener
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassstatic enumstatic classprotected static classclass -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected AsynchAECasManagerprotected UimaASClientInfoMBeanprotected org.apache.uima.collection.CollectionReaderprotected javax.jms.MessageConsumerprotected Semaphoreprotected Semaphoreprotected Semaphoreprotected intprotected static final intprotected Exceptionprotected Semaphoreprotected UIDGeneratorprotected booleanprotected Listprotected intprotected static final intprotected AtomicLongprotected BlockingQueue<PendingMessage>protected static final intprotected intprotected static final intprotected booleanprotected Semaphoreprotected booleanprotected org.apache.uima.resource.metadata.ProcessingResourceMetaDataprotected booleanprotected org.apache.uima.cas.CASprotected Stringprotected ClientServiceDelegateprotected static final Stringprotected static BaseUIMAAsynchronousEngineCommon_impl.SharedConnectionprotected Threadprotected ConcurrentHashMapprotected AtomicLongprotected static final StringFields inherited from interface org.apache.uima.aae.client.UimaAsynchronousEngine
ApplicationContext, ApplicationName, CasPoolSize, CpcTimeout, DD2SpringXsltFilePath, Endpoint, GetMetaTimeout, ReplyWindow, SaxonClasspath, SerializationStrategy, ServerUri, ShadowCasPoolSize, SharedConnection, Timeout, UimaEeDebug -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidRegisters application specific listener.protected voidcancelTimer(String identifier) protected abstract voidcleanup()voidSends a Collection Processing Complete (CPC) request to a UIMA AS Service and blocks waiting for a reply.booleanprotected abstract javax.jms.BytesMessageprotected abstract javax.jms.TextMessageprotected voidbooleandelayCasIfDelegateInTimedOutState(String aCasReferenceId) Checks the state of a delegate to see if it is in TIMEOUT State.abstract StringDeploys a single UIMA AS container and all services defined in provided deployment descriptors.protected abstract StringdeploySpringContainer(String[] springContextFiles) protected org.apache.uima.cas.CASdeserialize(byte[] binaryData, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest) protected org.apache.uima.cas.CASdeserialize(String aSerializedCAS, org.apache.uima.cas.CAS aCAS) protected org.apache.uima.cas.CASdeserialize(String aSerializedCAS, org.apache.uima.cas.CAS aCAS, org.apache.uima.cas.impl.XmiSerializationSharedData deserSharedData, boolean deltaCas) protected org.apache.uima.cas.CASdeserializeCAS(byte[] aSerializedCAS, String aCasPoolName) protected org.apache.uima.cas.CASdeserializeCAS(byte[] aSerializedCAS, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest) protected org.apache.uima.cas.CASdeserializeCAS(byte[] aSerializedCAS, org.apache.uima.cas.CAS aCas) protected org.apache.uima.cas.CASdeserializeCAS(String aSerializedCAS, String aCasPoolName) protected org.apache.uima.cas.CASdeserializeCAS(String aSerializedCAS, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest) protected org.apache.uima.cas.CASdeserializeCAS(String aSerializedCAS, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest, boolean deltaCas) voiddoStop()protected ConcurrentHashMapgetCache()org.apache.uima.cas.CASgetCAS()Returns a CAS.protected abstract MessageSenderabstract Stringprotected javax.jms.MessageProducergetMessageProducer(javax.jms.Destination destination) org.apache.uima.resource.metadata.ProcessingResourceMetaDataGets the ProcessingResourceMetadata for the asynchronous AnalysisEngine.Not implementedReturns serialization strategy for the remote service.protected voidhandleCollectionProcessCompleteReply(javax.jms.Message message) Handles response to CollectionProcessComplete request.protected voidhandleException(Exception exception, String casReferenceId, String inputCasReferenceId, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest, boolean doNotify) protected voidhandleException(Exception exception, String casReferenceId, String inputCasReferenceId, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest, boolean doNotify, boolean rethrow) protected voidhandleException(javax.jms.Message message, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest, boolean doNotify) protected voidhandleMetadataReply(javax.jms.Message message) Handles response to GetMeta Request.protected voidhandleNonProcessException(Exception exception) protected voidhandleProcessReply(javax.jms.Message message, boolean doNotify, org.apache.uima.util.ProcessTrace pt) Handles response to Process CAS request.protected voidhandleServiceInfo(javax.jms.Message message) Handles a ServiceInfo message returned from the Cas Multiplier.abstract voidinitialize(Map anApplicationContext) Initializes UIMA asynchronous client using configuration parameters provided in a Map object.protected abstract voidinitializeConsumer(String aBrokerURI, javax.jms.Connection connection) protected voidnotifyListeners(org.apache.uima.cas.CAS aCAS, org.apache.uima.collection.EntityProcessStatus aStatus, int aCommand) protected voidnotifyOnTimout(org.apache.uima.cas.CAS aCAS, String anEndpoint, int aTimeoutKind, String casReferenceId) voidvoidonException(Exception aFailure, String aDestination) voidonMessage(javax.jms.Message message) Listener method receiving JMS Messages from the response queue.protected voidCalled when the producer thread is fully initializedvoidprocess()Initiates processing of a collection.booleanContinuously tries to recover connection a broker.protected voidremoveFromCache(String aCasReferenceId) voidUnregisters named application listener.protected voidreset()sendAndReceiveCAS(org.apache.uima.cas.CAS aCAS) This synchronous method sends a given CAS to a UIMA AS service and waits for response.sendAndReceiveCAS(org.apache.uima.cas.CAS aCAS, org.apache.uima.util.ProcessTrace pt) This is a synchronous method which sends a message to a destination and blocks waiting for a reply.sendCAS(org.apache.uima.cas.CAS aCAS) Sends a given CAS for analysis to the UIMA EE Service.protected voidprotected StringserializeCAS(org.apache.uima.cas.CAS aCAS) protected StringserializeCAS(org.apache.uima.cas.CAS aCAS, org.apache.uima.cas.impl.XmiSerializationSharedData serSharedData) Serializes a given CAS.protected abstract voidsetCASMessage(String casReferenceId, byte[] aSerializedCAS, javax.jms.Message msg) protected abstract voidsetCASMessage(String casReferenceId, String aSerializedCAS, javax.jms.Message msg) protected abstract voidsetCASMessage(String casReferenceId, org.apache.uima.cas.CAS aCAS, javax.jms.Message msg) voidsetCollectionReader(org.apache.uima.collection.CollectionReader aCollectionReader) Registers aCollectionReaderinstance to process a Collection.abstract voidsetCPCMessage(javax.jms.Message msg) protected abstract voidsetMetaRequestMessage(javax.jms.Message msg) protected voidsetReleaseCASMessage(javax.jms.TextMessage msg, String aCasReferenceId) protected voidsetSerializationStrategy(String aSerializationStrategy) protected voidprotected voidBlocks while trying to acquire a semaphore awaiting receipt of GetMeta Reply.protected voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.uima.aae.client.UimaAsynchronousEngine
deploy, stop, stopProducingCases, stopProducingCases, undeploy, undeploy
-
Field Details
-
state
-
SHADOW_CAS_POOL
- See Also:
-
MetadataTimeout
protected static final int MetadataTimeout- See Also:
-
CpCTimeout
protected static final int CpCTimeout- See Also:
-
ProcessTimeout
protected static final int ProcessTimeout- See Also:
-
PingTimeout
protected static final int PingTimeout- See Also:
-
initialized
protected volatile boolean initialized -
listeners
-
asynchManager
-
remoteService
protected boolean remoteService -
collectionReader
protected org.apache.uima.collection.CollectionReader collectionReader -
running
protected volatile boolean running -
resourceMetadata
protected org.apache.uima.resource.metadata.ProcessingResourceMetaData resourceMetadata -
sendAndReceiveCAS
protected org.apache.uima.cas.CAS sendAndReceiveCAS -
idGenerator
-
clientCache
-
threadMonitorMap
protected ConcurrentHashMap<Long,BaseUIMAAsynchronousEngineCommon_impl.ThreadMonitor> threadMonitorMap -
processTimeout
protected int processTimeout -
metadataTimeout
protected int metadataTimeout -
cpcTimeout
protected int cpcTimeout -
abort
protected volatile boolean abort -
uniqueIdentifier
-
exc
-
outstandingCasRequests
-
totalCasRequestsSentBetweenCpCs
-
springContainerRegistry
-
consumer
protected javax.jms.MessageConsumer consumer -
serializationStrategy
-
clientSideJmxStats
-
serviceDelegate
-
pendingMessageQueue
-
producerSemaphore
-
cpcSemaphore
-
getMetaSemaphore
-
cpcReadySemaphore
-
cpcReplySemaphore
-
producerInitialized
protected volatile boolean producerInitialized -
shutdownHookThread
-
-
Constructor Details
-
BaseUIMAAsynchronousEngineCommon_impl
public BaseUIMAAsynchronousEngineCommon_impl()
-
-
Method Details
-
getEndPointName
- Throws:
Exception
-
createTextMessage
- Throws:
Exception
-
createBytesMessage
- Throws:
Exception
-
setMetaRequestMessage
- Throws:
Exception
-
setCASMessage
protected abstract void setCASMessage(String casReferenceId, org.apache.uima.cas.CAS aCAS, javax.jms.Message msg) throws Exception - Throws:
Exception
-
setCASMessage
protected abstract void setCASMessage(String casReferenceId, String aSerializedCAS, javax.jms.Message msg) throws Exception - Throws:
Exception
-
setCASMessage
protected abstract void setCASMessage(String casReferenceId, byte[] aSerializedCAS, javax.jms.Message msg) throws Exception - Throws:
Exception
-
setCPCMessage
- Throws:
Exception
-
initialize
public abstract void initialize(Map anApplicationContext) throws org.apache.uima.resource.ResourceInitializationException Description copied from interface:UimaAsynchronousEngineInitializes UIMA asynchronous client using configuration parameters provided in a Map object. It creates a connection to a service queue managed by a Broker as specified in the parameters. A temporary reply queue is also created with a JMS listener attached to it. Once the connections are made and the listener is started the method sends getMeta request to the UIMA AS service and waits for a response. When the reply to getMeta is received the UIMA AS client is fully initialized and notifies an application by callingUimaASStatusCallbackListener.initializationComplete(EntityProcessStatus)on the application listener.- Specified by:
initializein interfaceUimaAsynchronousEngine- Parameters:
anApplicationContext- - configuration containing UIMA EE Service Broker URI, service queue name, timeout value, reply window size, and CAS Pool size.- Throws:
org.apache.uima.resource.ResourceInitializationException
-
cleanup
- Throws:
Exception
-
deploy
public abstract String deploy(String[] aDeploymentDescriptorList, Map anApplicationContext) throws Exception Description copied from interface:UimaAsynchronousEngineDeploys a single UIMA AS container and all services defined in provided deployment descriptors. Each deployment descriptor contains an assembly of related UIMA AS services. This method is synchronous and will block until all UIMA AS services are completely deployed and initialized. If there is a problem deploying any of the UIMA AS services the container is destroyed and exception thrown.- Specified by:
deployin interfaceUimaAsynchronousEngine- Parameters:
aDeploymentDescriptorList- - a list of deployment descriptors to deploy in a container.anApplicationContext- - initialization parameters needed to configure the client and services- Returns:
- - the id of the container in which the UIMA AS services were deployed
- Throws:
Exception- - if there was a problem deploying the container or UIMA AS services.
-
deploySpringContainer
protected abstract String deploySpringContainer(String[] springContextFiles) throws org.apache.uima.resource.ResourceInitializationException - Throws:
org.apache.uima.resource.ResourceInitializationException
-
getDispatcher
-
initializeConsumer
protected abstract void initializeConsumer(String aBrokerURI, javax.jms.Connection connection) throws Exception - Throws:
Exception
-
addStatusCallbackListener
Description copied from interface:UimaAsynchronousEngineRegisters application specific listener. Via this listener the application receives call-backs. More than one listener can be added.- Specified by:
addStatusCallbackListenerin interfaceUimaAsynchronousEngine- Parameters:
aListener- - application listener object to add
-
getSerializationStrategy
Description copied from interface:UimaAsynchronousEngineReturns serialization strategy for the remote service. All CASes will be serialized according to the specified serialization. Either xmi or binary- Specified by:
getSerializationStrategyin interfaceUimaAsynchronousEngine- Returns:
- String type of serialization for CASes
-
setSerializationStrategy
-
serializeCAS
- Throws:
Exception
-
removeStatusCallbackListener
Description copied from interface:UimaAsynchronousEngineUnregisters named application listener.- Specified by:
removeStatusCallbackListenerin interfaceUimaAsynchronousEngine- Parameters:
aListener- - application listener to remove
-
onBeforeMessageSend
-
setCollectionReader
public void setCollectionReader(org.apache.uima.collection.CollectionReader aCollectionReader) throws org.apache.uima.resource.ResourceInitializationException Description copied from interface:UimaAsynchronousEngineRegisters aCollectionReaderinstance to process a Collection. This method must be called first, before callingUimaAsynchronousEngine.process()method.- Specified by:
setCollectionReaderin interfaceUimaAsynchronousEngine- Parameters:
aCollectionReader- - instance of aCollectionReader- Throws:
org.apache.uima.resource.ResourceInitializationException
-
acquireCpcReadySemaphore
protected void acquireCpcReadySemaphore() -
collectionProcessingComplete
public void collectionProcessingComplete() throws org.apache.uima.resource.ResourceProcessExceptionDescription copied from interface:UimaAsynchronousEngineSends a Collection Processing Complete (CPC) request to a UIMA AS Service and blocks waiting for a reply. The method blocks until the service replies or a timeout occurs. Before returning, this method will notify an application of completing the Collection Processing Complete request using registered listener- Specified by:
collectionProcessingCompletein interfaceUimaAsynchronousEngine- Throws:
org.apache.uima.resource.ResourceProcessException
-
doStop
public void doStop() -
getCAS
Returns a CAS. If multiple threads call this method, the order of each request is preserved. The oldest waiting thread receives the CAS. Each request for a CAS is queued, and when the CAS becomes available the oldest waiting thread will receive it for processing.- Specified by:
getCASin interfaceUimaAsynchronousEngine- Returns:
- - new CAS instance fetched from the CAS pool
- Throws:
Exception
-
reset
protected void reset() -
sendMetaRequest
- Throws:
Exception
-
waitForCpcReply
protected void waitForCpcReply() -
waitForMetadataReply
protected void waitForMetadataReply()Blocks while trying to acquire a semaphore awaiting receipt of GetMeta Reply. When the GetMeta is received, or there is a timeout, or the client stops the semaphore will be released. -
getPerformanceReport
Description copied from interface:UimaAsynchronousEngineNot implemented- Specified by:
getPerformanceReportin interfaceUimaAsynchronousEngine- Returns:
- null
-
process
public void process() throws org.apache.uima.resource.ResourceProcessExceptionDescription copied from interface:UimaAsynchronousEngineInitiates processing of a collection. This method should be only called after initialize() has been called and an instance of aCollectionReaderis provided viaUimaAsynchronousEngine.setCollectionReader(CollectionReader). This method blocks until theCollectionReaderfinishes processing the entire collection. Status of the processing can be obtained by registering a listener with theUimaAsynchronousEngine.addStatusCallbackListener(UimaAsBaseCallbackListener)method.The method is synchronized to allow processing of only one collection at a time. The application must wait with processing another collection until it receives notification via a listener
UimaASStatusCallbackListener.collectionProcessComplete(EntityProcessStatus aStatus)- Specified by:
processin interfaceUimaAsynchronousEngine- Throws:
org.apache.uima.resource.ResourceProcessException- - if there is a problem processing the Collection
-
getCache
-
delayCasIfDelegateInTimedOutState
Checks the state of a delegate to see if it is in TIMEOUT State. If it is, push the CAS id onto a list of CASes pending dispatch. The delegate is in a questionable state and the aggregate sends a ping message to check delegate's availability. If the delegate responds to the ping, all CASes in the pending dispatch list will be immediately dispatched.- Throws:
AsynchAEException
-
sendCAS
public String sendCAS(org.apache.uima.cas.CAS aCAS) throws org.apache.uima.resource.ResourceProcessException Sends a given CAS for analysis to the UIMA EE Service.- Specified by:
sendCASin interfaceUimaAsynchronousEngine- Parameters:
aCAS- - a CAS to analyze.- Returns:
- - returns a unique identifier associated with the sent CAS
- Throws:
org.apache.uima.resource.ResourceProcessException
-
handleCollectionProcessCompleteReply
Handles response to CollectionProcessComplete request.- Throws:
Exception
-
handleMetadataReply
Handles response to GetMeta Request. Deserializes ResourceMetaData and initializes CasManager.- Parameters:
message- - jms message containing serialized ResourceMetaData- Throws:
Exception
-
notifyListeners
protected void notifyListeners(org.apache.uima.cas.CAS aCAS, org.apache.uima.collection.EntityProcessStatus aStatus, int aCommand) -
cancelTimer
-
wakeUpSendThread
protected void wakeUpSendThread(BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest) throws Exception - Throws:
Exception
-
handleServiceInfo
Handles a ServiceInfo message returned from the Cas Multiplier. The primary purpose of this message is to provide the client with a dedicated queue object where the client may send messages to the specific CM service instance. An example of this would be a stop request that client needs to send to the specific Cas Multiplier.- Parameters:
message- - message received from a service- Throws:
Exception
-
decrementOutstandingCasCounter
protected void decrementOutstandingCasCounter() -
handleProcessReply
protected void handleProcessReply(javax.jms.Message message, boolean doNotify, org.apache.uima.util.ProcessTrace pt) throws Exception Handles response to Process CAS request. If the message originated in a service that is running in a separate jvm (remote), deserialize the CAS and notify the application of the completed analysis via application listener.- Parameters:
message- - jms message containing serialized CAS- Throws:
Exception
-
handleNonProcessException
- Throws:
Exception
-
handleException
protected void handleException(Exception exception, String casReferenceId, String inputCasReferenceId, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest, boolean doNotify) throws Exception - Throws:
Exception
-
handleException
protected void handleException(Exception exception, String casReferenceId, String inputCasReferenceId, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest, boolean doNotify, boolean rethrow) throws Exception - Throws:
Exception
-
handleException
protected void handleException(javax.jms.Message message, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest, boolean doNotify) throws Exception - Throws:
Exception
-
removeFromCache
-
deserialize
protected org.apache.uima.cas.CAS deserialize(String aSerializedCAS, org.apache.uima.cas.CAS aCAS) throws Exception - Throws:
Exception
-
deserialize
protected org.apache.uima.cas.CAS deserialize(byte[] binaryData, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest) throws Exception - Throws:
Exception
-
deserializeCAS
protected org.apache.uima.cas.CAS deserializeCAS(String aSerializedCAS, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest) throws Exception - Throws:
Exception
-
deserializeCAS
protected org.apache.uima.cas.CAS deserializeCAS(byte[] aSerializedCAS, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest) throws Exception - Throws:
Exception
-
deserializeCAS
protected org.apache.uima.cas.CAS deserializeCAS(byte[] aSerializedCAS, org.apache.uima.cas.CAS aCas) throws Exception - Throws:
Exception
-
deserializeCAS
protected org.apache.uima.cas.CAS deserializeCAS(String aSerializedCAS, BaseUIMAAsynchronousEngineCommon_impl.ClientRequest cachedRequest, boolean deltaCas) throws Exception - Throws:
Exception
-
deserializeCAS
protected org.apache.uima.cas.CAS deserializeCAS(String aSerializedCAS, String aCasPoolName) throws Exception - Throws:
Exception
-
deserializeCAS
protected org.apache.uima.cas.CAS deserializeCAS(byte[] aSerializedCAS, String aCasPoolName) throws Exception - Throws:
Exception
-
onMessage
public void onMessage(javax.jms.Message message) Listener method receiving JMS Messages from the response queue.- Specified by:
onMessagein interfacejavax.jms.MessageListener
-
getMetaData
public org.apache.uima.resource.metadata.ProcessingResourceMetaData getMetaData() throws org.apache.uima.resource.ResourceInitializationExceptionGets the ProcessingResourceMetadata for the asynchronous AnalysisEngine.- Specified by:
getMetaDatain interfaceUimaAsynchronousEngine- Throws:
org.apache.uima.resource.ResourceInitializationException
-
sendAndReceiveCAS
public String sendAndReceiveCAS(org.apache.uima.cas.CAS aCAS, org.apache.uima.util.ProcessTrace pt) throws org.apache.uima.resource.ResourceProcessException This is a synchronous method which sends a message to a destination and blocks waiting for a reply.- Throws:
org.apache.uima.resource.ResourceProcessException
-
sendAndReceiveCAS
public String sendAndReceiveCAS(org.apache.uima.cas.CAS aCAS) throws org.apache.uima.resource.ResourceProcessException Description copied from interface:UimaAsynchronousEngineThis synchronous method sends a given CAS to a UIMA AS service and waits for response. The method either returns a CAS with the result of analysis or throws an exception. It doesn't use call-backs through a registered application listener.- Specified by:
sendAndReceiveCASin interfaceUimaAsynchronousEngine- Parameters:
aCAS- - a CAS to analyze.- Returns:
- - a unique id assigned to the CAS
- Throws:
org.apache.uima.resource.ResourceProcessException
-
notifyOnTimout
-
getMessageProducer
protected javax.jms.MessageProducer getMessageProducer(javax.jms.Destination destination) throws Exception - Throws:
Exception
-
onProducerInitialized
protected void onProducerInitialized()Called when the producer thread is fully initialized -
connectionOpen
public boolean connectionOpen() -
onException
-
setReleaseCASMessage
protected void setReleaseCASMessage(javax.jms.TextMessage msg, String aCasReferenceId) throws Exception - Throws:
Exception
-