Jörn Kottmann wrote:
One more thing, is it possible that my two AAE instances share
the same Cas Manager instance ?
I spent a little more time in the code and I think the following test
represents whats happening in UIMA AS.

     // with 2 simultaneous AEs
     segmenterDesc = UIMAFramework.getXMLParser()
             .parseAnalysisEngineDescription(
                     new XMLInputSource(JUnitExtension
.getFile("TextAnalysisEngineImplTest/NewlineSegmenter.xml"))); ResourceManager rsrcMgr = UIMAFramework.newDefaultResourceManager(); Map<String, Object> params = new HashMap<String, Object>();
     params.put(AnalysisEngine.PARAM_NUM_SIMULTANEOUS_REQUESTS, 2);
AnalysisEngine ae1 = UIMAFramework.produceAnalysisEngine(segmenterDesc, rsrcMgr, params); AnalysisEngine ae2 = UIMAFramework.produceAnalysisEngine(segmenterDesc, rsrcMgr, params); // start with testing first ae
     CAS cas1 = ae1.newCAS();
     cas1.setDocumentText("Line one\nLine two\nLine three");
     CasIterator iter1 = ae1.processAndOutputNewCASes(cas1);
     assertTrue(iter1.hasNext());
     CAS outCas1 = iter1.next();
     assertEquals("Line one", outCas1.getDocumentText());
// now test second ae
     CAS cas2 = ae2.newCAS();
     cas2.setDocumentText("Line one\nLine two\nLine three");
     CasIterator iter2 = ae2.processAndOutputNewCASes(cas2);
     assertTrue(iter2.hasNext());
     CAS outCas2 = iter2.next();
     assertEquals("Line one", outCas2.getDocumentText());
     outCas2.release();
     assertTrue(iter2.hasNext());
     outCas2 = iter2.next();
     assertEquals("Line two", outCas2.getDocumentText());
     outCas2.release();
     assertTrue(iter2.hasNext());
     outCas2 = iter2.next();
     assertEquals("Line three", outCas2.getDocumentText());
     outCas2.release();
     assertFalse(iter2.hasNext());
// continue testing first ae
     outCas1.release();
     assertTrue(iter1.hasNext());
     outCas1 = iter1.next();
     assertEquals("Line two", outCas1.getDocumentText());
     outCas1.release();
     assertTrue(iter1.hasNext());
     outCas1 = iter1.next();
     assertEquals("Line three", outCas1.getDocumentText());
     outCas1.release();
     assertFalse(iter1.hasNext());

In this sample the resource manager is shared between the two instances,
thats the reason the code later runs in the exception when it tries to define
a cas pool with the same name a second time.

I am note sure if our API allows sharing a resource manager.

If each AE has its own resource manager the test runs through.

Jörn

Reply via email to