Re: Re-create bookmarkable pages on Ajax calls

2017-01-12 Thread Thomas Heigl
Alternatively, if this does not make any sense or is not possible at all,
would it be an option to approach this from the opposite direction, i.e.
make the pages really stateless, but still store them in the application
level cache so they don't have to be fully re-created for every Ajax call?

On Thu, Jan 12, 2017 at 6:48 PM, Thomas Heigl  wrote:

> Hi Martin,
>
> Yes, I tried that, but what happens is this:
>
> When a user clicks on the an an Ajax link on a page that is not in the
> application cache, the whole page gets refreshed and nothing else happens.
> This is due to the following code in ListenerInterfaceRequestHandler:
>
> if (!canCallListenerInterfaceAfterExpiry && freshPage &&
>> (pageComponentProvider.getPageId() != null || component == null))
>> {
>> // A listener interface is invoked on an expired page.
>> // If the page is stateful then we cannot assume that the listener
>> interface is
>> // invoked on its initial state (right after page initialization) and
>> that its
>> // component and/or behavior will be available. That's why the
>> listener interface
>> // should be ignored and the best we can do is to re-paint the newly
>> constructed
>> // page.
>> if (isAjax)
>> {
>> policy = RedirectPolicy.ALWAYS_REDIRECT;
>> }
>> requestCycle.scheduleRequestHandlerAfterCurrent(new
>> RenderPageRequestHandler(
>> pageProvider, policy));
>> return;
>> }
>
>
> What I would like to do is mark some of my pages as "semi-stateless" (i.e.
> all state can be inferred from the URL), use fixed markup IDs for
> components with Ajax listeners, and let the listener be invoked anyway. I
> know that this is not the way Wicket is meant to be used, but it would
> allow me to massively reduce the memory footprint and simplify session
> distribution. My sessions are only around 1.5kb without the PageMap.
>
> I'd like to give this a try, but Page.isPageStateless() is final and I do
> not see a way to hook into this.
>
> Do you have any suggestions?
>
> Best regards,
>
> Thomas
>
> On Thu, Jan 12, 2017 at 12:43 PM, Martin Grigorov 
> wrote:
>
>> Hi,
>>
>> You can setup a no-op IPageStore.
>> This way there won't be a call to ISerializer#serialize(Object) at all.
>>
>> Martin Grigorov
>> Wicket Training and Consulting
>> https://twitter.com/mtgrigorov
>>
>> On Thu, Jan 12, 2017 at 11:53 AM, Thomas Heigl 
>> wrote:
>>
>> > I forgot to add:
>> >
>> > We are using the HTML5 History API to push state to the (bookmarkable)
>> URL,
>> > so a page can be re-created with *all* state from the URL alone.
>> >
>> > Thomas
>> >
>> > On Thu, Jan 12, 2017 at 11:47 AM, Thomas Heigl 
>> > wrote:
>> >
>> > > Hi all,
>> > >
>> > > I'm looking for a solution to avoid serialization of bookmarkable
>> pages.
>> > >
>> > > These are yesterday's metrics from an instrumented version of
>> > Fast2WicketSerializer:
>> > >
>> > > "WicketSerializer.deserialize" : {
>> > >>   "count" : 4084,
>> > >>   "max" : 0.0308421623,
>> > >>   "mean" : 0.005861568417930906,
>> > >>   "min" : 0.00144874502,
>> > >>   "mean_rate" : 0.01926885221303454,
>> > >>   "duration_units" : "seconds",
>> > >>   "rate_units" : "calls/second"
>> > >> },
>> > >> "WicketSerializer.serialize" : {
>> > >>   "count" : 498884,
>> > >>   "max" : 0.007742393,
>> > >>   "mean" : 0.002135383760700826,
>> > >>   "min" : 8.2115001E-4,
>> > >>   "mean_rate" : 2.3538006959615907,
>> > >>   "duration_units" : "seconds",
>> > >>   "rate_units" : "calls/second"
>> > >> }
>> > >
>> > >
>> > > As you can see, Wicket serialized about 500.000 pages, but only 4000
>> > were ever
>> > > de-serialized. The deserialization is caused by users who use multiple
>> > tabs and
>> > > then trigger an ajax action on one of them.
>> > >
>> > > All my pages are unversioned, bookmarkable and mounted in a way that
>> > strips
>> > > version parameters from the URL.
>> > >
>> > > What I would like to do is completely disable HttpSessionDataStore,
>> rely
>> > only
>> > > on the application level cache that (from looking at the metrics is
>> > sufficient
>> > > in the vast majority of cases) and recreate the bookmarkable page for
>> the
>> > > remaining cases instead of de-serializing a stored version.
>> > >
>> > > I know this is possible with stateless pages, but my application is
>> very
>> > large
>> > > and converting it all to stateless would require a massive effort.
>> > >
>> > > Is there a way to implement this with Wicket 7.6?
>> > >
>> > > I'm aware of the flags "setRecreateBookmarkablePagesAfterExpiry" and
>> "
>> > setCallListenerInterfaceAfterExpiry"
>> > > but I'm not sure they apply to bookmarkable pages and Ajax calls.
>> > >
>> > > Any ideas would be greatly appreciated!
>> > >
>> > >
>> > > Best regards,
>> > >
>> > > Thomas
>> > >
>> > >
>> >
>>
>
>


Re: Re-create bookmarkable pages on Ajax calls

2017-01-12 Thread Thomas Heigl
Hi Martin,

Yes, I tried that, but what happens is this:

When a user clicks on the an an Ajax link on a page that is not in the
application cache, the whole page gets refreshed and nothing else happens.
This is due to the following code in ListenerInterfaceRequestHandler:

if (!canCallListenerInterfaceAfterExpiry && freshPage &&
> (pageComponentProvider.getPageId() != null || component == null))
> {
> // A listener interface is invoked on an expired page.
> // If the page is stateful then we cannot assume that the listener
> interface is
> // invoked on its initial state (right after page initialization) and
> that its
> // component and/or behavior will be available. That's why the
> listener interface
> // should be ignored and the best we can do is to re-paint the newly
> constructed
> // page.
> if (isAjax)
> {
> policy = RedirectPolicy.ALWAYS_REDIRECT;
> }
> requestCycle.scheduleRequestHandlerAfterCurrent(new
> RenderPageRequestHandler(
> pageProvider, policy));
> return;
> }


What I would like to do is mark some of my pages as "semi-stateless" (i.e.
all state can be inferred from the URL), use fixed markup IDs for
components with Ajax listeners, and let the listener be invoked anyway. I
know that this is not the way Wicket is meant to be used, but it would
allow me to massively reduce the memory footprint and simplify session
distribution. My sessions are only around 1.5kb without the PageMap.

I'd like to give this a try, but Page.isPageStateless() is final and I do
not see a way to hook into this.

Do you have any suggestions?

Best regards,

Thomas

On Thu, Jan 12, 2017 at 12:43 PM, Martin Grigorov 
wrote:

> Hi,
>
> You can setup a no-op IPageStore.
> This way there won't be a call to ISerializer#serialize(Object) at all.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Thu, Jan 12, 2017 at 11:53 AM, Thomas Heigl 
> wrote:
>
> > I forgot to add:
> >
> > We are using the HTML5 History API to push state to the (bookmarkable)
> URL,
> > so a page can be re-created with *all* state from the URL alone.
> >
> > Thomas
> >
> > On Thu, Jan 12, 2017 at 11:47 AM, Thomas Heigl 
> > wrote:
> >
> > > Hi all,
> > >
> > > I'm looking for a solution to avoid serialization of bookmarkable
> pages.
> > >
> > > These are yesterday's metrics from an instrumented version of
> > Fast2WicketSerializer:
> > >
> > > "WicketSerializer.deserialize" : {
> > >>   "count" : 4084,
> > >>   "max" : 0.0308421623,
> > >>   "mean" : 0.005861568417930906,
> > >>   "min" : 0.00144874502,
> > >>   "mean_rate" : 0.01926885221303454,
> > >>   "duration_units" : "seconds",
> > >>   "rate_units" : "calls/second"
> > >> },
> > >> "WicketSerializer.serialize" : {
> > >>   "count" : 498884,
> > >>   "max" : 0.007742393,
> > >>   "mean" : 0.002135383760700826,
> > >>   "min" : 8.2115001E-4,
> > >>   "mean_rate" : 2.3538006959615907,
> > >>   "duration_units" : "seconds",
> > >>   "rate_units" : "calls/second"
> > >> }
> > >
> > >
> > > As you can see, Wicket serialized about 500.000 pages, but only 4000
> > were ever
> > > de-serialized. The deserialization is caused by users who use multiple
> > tabs and
> > > then trigger an ajax action on one of them.
> > >
> > > All my pages are unversioned, bookmarkable and mounted in a way that
> > strips
> > > version parameters from the URL.
> > >
> > > What I would like to do is completely disable HttpSessionDataStore,
> rely
> > only
> > > on the application level cache that (from looking at the metrics is
> > sufficient
> > > in the vast majority of cases) and recreate the bookmarkable page for
> the
> > > remaining cases instead of de-serializing a stored version.
> > >
> > > I know this is possible with stateless pages, but my application is
> very
> > large
> > > and converting it all to stateless would require a massive effort.
> > >
> > > Is there a way to implement this with Wicket 7.6?
> > >
> > > I'm aware of the flags "setRecreateBookmarkablePagesAfterExpiry" and "
> > setCallListenerInterfaceAfterExpiry"
> > > but I'm not sure they apply to bookmarkable pages and Ajax calls.
> > >
> > > Any ideas would be greatly appreciated!
> > >
> > >
> > > Best regards,
> > >
> > > Thomas
> > >
> > >
> >
>


Re: Re-create bookmarkable pages on Ajax calls

2017-01-12 Thread Martin Grigorov
Hi,

You can setup a no-op IPageStore.
This way there won't be a call to ISerializer#serialize(Object) at all.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Thu, Jan 12, 2017 at 11:53 AM, Thomas Heigl  wrote:

> I forgot to add:
>
> We are using the HTML5 History API to push state to the (bookmarkable) URL,
> so a page can be re-created with *all* state from the URL alone.
>
> Thomas
>
> On Thu, Jan 12, 2017 at 11:47 AM, Thomas Heigl 
> wrote:
>
> > Hi all,
> >
> > I'm looking for a solution to avoid serialization of bookmarkable pages.
> >
> > These are yesterday's metrics from an instrumented version of
> Fast2WicketSerializer:
> >
> > "WicketSerializer.deserialize" : {
> >>   "count" : 4084,
> >>   "max" : 0.0308421623,
> >>   "mean" : 0.005861568417930906,
> >>   "min" : 0.00144874502,
> >>   "mean_rate" : 0.01926885221303454,
> >>   "duration_units" : "seconds",
> >>   "rate_units" : "calls/second"
> >> },
> >> "WicketSerializer.serialize" : {
> >>   "count" : 498884,
> >>   "max" : 0.007742393,
> >>   "mean" : 0.002135383760700826,
> >>   "min" : 8.2115001E-4,
> >>   "mean_rate" : 2.3538006959615907,
> >>   "duration_units" : "seconds",
> >>   "rate_units" : "calls/second"
> >> }
> >
> >
> > As you can see, Wicket serialized about 500.000 pages, but only 4000
> were ever
> > de-serialized. The deserialization is caused by users who use multiple
> tabs and
> > then trigger an ajax action on one of them.
> >
> > All my pages are unversioned, bookmarkable and mounted in a way that
> strips
> > version parameters from the URL.
> >
> > What I would like to do is completely disable HttpSessionDataStore, rely
> only
> > on the application level cache that (from looking at the metrics is
> sufficient
> > in the vast majority of cases) and recreate the bookmarkable page for the
> > remaining cases instead of de-serializing a stored version.
> >
> > I know this is possible with stateless pages, but my application is very
> large
> > and converting it all to stateless would require a massive effort.
> >
> > Is there a way to implement this with Wicket 7.6?
> >
> > I'm aware of the flags "setRecreateBookmarkablePagesAfterExpiry" and "
> setCallListenerInterfaceAfterExpiry"
> > but I'm not sure they apply to bookmarkable pages and Ajax calls.
> >
> > Any ideas would be greatly appreciated!
> >
> >
> > Best regards,
> >
> > Thomas
> >
> >
>


Re: Re-create bookmarkable pages on Ajax calls

2017-01-12 Thread Thomas Heigl
I forgot to add:

We are using the HTML5 History API to push state to the (bookmarkable) URL,
so a page can be re-created with *all* state from the URL alone.

Thomas

On Thu, Jan 12, 2017 at 11:47 AM, Thomas Heigl  wrote:

> Hi all,
>
> I'm looking for a solution to avoid serialization of bookmarkable pages.
>
> These are yesterday's metrics from an instrumented version of 
> Fast2WicketSerializer:
>
> "WicketSerializer.deserialize" : {
>>   "count" : 4084,
>>   "max" : 0.0308421623,
>>   "mean" : 0.005861568417930906,
>>   "min" : 0.00144874502,
>>   "mean_rate" : 0.01926885221303454,
>>   "duration_units" : "seconds",
>>   "rate_units" : "calls/second"
>> },
>> "WicketSerializer.serialize" : {
>>   "count" : 498884,
>>   "max" : 0.007742393,
>>   "mean" : 0.002135383760700826,
>>   "min" : 8.2115001E-4,
>>   "mean_rate" : 2.3538006959615907,
>>   "duration_units" : "seconds",
>>   "rate_units" : "calls/second"
>> }
>
>
> As you can see, Wicket serialized about 500.000 pages, but only 4000 were ever
> de-serialized. The deserialization is caused by users who use multiple tabs 
> and
> then trigger an ajax action on one of them.
>
> All my pages are unversioned, bookmarkable and mounted in a way that strips
> version parameters from the URL.
>
> What I would like to do is completely disable HttpSessionDataStore, rely only
> on the application level cache that (from looking at the metrics is sufficient
> in the vast majority of cases) and recreate the bookmarkable page for the
> remaining cases instead of de-serializing a stored version.
>
> I know this is possible with stateless pages, but my application is very large
> and converting it all to stateless would require a massive effort.
>
> Is there a way to implement this with Wicket 7.6?
>
> I'm aware of the flags "setRecreateBookmarkablePagesAfterExpiry" and 
> "setCallListenerInterfaceAfterExpiry"
> but I'm not sure they apply to bookmarkable pages and Ajax calls.
>
> Any ideas would be greatly appreciated!
>
>
> Best regards,
>
> Thomas
>
>