Hi,

Try adding a .json to the end of the url.
That should cause the json renderer to show you the properties.

If you have any hierarchical content in Cassandra you can also test
that by specifying the number of levels to show.
Add .2.json

That will cause the listChildren methods to be called.
There is more information on the Sling tutorial [1]. Try following the
tutorial again to remind yourself how JCR behaves.

Your ResourceProvider should get a row from Cassandra on request, it
should not get all the rows from Cassandra, so you should never have
all 1M records in memory.

Ian


1 
http://sling.apache.org/documentation/getting-started/discover-sling-in-15-minutes.html


On 20 August 2013 04:22, Dishara Wijewardana <[email protected]> wrote:
> Hi Ian,
> Thank you very much for the explanation.
> I did the changes and commited it. If you see on CassandraResource and
> CassandraResourceProvider,  you will see I have done similar to Planet
> Resource.  And when I do a http://localhost:8080/cassandra/pnode1/cnode1/ I
> am not seeing any errors in BE and either nothing get seen on the browser.
>  It's a  blank page with no errors.
>
> So apparently it seems work. And when I evaluated followings they worked
> fine :-). I currently only added "path" property only for the map.
>
>   ValueMap vm =
> resourceResolver.get("/content/cassandra/testitem").adapTo(ValueMap.class);
>     Assert.assertNotNull(vm.get("path"));
>     Assert.assertTrue(((String)vm.get("path")).length()>0);
>
>
> So how should we test 1M record test on top of this  (because I am getting
> a blank response on the browser) ?. Even in that case I think I have to
> populate the Map with 1M records for instance. (Correct me if I am wrong).
> But if it is the case, this will consume quite a lot of memory to keep a 1M
> size hash map.
> Please advice how to proceed.
>
> Thanks
>
>
> On Mon, Aug 19, 2013 at 1:40 PM, Ian Boston <[email protected]> wrote:
>
>> Hi,
>> Initially, just to verify that you can get the
>> CassandraResourceProvider to work, just take the code from the
>> PlanetProvider and send back a Map with 1 value (eg path).
>>
>> Once you have that working and can perform a get on the resource, then
>> you need to populate that map with the values associated with the
>> columns in the Cassandra row that represents the Cassandra resource.
>> To give the data in Cassandra some reality you can get you data
>> population code to add the following columns to every cassandra row.
>>
>> path : the path of the resource
>> created : a long representing the time (System.currentTimeMillis())
>> when the resource was created.
>>
>> when you have done that the following test code should be pass.
>>
>>     ValueMap vm =
>> resourceResolver.get("/content/cassandra/testitem").adapTo(ValueMap.class);
>>     Assert.assertNotNull(vm.get("path"));
>>     Assert.assertTrue(((String)vm.get("path")).length()>0);
>>     Assert.assertNotNull(vm.get("created"));
>>     Assert.assertTrue(((Long)vm.get("path")) < System.currentTimeMillis());
>>
>> Best Regards
>> Ian
>>
>>
>> On 18 August 2013 22:35, Dishara Wijewardana <[email protected]>
>> wrote:
>> > Hi Ian ,
>> > Thanks for the clarification.
>> >
>> > Each PlanetResource value map has two predefined properties (keys) in its
>> > Map. "name" and "distance".  I looked in to the code of
>> > PlanetResource/Provider end to end.
>> > I am trying the understand the rationale behind this so that I can
>> > incooperate this to CassandraResource.
>> >
>> > - To obtain a PlanetResource, the implementation always returns a
>> > PlanetResource on the availability of the Map it maintains "PLANETS".
>> (can
>> > see in getResource/listResource)
>> > - The content of the planet map ONLY has a Pre-Defined number of
>> > key/values. (some planet names and its distances). Because PLANETS map
>> only
>> > populated from the static code block from the provider.
>> > - After server starts the ONLY keys "PLANETS" map have is i.e
>> >  /planets/mercury/
>> > /planets/earth/ and etc. Also for some test there is also
>> > /planets/earth/moon.  And its corresponding PlanetValueMap.
>> >
>> >
>> > - As per current code in planet resource;  if I do a
>> > PlanetResouceProvide#getResource(/planets/myplanet/moon1) this returns
>> > NULL. It returns something only when we pass those pre defined paths. i.e
>> >   /planets/mercury/.
>> >
>> > In CassandraResourceProvider I do not refer any map, but rather directly
>> > deals with the Cassandra DB, after decoding the path to column family
>> key.
>> > Is this PlanetResource provider behavior correct ? If so how my Cassandra
>> > Provider/Resource should map to this? Should I define pre defined column
>> > families like this.
>> >
>> > Thanks
>> >
>> >
>> >
>> >
>> > On Sun, Aug 18, 2013 at 1:43 PM, Ian Boston <[email protected]> wrote:
>> >
>> >> Hi,
>> >> The annotations in PlanetResource add OSGi properties and code that
>> >> registers the class as adatable from a PlanetResource to a ValueMap.
>> >> You need to do the same for CassandraResource. The contents of the
>> >> ValueMap (backed by a Map), should be selected properties of the
>> >> Cassandra row. (ie the names and values of the columns).
>> >>
>> >> Ian
>> >>
>> >> On 17 August 2013 06:16, Dishara Wijewardana <[email protected]>
>> >> wrote:
>> >> > Hi all,
>> >> > Seems the error I have posted is wrong. The above error is correct,
>> >> because
>> >> > I am trying to acquire a non existing resource. (I saw in the doc, the
>> >> way
>> >> > jcr resources get resolved, there it defines a resourcePathInfo as
>> >> > .html/.json where if you add a node as "/foo/bar") you can view the
>> >> content
>> >> > of it through /foo/bar.html or /foo/bar.json.
>> >> >
>> >> > In my case If I do the same, the resource that I have stored is
>> >> > "/content/cassandra/1K/0" , but above NPE comes when I tried *
>> >> > http://localhost:8080/content/cassandra/1K/0.html*. (NOTE: I have
>> also
>> >> set
>> >> > resourcePathInfo =.html in resource meta data). I am getting following
>> >> when
>> >> > I do the correct sample path *
>> >> http://localhost:8080/content/cassandra/1K/0.
>> >> >   *The unsupported exception is thrown by me on resource.adaptTo
>>  since I
>> >> > did not see any requirement of implementing that. Is it required to
>> >> > implement adaptTo method ? What does it suppose to do ? ( I believe
>> now
>> >> up
>> >> > to this error point, my request has come in the correct path
>> >> > , and this is something I should fix)
>> >> >
>> >> > I checked on PlanetResource impl class. There I found following which
>> I
>> >> do
>> >> > not have in my CassandraResource class. What these annotations means ?
>> >> > @Adaptable(adaptableClass=Resource.class, adapters={
>> >> >     @Adapter({ValueMap.class})
>> >> > })  * *
>> >> >
>> >> > Internal Server Error (500)
>> >> >
>> >> > The requested URL /content/cassandra/num4K/0 resulted in an error in
>> >> > org.apache.sling.servlets.get.DefaultGetServlet.
>> >> > Exception:
>> >> >
>> >> > java.lang.UnsupportedOperationException
>> >> >         at
>> >>
>> org.apache.sling.cassandra.resource.provider.CassandraResource.adaptTo(CassandraResource.java:186)
>> >> >         at
>> >>
>> org.apache.sling.servlets.get.impl.helpers.HtmlRendererServlet.doGet(HtmlRendererServlet.java:63)
>> >> >         at
>> >>
>> org.apache.sling.api.servlets.SlingSafeMethodsServlet.mayService(SlingSafeMethodsServlet.java:268)
>> >> >         at
>> >>
>> org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:344)
>> >> >         at
>> >>
>> org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:375)
>> >> >         at
>> >>
>> org.apache.sling.servlets.get.impl.DefaultGetServlet.doGet(DefaultGetServlet.java:252)
>> >> >         at
>> >>
>> org.apache.sling.api.servlets.SlingSafeMethodsServlet.mayService(SlingSafeMethodsServlet.java:268)
>> >> >         at
>> >>
>> org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:344)
>> >> >         at
>> >>
>> org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:375)
>> >> >         at
>> >>
>> org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:508)
>> >> >         at
>> >>
>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:261)
>> >> >         at
>> >>
>> org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
>> >> >         at
>> >>
>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
>> >> >         at
>> >>
>> org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:64)
>> >> >         at
>> >>
>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
>> >> >         at
>> >>
>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:151)
>> >> >         at
>> >>
>> org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:207)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>> >> >         at
>> >>
>> org.apache.sling.engine.impl.log.RequestLoggerFilter.doFilter(RequestLoggerFilter.java:75)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.handler.FilterHandler.doHandle(FilterHandler.java:88)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:76)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:47)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
>> >> >         at
>> >>
>> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
>> >> >         at
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>> >> >         at
>> >> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>> >> >         at
>> >> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>> >> >         at
>> >> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>> >> >         at
>> >> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>> >> >         at
>> >> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>> >> >         at org.mortbay.jetty.Server.handle(Server.java:326)
>> >> >         at
>> >> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>> >> >         at
>> >>
>> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926)
>> >> >         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
>> >> >         at
>> >> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>> >> >         at
>> >> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>> >> >         at
>> >>
>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
>> >> >         at
>> >>
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
>> >> >
>> >> > Request Progress:
>> >> >
>> >> >       0 (2013-08-17 10:25:10) TIMER_START{Request Processing}
>> >> >       0 (2013-08-17 10:25:10) COMMENT timer_end format is {<elapsed
>> >> > msec>,<timer name>} <optional message>
>> >> >       0 (2013-08-17 10:25:10) LOG Method=GET,
>> >> > PathInfo=/content/cassandra/num4K/0
>> >> >       0 (2013-08-17 10:25:10) TIMER_START{ResourceResolution}
>> >> >      11 (2013-08-17 10:25:10) TIMER_END{11,ResourceResolution}
>> >> > URI=/content/cassandra/num4K/0 resolves to
>> >> >
>> >>
>> Resource=org.apache.sling.cassandra.resource.provider.CassandraResource@52ecb5eb
>> >> >      17 (2013-08-17 10:25:10) LOG Resource Path Info:
>> >> > SlingRequestPathInfo: path='/content/cassandra/num4K/0',
>> >> > selectorString='null', extension='html', suffix='null'
>> >> >      17 (2013-08-17 10:25:10) TIMER_START{ServletResolution}
>> >> >      17 (2013-08-17 10:25:10)
>> >> >
>> >>
>> TIMER_START{resolveServlet(org.apache.sling.cassandra.resource.provider.CassandraResource@52ecb5eb
>> >> )}
>> >> >      26 (2013-08-17 10:25:10)
>> >> >
>> >>
>> TIMER_END{9,resolveServlet(org.apache.sling.cassandra.resource.provider.CassandraResource@52ecb5eb
>> >> )}
>> >> > Using servlet org.apache.sling.servlets.get.DefaultGetServlet
>> >> >      26 (2013-08-17 10:25:10) TIMER_END{9,ServletResolution}
>> >> > URI=/content/cassandra/num4K/0 handled by
>> >> > Servlet=org.apache.sling.servlets.get.DefaultGetServlet
>> >> >      26 (2013-08-17 10:25:10) LOG Applying Requestfilters
>> >> >      26 (2013-08-17 10:25:10) LOG Calling filter:
>> >> > org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
>> >> >      26 (2013-08-17 10:25:10)
>> >> > TIMER_START{org.apache.sling.servlets.get.DefaultGetServlet#0}
>> >> >      29 (2013-08-17 10:25:10) LOG Using
>> >> > org.apache.sling.servlets.get.impl.helpers.HtmlRendererServlet to
>> >> > render for extension=html
>> >> >      32 (2013-08-17 10:25:10)
>> >> > TIMER_END{6,org.apache.sling.servlets.get.DefaultGetServlet#0}
>> >> >      33 (2013-08-17 10:25:10)
>> >> >
>> >>
>> TIMER_START{handleError:throwable=java.lang.UnsupportedOperationException}
>> >> >      72 (2013-08-17 10:25:10)
>> >> >
>> >>
>> TIMER_END{39,handleError:throwable=java.lang.UnsupportedOperationException}
>> >> > Using handler
>> >>
>> org.apache.sling.servlets.resolver.internal.defaults.DefaultErrorHandlerServlet
>> >> >      73 (2013-08-17 10:25:10) TIMER_END{73,Request Processing} Dumping
>> >> > SlingRequestProgressTracker Entries
>> >> >
>> >> >
>> >> >
>> >> > On Fri, Aug 16, 2013 at 11:58 AM, Bertrand Delacretaz <
>> >> > [email protected]> wrote:
>> >> >
>> >> >> On Fri, Aug 16, 2013 at 4:12 AM, Dishara Wijewardana
>> >> >> <[email protected]> wrote:
>> >> >> > ...java.lang.NullPointerException
>> >> >> >         at
>> >> >>
>> >>
>> org.apache.sling.servlets.resolver.internal.SlingServletResolver.resolveServlet(SlingServletResolver.java:581)...
>> >> >>
>> >> >> duplicated question...I replied in the other thread.
>> >> >> -Bertrand
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Thanks
>> >> > /Dishara
>> >>
>> >
>> >
>> >
>> > --
>> > Thanks
>> > /Dishara
>>
>
>
>
> --
> Thanks
> /Dishara

Reply via email to