You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2005/06/28 01:25:28 UTC

svn commit: r202098 - in /portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed: pipeline/valve/PageProfilerValve.java profiler/impl/ProfilerValveImpl.java

Author: taylor
Date: Mon Jun 27 16:25:28 2005
New Revision: 202098

URL: http://svn.apache.org/viewcvs?rev=202098&view=rev
Log:
optimize hits against profiler getRulesForPrincipal, since it was hitting the database once per request

Modified:
    portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/pipeline/valve/PageProfilerValve.java
    portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java

Modified: portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/pipeline/valve/PageProfilerValve.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/pipeline/valve/PageProfilerValve.java?rev=202098&r1=202097&r2=202098&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/pipeline/valve/PageProfilerValve.java (original)
+++ portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/pipeline/valve/PageProfilerValve.java Mon Jun 27 16:25:28 2005
@@ -39,4 +39,5 @@
 public interface PageProfilerValve extends Valve
 {
     String PROFILE_LOCATOR_REQUEST_ATTR_KEY = "org.apache.jetspeed.profiler.ProfileLocator";
+    String PROFILE_LOCATORS_PER_PRINCIPAL = "org.apache.jetspeed.profiler.ProfileLocatorsPrincipal";
 }

Modified: portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java?rev=202098&r1=202097&r2=202098&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java (original)
+++ portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java Mon Jun 27 16:25:28 2005
@@ -100,8 +100,13 @@
             
             if ( locators ==  null )
             {
-                // get all locators for the current user
-                locators = profiler.getProfileLocators(request, principal);
+                locators = (Map)request.getSessionAttribute(PROFILE_LOCATORS_PER_PRINCIPAL);
+                if (locators == null)
+                {
+                    // get all locators for the current user
+                    locators = profiler.getProfileLocators(request, principal);
+                    request.setSessionAttribute(PROFILE_LOCATORS_PER_PRINCIPAL, locators);
+                }
             }
 
             if (locators.size() == 0)



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Re: login session

Posted by Randy Watler <wa...@wispertel.net>.
James,

I think we need to consider whether a new session should be started or 
not in the login servlet.
We will need to get input from the rest of the team, most notably Ate.

Of course you can keep using your workaround. As usual, SVN pulls are 
not necessarily
stable, but we do try hard to keep it that way. Thanks for the input and 
alerting us to this
issue in the first place!

Randy

James Liao wrote:

>Hi David,
>I test it again thoroghly. But the problem still exist. It seems that
>the problem is cause by the following reason:
>1. Each time the JetspeedRequestContext try to get something from
>session, it will call HttpServletRequest.getSession(), so there is a
>session for guest user.
>
>2. When you try to login to portal, LoginServlet will call 
>"HttpSession session = request.getSession(true);" This does not make
>sure to create a new session for this login action. The following is
>the Java Doc for this method:
>
>Returns the current HttpSession  associated with this request or, if
>if there is no current session and create is true, returns a new
>session.
>
>So it is the same session for the guest and user(admin, manager or
>someone else).
>
>I think we could fix this problem by call
>"session.removeAttribute(PageProfilerValve.PROFILE_LOCATORS_PER_PRINCIPAL);"
>after "HttpSession session = request.getSession(true);" in
>LoginServlet.java. It will clear this attribute.
>
>My entironment:
>JDK 1.4.2_07
>WinXP SP2
>
>-James Liao
>
>On 6/28/05, David Sean Taylor <da...@bluesunrise.com> wrote:
>  
>
>>James Liao wrote:
>>    
>>
>>>Hi david,
>>>I have update to the latest J2, I found a problem about your optimize
>>>for ProfilerValve.
>>>
>>>For the first time, I visit J2 portal, I got a guest principal as
>>>default, you will getProfileLocators for guest principal and store
>>>into session.
>>>
>>>When I login as admin, the session is still the same session for
>>>previous guest, so it will not recreate the locators, still use the
>>>old locators for guest. I can't go anywhere except the
>>>default-page.psml. I think it is wrong.
>>>
>>>      
>>>
>>Well, IMO logging on should create a new session.
>>
>>--
>>David Sean Taylor
>>Bluesunrise Software
>>david@bluesunrise.com
>>[office] +01 707 773-4646
>>[mobile] +01 707 529 9194
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
>>For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
>For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
>
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Re: svn commit: r202098 - in /portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed: pipeline/valve/PageProfilerValve.java profiler/impl/ProfilerValveImpl.java

Posted by James Liao <ji...@gmail.com>.
Hi,
Thanks for response.
Yes, I agree that a anonymous(guest) session is necessary.
I will go back to the last version to wait for your solution.
Regards,
- James Liao

On 6/29/05, Ate Douma <at...@douma.nu> wrote:
> James,
> 
> You are correct: the anonymous session is reused when you login properly.
> And its actually something you usually want (consider a session based shopping cart).
> 
> There is a better solution than your workaround though and I will look into it this
> evening or tomorrow morning.
> 
> Regards, Ate
> 
> James Liao wrote:
> > Hi David,
> > I test it again thoroghly. But the problem still exist. It seems that
> > the problem is cause by the following reason:
> > 1. Each time the JetspeedRequestContext try to get something from
> > session, it will call HttpServletRequest.getSession(), so there is a
> > session for guest user.
> >
> > 2. When you try to login to portal, LoginServlet will call
> > "HttpSession session = request.getSession(true);" This does not make
> > sure to create a new session for this login action. The following is
> > the Java Doc for this method:
> >
> > Returns the current HttpSession  associated with this request or, if
> > if there is no current session and create is true, returns a new
> > session.
> >
> > So it is the same session for the guest and user(admin, manager or
> > someone else).
> >
> > I think we could fix this problem by call
> > "session.removeAttribute(PageProfilerValve.PROFILE_LOCATORS_PER_PRINCIPAL);"
> > after "HttpSession session = request.getSession(true);" in
> > LoginServlet.java. It will clear this attribute.
> >
> > My entironment:
> > JDK 1.4.2_07
> > WinXP SP2
> >
> > -James Liao
> >
> > On 6/28/05, David Sean Taylor <da...@bluesunrise.com> wrote:
> >
> >>James Liao wrote:
> >>
> >>>Hi david,
> >>>I have update to the latest J2, I found a problem about your optimize
> >>>for ProfilerValve.
> >>>
> >>>For the first time, I visit J2 portal, I got a guest principal as
> >>>default, you will getProfileLocators for guest principal and store
> >>>into session.
> >>>
> >>>When I login as admin, the session is still the same session for
> >>>previous guest, so it will not recreate the locators, still use the
> >>>old locators for guest. I can't go anywhere except the
> >>>default-page.psml. I think it is wrong.
> >>>
> >>
> >>Well, IMO logging on should create a new session.
> >>
> >>--
> >>David Sean Taylor
> >>Bluesunrise Software
> >>david@bluesunrise.com
> >>[office] +01 707 773-4646
> >>[mobile] +01 707 529 9194
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
> >>For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
> > For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
> >
> >
> >
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Re: svn commit: r202098 - in /portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed: pipeline/valve/PageProfilerValve.java profiler/impl/ProfilerValveImpl.java

Posted by Ate Douma <at...@douma.nu>.
James,

You are correct: the anonymous session is reused when you login properly.
And its actually something you usually want (consider a session based shopping cart).

There is a better solution than your workaround though and I will look into it this
evening or tomorrow morning.

Regards, Ate

James Liao wrote:
> Hi David,
> I test it again thoroghly. But the problem still exist. It seems that
> the problem is cause by the following reason:
> 1. Each time the JetspeedRequestContext try to get something from
> session, it will call HttpServletRequest.getSession(), so there is a
> session for guest user.
> 
> 2. When you try to login to portal, LoginServlet will call 
> "HttpSession session = request.getSession(true);" This does not make
> sure to create a new session for this login action. The following is
> the Java Doc for this method:
> 
> Returns the current HttpSession  associated with this request or, if
> if there is no current session and create is true, returns a new
> session.
> 
> So it is the same session for the guest and user(admin, manager or
> someone else).
> 
> I think we could fix this problem by call
> "session.removeAttribute(PageProfilerValve.PROFILE_LOCATORS_PER_PRINCIPAL);"
> after "HttpSession session = request.getSession(true);" in
> LoginServlet.java. It will clear this attribute.
> 
> My entironment:
> JDK 1.4.2_07
> WinXP SP2
> 
> -James Liao
> 
> On 6/28/05, David Sean Taylor <da...@bluesunrise.com> wrote:
> 
>>James Liao wrote:
>>
>>>Hi david,
>>>I have update to the latest J2, I found a problem about your optimize
>>>for ProfilerValve.
>>>
>>>For the first time, I visit J2 portal, I got a guest principal as
>>>default, you will getProfileLocators for guest principal and store
>>>into session.
>>>
>>>When I login as admin, the session is still the same session for
>>>previous guest, so it will not recreate the locators, still use the
>>>old locators for guest. I can't go anywhere except the
>>>default-page.psml. I think it is wrong.
>>>
>>
>>Well, IMO logging on should create a new session.
>>
>>--
>>David Sean Taylor
>>Bluesunrise Software
>>david@bluesunrise.com
>>[office] +01 707 773-4646
>>[mobile] +01 707 529 9194
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
>>For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
> 
> 
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Re: svn commit: r202098 - in /portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed: pipeline/valve/PageProfilerValve.java profiler/impl/ProfilerValveImpl.java

Posted by James Liao <ji...@gmail.com>.
Hi David,
I test it again thoroghly. But the problem still exist. It seems that
the problem is cause by the following reason:
1. Each time the JetspeedRequestContext try to get something from
session, it will call HttpServletRequest.getSession(), so there is a
session for guest user.

2. When you try to login to portal, LoginServlet will call 
"HttpSession session = request.getSession(true);" This does not make
sure to create a new session for this login action. The following is
the Java Doc for this method:

Returns the current HttpSession  associated with this request or, if
if there is no current session and create is true, returns a new
session.

So it is the same session for the guest and user(admin, manager or
someone else).

I think we could fix this problem by call
"session.removeAttribute(PageProfilerValve.PROFILE_LOCATORS_PER_PRINCIPAL);"
after "HttpSession session = request.getSession(true);" in
LoginServlet.java. It will clear this attribute.

My entironment:
JDK 1.4.2_07
WinXP SP2

-James Liao

On 6/28/05, David Sean Taylor <da...@bluesunrise.com> wrote:
> James Liao wrote:
> > Hi david,
> > I have update to the latest J2, I found a problem about your optimize
> > for ProfilerValve.
> >
> > For the first time, I visit J2 portal, I got a guest principal as
> > default, you will getProfileLocators for guest principal and store
> > into session.
> >
> > When I login as admin, the session is still the same session for
> > previous guest, so it will not recreate the locators, still use the
> > old locators for guest. I can't go anywhere except the
> > default-page.psml. I think it is wrong.
> >
> Well, IMO logging on should create a new session.
> 
> --
> David Sean Taylor
> Bluesunrise Software
> david@bluesunrise.com
> [office] +01 707 773-4646
> [mobile] +01 707 529 9194
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Re: svn commit: r202098 - in /portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed: pipeline/valve/PageProfilerValve.java profiler/impl/ProfilerValveImpl.java

Posted by David Sean Taylor <da...@bluesunrise.com>.
James Liao wrote:
> Hi david,
> I have update to the latest J2, I found a problem about your optimize
> for ProfilerValve.
> 
> For the first time, I visit J2 portal, I got a guest principal as
> default, you will getProfileLocators for guest principal and store
> into session.
> 
> When I login as admin, the session is still the same session for
> previous guest, so it will not recreate the locators, still use the
> old locators for guest. I can't go anywhere except the
> default-page.psml. I think it is wrong.
> 
Well, IMO logging on should create a new session.

-- 
David Sean Taylor
Bluesunrise Software
david@bluesunrise.com
[office] +01 707 773-4646
[mobile] +01 707 529 9194

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Re: svn commit: r202098 - in /portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed: pipeline/valve/PageProfilerValve.java profiler/impl/ProfilerValveImpl.java

Posted by James Liao <ji...@gmail.com>.
Hi david,
I have update to the latest J2, I found a problem about your optimize
for ProfilerValve.

For the first time, I visit J2 portal, I got a guest principal as
default, you will getProfileLocators for guest principal and store
into session.

When I login as admin, the session is still the same session for
previous guest, so it will not recreate the locators, still use the
old locators for guest. I can't go anywhere except the
default-page.psml. I think it is wrong.

- James Liao

On 6/28/05, taylor@apache.org <ta...@apache.org> wrote:
> Author: taylor
> Date: Mon Jun 27 16:25:28 2005
> New Revision: 202098
> 
> URL: http://svn.apache.org/viewcvs?rev=202098&view=rev
> Log:
> optimize hits against profiler getRulesForPrincipal, since it was hitting the database once per request
> 
> Modified:
>     portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/pipeline/valve/PageProfilerValve.java
>     portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
> 
> Modified: portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/pipeline/valve/PageProfilerValve.java
> URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/pipeline/valve/PageProfilerValve.java?rev=202098&r1=202097&r2=202098&view=diff
> ==============================================================================
> --- portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/pipeline/valve/PageProfilerValve.java (original)
> +++ portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/pipeline/valve/PageProfilerValve.java Mon Jun 27 16:25:28 2005
> @@ -39,4 +39,5 @@
>  public interface PageProfilerValve extends Valve
>  {
>      String PROFILE_LOCATOR_REQUEST_ATTR_KEY = "org.apache.jetspeed.profiler.ProfileLocator";
> +    String PROFILE_LOCATORS_PER_PRINCIPAL = "org.apache.jetspeed.profiler.ProfileLocatorsPrincipal";
>  }
> 
> Modified: portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java
> URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java?rev=202098&r1=202097&r2=202098&view=diff
> ==============================================================================
> --- portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java (original)
> +++ portals/jetspeed-2/trunk/portal/src/java/org/apache/jetspeed/profiler/impl/ProfilerValveImpl.java Mon Jun 27 16:25:28 2005
> @@ -100,8 +100,13 @@
> 
>              if ( locators ==  null )
>              {
> -                // get all locators for the current user
> -                locators = profiler.getProfileLocators(request, principal);
> +                locators = (Map)request.getSessionAttribute(PROFILE_LOCATORS_PER_PRINCIPAL);
> +                if (locators == null)
> +                {
> +                    // get all locators for the current user
> +                    locators = profiler.getProfileLocators(request, principal);
> +                    request.setSessionAttribute(PROFILE_LOCATORS_PER_PRINCIPAL, locators);
> +                }
>              }
> 
>              if (locators.size() == 0)
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-dev-help@portals.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org