Hi Mike,

We are using infinispan cache grid, and we are storing  the XDMNode in infinispan cache.

Everything worked fine in non-cluster environment, when we moved to cluster environment, any change to XDMNode in one server(node), the same will get propogated to another server in the cluster,

During this process, the XDMnode propogation failed, since XDMNode is not serialized.

To get better performance, we are caching the XDMNode, is this approach correct ?

 

Regards

Mohan

 

From: Michael Kay [mailto:mike@saxonica.com]
Sent: Friday, December 20, 2013 11:06 PM
To: Mailing list for the SAXON XSLT and XQuery processor
Cc: Mohanbabu Lakkaraji
Subject: Re: [saxon] Regarding XQuery

 

I'm afraid you lost me at the point where you tried to explain what was actually going wrong:

 

Everything was working fine for single node, once we move to multiple Node, it’s failing as XDMNode is not getting propogated to second mode as it’s not serialized.

 

 

I need to know exactly what you are doing and exactly how it fails. When you say you "move to multiple Node", what exactly did you change? Have you shown me the code that works, or the code that fails? (the code that fails is more interesting...).  If the code fails, what are the symptoms of the failure?

 

Michael Kay

Saxonica

 

 

On 19 Dec 2013, at 18:15, Mohanbabu Lakkaraji <Mohanbabu.Lakkaraji@tecnotree.com> wrote:



Hi,

 

We are using saxon9.4HE

Our entire application is dependent on XQuery, we have all our data in a single big XML file,

We create XDmNode once and cache XDMNode and Processor( that was used to create XDmNode). When there is any addition/update of XML data, we re-create the XDMNode and update the cache.

For every query request, we get the XDMNode and Processor from cache and execute XQuery.

 

The reason why we are caching XDMNode is that, we are getting good performance if we re-use the XDMNode from cache instead of creating XDMNode from the Big XML file for every query request.

 

Following is the example code

 

Code to create XDMNode

private  XdmNode getNode(String xmlPayLoad)

{

                //create processor

                    Processor proc = new Processor(false);

                    //create buffered reader for the xml payload

                    BufferedReader reader = new BufferedReader(new StringReader(xmlPayLoad));

     //create stream source

     StreamSource streamSource = new StreamSource(reader);

     //create document builder

        DocumentBuilder docBuilder = proc.newDocumentBuilder();

        //create node

        XdmNode node = null;

                                try {

                                                node = docBuilder.build(streamSource);

                                } catch (SaxonApiException e) {

                                                e.printStackTrace();

                                }

         return node;

}

 

 

The XDMNode and processor is cached

 

And Following is the code to execute XQuery

 

 

                private String executeXQuery(XdmNode node,String Processor proc,String xQueryString)

                {

                                StringBuilder resultBuff = new StringBuilder();

 

        XQueryCompiler comp = proc.newXQueryCompiler();

       

        //compile the query

        XQueryExecutable exprExec;

                                try {

                                                exprExec = comp.compile(xQueryString);

                                } catch (SaxonApiException e) {

                                                e.printStackTrace();

                                                return resultBuff.toString();

                                }

        XQueryEvaluator queryEvaluator = exprExec.load();

        queryEvaluator.setExternalVariable(new QName("params"), node);

        //evaluate the query

        XdmValue result;

                                try {

                                                result = queryEvaluator.evaluate();

                                                int len = result.size();

                                                for(int i=0;i<len;i++)

                                                {

                                                                resultBuff.append(result.itemAt(i));

                                                }

 

                                } catch (SaxonApiException e) {

                                                e.printStackTrace();

                                }

                               

                                return resultBuff.toString();

 

                }

 

Following is the XQuery

declare variable $params external;  for $param in $params/offerings/offering    return $param/segments/segment

 

Following is the sample XML file

 

<offerings><offering><id>1</id><allowances><allowance><id>33</id><productName>AllowanceName</productName></allowance></allowances><segments><segment><id>11</id><name>segmentName</name></segment></segments></offering></offerings>

 

 

Everything was working fine for single node, once we move to multiple Node, it’s failing as XDMNode is not getting propogated to second mode as it’s not serialized.

 

Could you please let us know if we are doing the right way, if not, could you please suggest alternative method

 

Regards

Mohan

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help