Re: How to have client, service and broker co-located using UIMA-AS
Hi Jaroslaw, thank you for the detailed answer on the state of UIMA-AS and its future evolution. My initial quest for co-located components passing CASes by reference was motivated by some experiments with UIMA-AS suggesting that I was not able to outperform a pipeline executed with uimaFIT. Fortunately, I've just discovered that my deployment descriptor contained a wrong configuration seemingly preventing parallelism. After correcting that error, I was able to outperform uimaFIT. In the end, the presence of the queue broker and the associated serialization/deserialization costs did not prevent me to take advantage of UIMA-AS. Regards, Manuel 2017-10-05 19:55 GMT+02:00 Jaroslaw Cwiklik: > Manuel, the current uima-as code requires a broker between a client and a > service even if all are colocated in the same process. This implies CAS > serialization/deserialization between endpoints. I am refactoring uima-as > code as part of JIRA https://issues.apache.org/jira/browse/UIMA-5280. > Once > the changes are complete the client and a service will use java queue > messaging, passing CASes by reference. Don't have ETA yet. This has been an > ongoing effort. Most of the new code is in place to support the JIRA plus a > few other enhancements. Testing and debugging will take some time. > Jerry > > On Thu, Oct 5, 2017 at 11:30 AM, Manuel Fiorelli < > manuel.fiore...@gmail.com> > wrote: > > > Hi Jaroslaw, > > > > I applied your suggestions to my program, and indeed it seems to work > > without the need of an external broker. > > > > However, it seems to me that timings are more or less the same with the > > co-located and the remote (still on the same machine) broker. > > > > In both cases client and services are launched by the same process. > > > > So my question is: "Is my program passing the CASes by reference?" > > Additionally, "Is this optimization enabled whenever client and service > are > > co-located irrespective of the position of the broker?" > > > > Regards, > > Manuel > > > > 2017-10-04 22:23 GMT+02:00 Manuel Fiorelli : > > > > > Hi Jaroslaw > > > > > > Thank you for your answer. Tomorrow, I will apply your suggestions and > > > tell you what happens. > > > > > > Il 4 ott 2017 19:50, "Jaroslaw Cwiklik" ha > scritto: > > > > > >> Manuel, small correction. Towards the end replace this > > >> > > >> client.sendCAS(cas); > > >> > > >> with > > >> > > >> client.sendAndReceiveCAS(cas); > > >> > > >> Simpler, synchronous msg exchange between client and a service. > > >> > > >> Jerry Cwiklik > > >> > > >> On Wed, Oct 4, 2017 at 1:00 PM, Jaroslaw Cwiklik > > >> wrote: > > >> > > >> > Hi Manuel, you *can* colocate broker, client and a service in the > same > > >> > process. Here is the code to get this done. Sorry did not test this. > > You > > >> > need to create a deployment descriptor (xml file) to be able to > > deploy a > > >> > service. > > >> > > > >> > // Deploy in-process broker > > >> > String uri = "tcp://"localhost:61616"; > > >> > BrokerService broker = > > >> > BrokerFactory.createBroker(new URI("broker:()/localhost? > > >> > persistent=false")); > > >> > TransportConnector tcpConnector = broker.addConnector(uri); > > >> > broker.start(); > > >> > //-- > > >> > > > >> > UimaAsynchronousEngine client = > > >> > new BaseUIMAAsynchronousEngine_impl(); > > >> > > > >> > Map appCtx = new HashMap(); > > >> > appCtx.put(UimaAsynchronousEngine.DD2SpringXsltFilePath, > > >> >$UIMA_HOME+"/bin/dd2spring.xsl"); > > >> > appCtx.put(UimaAsynchronousEngine.SaxonClasspath, > > >> >"file:"+$UIMA_HOME+"/saxon/saxon8.jar"); > > >> > > > >> > String aDeploymentDescriptorPath = > > >> > > > >> > > > >> > // deploy in-process service > > >> > String serviceId = > > >> > client.deploy(aDeploymentDescriptorPath, appCtx); > > >> > > > >> > String endpoint = ; // from the deployment descriptor > > >> > > > >> > appCtx.put(UimaAsynchronousEngine.ServerUri, uri); > > >> > appCtx.put(UimaAsynchronousEngine.ENDPOINT, endpoint); > > >> > > > >> > // connect client with an in-process service > > >> > client.initialize(appCtx); > > >> > > > >> > CAS cas = client.getCAS(); > > >> > cas.setDocumentText("Some Text"); > > >> > client.sendCAS(cas); > > >> > > > >> > client.stop(); > > >> > > > >> > > > >> > > > >> > On Wed, Oct 4, 2017 at 11:37 AM, Manuel Fiorelli < > > >> > manuel.fiore...@gmail.com> wrote: > > >> > > > >> >> Hi everybody > > >> >> > > >> >> Within the documentation of UIMA-AS, specifically within the > section > > >> >> Terminology ( > > >> >> https://uima.apache.org/d/uima-as-2.9.0/uima_async_scaleout. > > >> >> html#ugr.async.ov.terminology), > > >> >> the description of Queue Broker says: > > >> >> > > >> >> > > >> >> Queue brokers manage one or more named queues. The brokers are > > >> identified > > >> >> using a URL, representing where they are on
Re: How to have client, service and broker co-located using UIMA-AS
Manuel, the current uima-as code requires a broker between a client and a service even if all are colocated in the same process. This implies CAS serialization/deserialization between endpoints. I am refactoring uima-as code as part of JIRA https://issues.apache.org/jira/browse/UIMA-5280. Once the changes are complete the client and a service will use java queue messaging, passing CASes by reference. Don't have ETA yet. This has been an ongoing effort. Most of the new code is in place to support the JIRA plus a few other enhancements. Testing and debugging will take some time. Jerry On Thu, Oct 5, 2017 at 11:30 AM, Manuel Fiorelliwrote: > Hi Jaroslaw, > > I applied your suggestions to my program, and indeed it seems to work > without the need of an external broker. > > However, it seems to me that timings are more or less the same with the > co-located and the remote (still on the same machine) broker. > > In both cases client and services are launched by the same process. > > So my question is: "Is my program passing the CASes by reference?" > Additionally, "Is this optimization enabled whenever client and service are > co-located irrespective of the position of the broker?" > > Regards, > Manuel > > 2017-10-04 22:23 GMT+02:00 Manuel Fiorelli : > > > Hi Jaroslaw > > > > Thank you for your answer. Tomorrow, I will apply your suggestions and > > tell you what happens. > > > > Il 4 ott 2017 19:50, "Jaroslaw Cwiklik" ha scritto: > > > >> Manuel, small correction. Towards the end replace this > >> > >> client.sendCAS(cas); > >> > >> with > >> > >> client.sendAndReceiveCAS(cas); > >> > >> Simpler, synchronous msg exchange between client and a service. > >> > >> Jerry Cwiklik > >> > >> On Wed, Oct 4, 2017 at 1:00 PM, Jaroslaw Cwiklik > >> wrote: > >> > >> > Hi Manuel, you *can* colocate broker, client and a service in the same > >> > process. Here is the code to get this done. Sorry did not test this. > You > >> > need to create a deployment descriptor (xml file) to be able to > deploy a > >> > service. > >> > > >> > // Deploy in-process broker > >> > String uri = "tcp://"localhost:61616"; > >> > BrokerService broker = > >> > BrokerFactory.createBroker(new URI("broker:()/localhost? > >> > persistent=false")); > >> > TransportConnector tcpConnector = broker.addConnector(uri); > >> > broker.start(); > >> > //-- > >> > > >> > UimaAsynchronousEngine client = > >> > new BaseUIMAAsynchronousEngine_impl(); > >> > > >> > Map appCtx = new HashMap(); > >> > appCtx.put(UimaAsynchronousEngine.DD2SpringXsltFilePath, > >> >$UIMA_HOME+"/bin/dd2spring.xsl"); > >> > appCtx.put(UimaAsynchronousEngine.SaxonClasspath, > >> >"file:"+$UIMA_HOME+"/saxon/saxon8.jar"); > >> > > >> > String aDeploymentDescriptorPath = > >> > > >> > > >> > // deploy in-process service > >> > String serviceId = > >> > client.deploy(aDeploymentDescriptorPath, appCtx); > >> > > >> > String endpoint = ; // from the deployment descriptor > >> > > >> > appCtx.put(UimaAsynchronousEngine.ServerUri, uri); > >> > appCtx.put(UimaAsynchronousEngine.ENDPOINT, endpoint); > >> > > >> > // connect client with an in-process service > >> > client.initialize(appCtx); > >> > > >> > CAS cas = client.getCAS(); > >> > cas.setDocumentText("Some Text"); > >> > client.sendCAS(cas); > >> > > >> > client.stop(); > >> > > >> > > >> > > >> > On Wed, Oct 4, 2017 at 11:37 AM, Manuel Fiorelli < > >> > manuel.fiore...@gmail.com> wrote: > >> > > >> >> Hi everybody > >> >> > >> >> Within the documentation of UIMA-AS, specifically within the section > >> >> Terminology ( > >> >> https://uima.apache.org/d/uima-as-2.9.0/uima_async_scaleout. > >> >> html#ugr.async.ov.terminology), > >> >> the description of Queue Broker says: > >> >> > >> >> > >> >> Queue brokers manage one or more named queues. The brokers are > >> identified > >> >> using a URL, representing where they are on the network. When the > queue > >> >> broker is co-located with the AS client and service, CASes are passed > >> by > >> >> reference, avoiding serialization / deserialization. > >> >> > >> >> > >> >> Unfortunately, I could not find in the documentation how to place > >> broker, > >> >> client and service in the same JVM (co-location). > >> >> > >> >> After some web searches, experiments and exploration of the source > >> code of > >> >> UIMA-AS, I found that the solution may require the use of the URL > >> >> "vm://localhost?broker.persistent=false" for the broker. > >> >> > >> >> In my sample program, I deploy a service (an asynchronous aggregate > AE) > >> >> and > >> >> then create an asynchronous client using the URL above, but then I > >> receive > >> >> the following NullPointerException: > >> >> > >> >> > >> >> ott 04, 2017 5:29:28 PM > >> >> org.apache.uima.aae.controller.AggregateAnalysisEngineControl > ler_impl > >> >> replyToClient > >> >>