3 Replies Latest reply: Feb 1, 2011 12:24 PM by Galder Zamarreño RSS

Clarifications on the REST interface

thanhp Newbie

Hi all,

 

I'm looking at the Client Server Infinispan and have a few questions on the content of

http://community.jboss.org/wiki/AccessingdatainInfinispanviaRESTfulinterface

 

Please let me know if there's already answers for that elsewhere.

 

In the PUT section

 

- "if the cache name is new, it will be automatically initialised" I believe this isn't the case anymore, you have to configure it explicitly?

 

- "For examplehttp://someserver/hr/payRoll/3 (in which case "hr" is the cache name, and "payRoll/3" is the key). " Would such a key work or would the "/" character cause the put to fail?

 

In the Getting Data back out

 

- "If the data in the grid is a Java object - there are a few options in how it can be returned, which use the HTTP Accept header:

  1. application/xml - the object will be serialized via XStream to XML representation
  2. application/json - the object will be sent via a JSON format (via Jackson)"

 

 

Is this still valid in 4.2 given that objects do not seem deserialized anymore?

 

 

Also,

- Is there a standard page to access the stats, like for the ehcache rest server

 

 

Thank you

  • 1. Clarifications on the REST interface
    Manik Surtani Master

    - "if the cache name is new, it will be automatically initialised" I believe this isn't the case anymore, you have to configure it explicitly?

    Thanks for pointing this out, this has now been corrected.

     

    - "For examplehttp://someserver/hr/payRoll/3 (in which case "hr" is the cache name, and "payRoll/3" is the key). " Would such a key work or would the "/" character cause the put to fail?

    It should work.

     

     

    - "If the data in the grid is a Java object - there are a few options in how it can be returned, which use the HTTP Accept header:

    1. application/xml - the object will be serialized via XStream to XML representation
    2. application/json - the object will be sent via a JSON format (via Jackson)"

     

     

    Is this still valid in 4.2 given that objects do not seem deserialized anymore?

     

    Corrected.  This is only valid if the object is stored as XML or JSON in the first place.

     

    Regarding stats, these are accessed via JMX, or if you install a RHQ/JOPR webapp on the web container, via this interface.  See the docs on managing Infinispan for details.

  • 2. Clarifications on the REST interface
    thanhp Newbie

    Hi Manik,

     

    Thank you for the answers. It all fits, except the http://someserver/hr/payRoll/3 part.

     

    I'm running on 4.2 final / Tomcat 6.0.29, and trying to hit something similar:

    curl -X PUT -d "hello" http://localhost:8080/infinispan/rest/Local/1/2

     

    On the server side, I see the following stack:

     

    15:53:00,244 DEBUG [SynchronousDispatcher] Failed executing PUT /rest/Local/1/2

    org.jboss.resteasy.spi.NotFoundException: Could not find resource for relative : /rest/Local/1/2 of full path: http://localhost:8080/infinispan/rest/Local/1/2

        at org.jboss.resteasy.core.registry.PathParamSegment.matchPattern(PathParamSegment.java:200)

        at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:339)

        at org.jboss.resteasy.core.registry.SimpleSegment.matchSimple(SimpleSegment.java:44)

        at org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:327)

        at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:372)

        at org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:365)

        at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:251)

        at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:155)

        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:116)

        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:198)

        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:48)

        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:43)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

     

    Did I miss something (that nagging feeling)?

     

     

    Thanks again

  • 3. Clarifications on the REST interface
    Galder Zamarreño Master

    Contrary to what Manik said, Resteasy thinks the trailing '/' characters refer to a new web app, so don't think we can do much here. Avoid using '/' character in the key names.