uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jaroslaw Cwiklik <uim...@gmail.com>
Subject Re: UIMA-AS client is blocking
Date Wed, 31 Mar 2010 15:36:16 GMT
My bad. Indeed when getCas() is used there is no need to call reset nor
release.

The framework calls release() when the listener  callback finishes. I've
created a test program to run the client without a listener and I see no
hang. Here is the complete test program:

import java.util.HashMap;
import java.util.Map;

import org.apache.uima.aae.client.UimaAsynchronousEngine;
import org.apache.uima.adapter.jms.client.BaseUIMAAsynchronousEngine_impl;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.CASException;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceProcessException;


public class TestUimaASClient {

  BaseUIMAAsynchronousEngine_impl uimaAsEngine;

  public void initialize() throws Exception {
    uimaAsEngine = new BaseUIMAAsynchronousEngine_impl();
    Map<String, Object> appCtx = new HashMap<String, Object>();
    appCtx.put(UimaAsynchronousEngine.ServerUri, "tcp://localhost:61616");
    appCtx.put(UimaAsynchronousEngine.Endpoint, "RoomNumberAnnotatorQueue");
    appCtx.put(UimaAsynchronousEngine.CasPoolSize, 1);
    appCtx.put(UimaAsynchronousEngine.Timeout, 0);
    uimaAsEngine.initialize(appCtx);
  }
  public void run() throws Exception {
    for (int i = 0; i < 150; i++) {
      CAS cas = uimaAsEngine.getCAS();
      JCas jcas;
      try {
        System.out.println("UIMA AS Client Sending CAS#" + (i + 1) + "
Request to a Service");
        jcas = cas.getJCas();
        jcas.setDocumentText("Some Text");
      } catch (CASException e) {
        throw new ResourceProcessException(e);
      }
      uimaAsEngine.sendCAS(cas);
    }
    // done
    uimaAsEngine.stop();

  }
  public static void main(String[] args ) {
    TestUimaASClient client = new TestUimaASClient();
    try {
      client.initialize();
      client.run();
    } catch( Exception e) {
      e.printStackTrace();
    }
  }

}

The above runs to completion no matter how many CASes are sent.

Pierre, can you test the above client with your service? Just change the
ServerUri and Endpoint settings in the initialize() method.

JC

On Wed, Mar 31, 2010 at 10:53 AM, Eddie Epstein <eaepstein@gmail.com> wrote:

> This sounds correct when using sendAndReceiveCAS, but not when
> using sendCAS.
>
> With the asynchronous sendCAS interface the application gets the CAS
> back within the callback listener registered via addStatusCallbackListener.
> And the CAS is *not* supposed to be released in the user's
> entityProcessComplete method in the listener class.
>
> Perhaps there is a bug if no listener class is registered?
>
> Eddie
>
> On Wed, Mar 31, 2010 at 9:52 AM, Jaroslaw Cwiklik <uimaee@gmail.com>
> wrote:
> > You are not calling cas.release() when you are done with the CAS.
> > Per UIMA AS documentation ("4.2 The UimaAsynchronousEngine Interface -
> CAS
> > getCAS()"
> >
> > "...CAS getCAS(): Requests a new CAS instance from the CAS pool. This
> method
> > blocks until a free instance of CAS is available in the CAS pool.
> > Applications that
> > use getCAS() need to call CAS.reset() before reusing the CAS, or
> > CAS.release()
> > to return it to the Cas pool."
> >
> > The release() places a CAS back into the pool so the subsequent call to
> > getCAS()
> > succeeds. An alternate strategy is to have a single CAS instance in the
> CAS
> > pool
> > call getCAS() to get that instance and enter a while loop. When done
> > processing
> > reply, call cas.reset() and do *not* call getCAS() again.
> >
> > JC
> >
> > On Tue, Mar 30, 2010 at 5:41 AM, pierre yahoo <ppujalon@yahoo.fr> wrote:
> >
> >> I'm trying to use UIMA-AS to scale a part of the process of our
> >> application.
> >> I have successfully deployed our process as asynchronous services but I
> >> have tremendous issues with the client.
> >>
> >> I'm basically looping synchronously(one at a time) on the following
> code.
> >>     CAS cas = uimaEEEngine.getCAS();
> >>     JCas jcas;
> >>     try {
> >>        jcas = cas.getJCas();
> >>     } catch (CASException e) {
> >>         throw new ResourceProcessException(e);
> >>     }
> >>     fillCas(jcas);
> >>     uimaEEEngine.sendCAS(cas);
> >>
> >> When I run the application, the client works fine for a while and
> suddenly
> >> gets stuck waiting on cas.getJCas()..
> >> I have checked that the asynchronous service have processed all the
> >> previous  CAS.  The service is still up and running as I can send
> requests
> >> from an another client.
> >> When I tracked down who locks the process, I can see that the semaphore
> on
> >> CasQueueEntry is not released.
> >> When I looked further, I noticed that the all process is basically lock
> >> when the CasManager_Impl is calling CasPool.getCas(0) . The CasPool is
> then
> >> waiting with no timeout for someone to notify it.
> >>
> >> I try to change the size of the client CasPool but it didn't really fix
> the
> >> issue. Just pushing further the lock...
> >>
> >> Does anyone have ever experienced this? Am I doing something wrong ?
> >>
> >> Pierre
> >>
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message