You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Josep María Formentí Serra <jm...@aia.es> on 2017/06/09 10:09:00 UTC

How use JCasPool when is exhausted

Hi all,

  I have doubts how to control when the pool, JCasPool, is exhausted.

  I'm trying something like this:

            JCasPool casPool = new JCasPool(100,
segmenter.getAnalysisEngineMetaData());

            ....

            if (cas == null) {
                synchronized (casPool) {
                    {
                        casPool.wait();
                        cas = casPool.getJCas();
                    }
                    while (cas == null);
                }
            }

 For release just: casPool.releaseJCas(cas);

 This is not working for me, because when there are a lot of requests the
application finally is blocked: the pool is full and never is released a
CAS.

Thanks,
  JM

Re: How use JCasPool when is exhausted

Posted by Josep María Formentí Serra <jm...@aia.es>.
Oooops, you're right this was the problem, the "do" is missing

Thanks a lot!

2017-06-09 17:17 GMT+02:00 Marshall Schor <ms...@schor.com>:

> Hi,
>
> I'm having some trouble understanding your code snippet.
>
> Perhaps you intended to have a "do { .... } while (cas == null), but it
> appears
> the "do" is missing?
>
> -Marshall
>
>
> On 6/9/2017 6:09 AM, Josep María Formentí Serra wrote:
> > Hi all,
> >
> >   I have doubts how to control when the pool, JCasPool, is exhausted.
> >
> >   I'm trying something like this:
> >
> >             JCasPool casPool = new JCasPool(100,
> > segmenter.getAnalysisEngineMetaData());
> >
> >             ....
> >
> >             if (cas == null) {
> >                 synchronized (casPool) {
> >                     {
> >                         casPool.wait();
> >                         cas = casPool.getJCas();
> >                     }
> >                     while (cas == null);
> >                 }
> >             }
> >
> >  For release just: casPool.releaseJCas(cas);
> >
> >  This is not working for me, because when there are a lot of requests the
> > application finally is blocked: the pool is full and never is released a
> > CAS.
> >
> > Thanks,
> >   JM
> >
>
>


-- 
------------------------------------------------------------------- --- --
- - -
*Grupo AIA* - *www.aia.es <http://www.aia.es> *
Josep Mª Formentí Serra       <jm...@aia.ptv.es>
*jmformenti@aia.es <jm...@aia.ptv.es>*Dpto. Servicios Financieros y
Seguros
ESADECREAPOLIS, Sant Cugat, Barcelona
Telf.: +34 93 504 49 00 Fax.: +34 93 580 21 88
------------------------------------------------------------------- --- --
- - -
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.

Re: How use JCasPool when is exhausted

Posted by Marshall Schor <ms...@schor.com>.
Hi,

I'm having some trouble understanding your code snippet.

Perhaps you intended to have a "do { .... } while (cas == null), but it appears
the "do" is missing?

-Marshall


On 6/9/2017 6:09 AM, Josep María Formentí Serra wrote:
> Hi all,
>
>   I have doubts how to control when the pool, JCasPool, is exhausted.
>
>   I'm trying something like this:
>
>             JCasPool casPool = new JCasPool(100,
> segmenter.getAnalysisEngineMetaData());
>
>             ....
>
>             if (cas == null) {
>                 synchronized (casPool) {
>                     {
>                         casPool.wait();
>                         cas = casPool.getJCas();
>                     }
>                     while (cas == null);
>                 }
>             }
>
>  For release just: casPool.releaseJCas(cas);
>
>  This is not working for me, because when there are a lot of requests the
> application finally is blocked: the pool is full and never is released a
> CAS.
>
> Thanks,
>   JM
>


Re: How use JCasPool when is exhausted

Posted by Marshall Schor <ms...@schor.com>.
Since you say that CASes are never being released, perhaps you need to trace the
code where you think an acquired cas ought to be being released, and see why
that code path doesn't call the releaseJCas(cas) method?

Also, were there any log / error messages generated?

-Marshall

On 6/9/2017 6:09 AM, Josep María Formentí Serra wrote:
> Hi all,
>
>   I have doubts how to control when the pool, JCasPool, is exhausted.
>
>   I'm trying something like this:
>
>             JCasPool casPool = new JCasPool(100,
> segmenter.getAnalysisEngineMetaData());
>
>             ....
>
>             if (cas == null) {
>                 synchronized (casPool) {
>                     {
>                         casPool.wait();
>                         cas = casPool.getJCas();
>                     }
>                     while (cas == null);
>                 }
>             }
>
>  For release just: casPool.releaseJCas(cas);
>
>  This is not working for me, because when there are a lot of requests the
> application finally is blocked: the pool is full and never is released a
> CAS.
>
> Thanks,
>   JM
>