Re: sessionListener.sessionDestroyed is called on shutdown of a node in the cluster

2008-04-18 Thread Ronald Klop

Yes, I know how to work around the problem. But I don't like workarounds. All 
implementations I can think of are very fragile. What if somebody stops my 
Tomcat with kill one day?

My session isn't destroyed, so I don't understand why the event is thrown.

Ronald.

On Thu Apr 17 15:49:49 CEST 2008 Tomcat Users List users@tomcat.apache.org 
wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ronald,

Ronald Klop wrote:
| In sessionDestroyed I register the user as logged out.
|
| How can I know if sessionDestroyed is called from session.invalidate()
| from the real expiration of the session or shutdown of one cluster node?

Are your shutdowns typically planned? If so, you could stick something
in the session like shuttingDown192.168.1.123 and then check for that
key when you are processing a session destroyed event. Just ignore
such events from the current machine's IP address.

Or, you could even do something like this:

1. Before shutdown, place a shutting down key in the application scope.

2. Modify your sessionDestroyed code to do this:

public void sessionDestroyed(HttpSessionEvent se)
{
~ ServletContext application = se.getSession().getServletContext();

~ if(null != application.getAttribute(SHUTTING_DOWN))
~ return;

~ // Otherwise, process the shutdown normally.
}

This should work given that the application scope is not distributed
across nodes in the cluster. You just put your node in a shutdown
state and then ignore all events (or any you care to ignore).

Hope that helps,
- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgHVX0ACgkQ9CaO5/Lv0PC27ACfdh2El6QLeI4LpHaoowJcfJ/Q
cOgAn1ocNzI8qXhax4cs/LLUJYSqWytT
=7EAa
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: sessionListener.sessionDestroyed is called on shutdown of a node in the cluster

2008-04-18 Thread Ronald Klop

On Fri Apr 18 14:16:33 CEST 2008 Christopher Schultz [EMAIL PROTECTED] wrote:

Ronald,

Ronald Klop wrote:
 Yes, I know how to work around the problem. But I don't like 
 workarounds. All implementations I can think of are very fragile. What 
 if somebody stops my Tomcat with kill one day?


Then I don't think that you will have to worry about processing 
sessionDestroyed messages ;)


Also, that is a somewhat remote possibility. Finally, marking a user as 
logged-out isn't the end of the world. You should only have to handle 
common cases, here, right?


 My session isn't destroyed, so I don't understand why the event is thrown.

Yes, the session is destroyed. The problem is that, semantically, you 
are thinking that session == app login, which is not true.


-chris





Mmm. But why does the client still have the same session after one node shuts 
down. The session doesn't live on one node. It lives as long as the cluster 
lives.
I understand the Session object in the JVM is destroyed, but one part of 
clustering (for me) is to replicate the Session object, so the 
'browser-session' lives on.
There is no way for me to detect if the browser-session expires or if the 
Session object expires except by hacking around with ugly if statements and 
making the deployement more difficult and fragile.

I think session.destroyed should only be called if the last node of the cluster 
shuts down. Or if the session expires by timeout.

But maybe our ideas just don't match. That's fine by me.

Ronald.


Re: sessionListener.sessionDestroyed is called on shutdown of a node in the cluster

2008-04-18 Thread Ronald Klop

On Fri Apr 18 15:29:16 CEST 2008 Christopher Schultz [EMAIL PROTECTED] wrote:

Ronald,

Ronald Klop wrote:
 But why does the client still have the same session after one node 
 shuts down. The session doesn't live on one node. It lives as long as 
 the cluster lives.


That's a good point.

 I understand the Session object in the JVM is destroyed, but one part of 
 clustering (for me) is to replicate the Session object, so the 
 'browser-session' lives on.


Fair enough.

 There is no way for me to detect if the browser-session expires or if 
 the Session object expires except by hacking around with ugly if 
 statements and making the deployement more difficult and fragile.
 
 I think session.destroyed should only be called if the last node of the 
 cluster shuts down. Or if the session expires by timeout.


Unfortunately, I was unable to find any detail in the servlet 
specification, which means that implementors are free to do what they'd 
like in these situations. On the other hand, it means that you might 
have an opportunity to lobby the Tomcat folks to add a configuration 
parameter (similar to expireSessionsOnShutdown) to achieve the behavior 
you desire.


The problem is that sessionDestroyed can be used to support both 
resource release (kind of like a finally for sessions) as well as 
logout (in your case). For the former, it is very important for that 
event to fire, even on a single node being taken out of service. For 
others (such as yourself), it is inconvenient. It's hard to satisfy both 
requirements.


The Tomcat folks seem to have erred on the side of inclusivity (always 
send the event) because there are possibilities to work around it. If 
the event were never sent, there's no way to handle resource release at all.


Optional configuration sounds like a good choice.

-chris




Thanks for the explanation. I would implement the resource release stuff in a 
ContextListener or by ValueUnboundListeners, but that is another discussion.
My problem isn't that big in practice. Just the accounting of logouts is not 
100% correct. I'll think about something genius to work around it. If I can't 
think of anything I will try to lobby more.

Ronald.



Re: sessionListener.sessionDestroyed is called on shutdown of a node in the cluster

2008-04-17 Thread Ronald Klop

Thanks for replying. I still have not found a solution.
As Filip mentions below. It isn't going to be fixed.

Maybe it is possible to do something with valueBound, valueUnbound events, but 
I didn't have time to check it yet.

Ronald.

On Wed Apr 16 12:23:38 CEST 2008 Tomcat Users List users@tomcat.apache.org 
wrote:


Hello,

I have the same problem.
please let me know if you have got any solution to this.


sanjeev 




Ronald Klop wrote:
 
 In sessionDestroyed I register the user as logged out.
 
 How can I know if sessionDestroyed is called from session.invalidate()

 from the real expiration of the session or shutdown of one cluster node?
 
 
 Ronald.
 
 On Thu Mar 20 17:40:26 CET 2008 Tomcat Users List

 users@tomcat.apache.org wrote:
 It's expected behavior, sessions will always expire on the local node 
 during a graceful shutdown.
 
 expireSessionsOnShutdown=false simply means that we don't expire 
 sessions in the remote nodes
 
 Filip
 
 
 Ronald Klop wrote:

  Hello,
 
  When I shutdown a node in my cluster (tomcat 5.5.26) sessionDestroyed 
  is called on all SessionListeners on that node.
  But I'm running a cluster, so one node stopping doesn't mean the 
  session is destroyed.

 
  My understanding is that expireSessionsOnShutdown=false by default 
  and I don't change it in my config.

 
  Is this a bug, a feature or am I doing something wrong?
 
  Ronald.
 
 
 
  No virus found in this incoming message.
  Checked by AVG. 
  Version: 7.5.519 / Virus Database: 269.21.7/1334 - Release Date:

 3/18/2008 8:52 PM
  
 
 
 -

 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 


--
View this message in context: 
http://www.nabble.com/sessionListener.sessionDestroyed-is-called-on-shutdown-of-a-node-in-the-cluster-tp16178701p16720610.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Re: sessionListener.sessionDestroyed is called on shutdown of a node in the cluster

2008-04-17 Thread Christopher Schultz

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ronald,

Ronald Klop wrote:
| In sessionDestroyed I register the user as logged out.
|
| How can I know if sessionDestroyed is called from session.invalidate()
| from the real expiration of the session or shutdown of one cluster node?

Are your shutdowns typically planned? If so, you could stick something
in the session like shuttingDown192.168.1.123 and then check for that
key when you are processing a session destroyed event. Just ignore
such events from the current machine's IP address.

Or, you could even do something like this:

1. Before shutdown, place a shutting down key in the application scope.

2. Modify your sessionDestroyed code to do this:

public void sessionDestroyed(HttpSessionEvent se)
{
~  ServletContext application = se.getSession().getServletContext();

~  if(null != application.getAttribute(SHUTTING_DOWN))
~  return;

~  // Otherwise, process the shutdown normally.
}

This should work given that the application scope is not distributed
across nodes in the cluster. You just put your node in a shutdown
state and then ignore all events (or any you care to ignore).

Hope that helps,
- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgHVX0ACgkQ9CaO5/Lv0PC27ACfdh2El6QLeI4LpHaoowJcfJ/Q
cOgAn1ocNzI8qXhax4cs/LLUJYSqWytT
=7EAa
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: sessionListener.sessionDestroyed is called on shutdown of a node in the cluster

2008-04-17 Thread Petruzella, Jim
Please remove me from this list...

Thanks!!

Jim Petruzella
Windows System Administrator
Distributed Systems
Perdue Farms Inc.
Corporate Office
Salisbury  Md. 21802
www.perdue.com
[EMAIL PROTECTED]
(410) 341-2176

-Original Message-
From: Christopher Schultz [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 17, 2008 9:50 AM
To: Tomcat Users List
Cc: Filip Hanik - Dev Lists
Subject: Re: sessionListener.sessionDestroyed is called on shutdown of a node 
in the cluster

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Ronald,

Ronald Klop wrote:
| In sessionDestroyed I register the user as logged out.
|
| How can I know if sessionDestroyed is called from session.invalidate()
| from the real expiration of the session or shutdown of one cluster node?

Are your shutdowns typically planned? If so, you could stick something
in the session like shuttingDown192.168.1.123 and then check for that
key when you are processing a session destroyed event. Just ignore
such events from the current machine's IP address.

Or, you could even do something like this:

1. Before shutdown, place a shutting down key in the application scope.

2. Modify your sessionDestroyed code to do this:

public void sessionDestroyed(HttpSessionEvent se)
{
~  ServletContext application = se.getSession().getServletContext();

~  if(null != application.getAttribute(SHUTTING_DOWN))
~  return;

~  // Otherwise, process the shutdown normally.
}

This should work given that the application scope is not distributed
across nodes in the cluster. You just put your node in a shutdown
state and then ignore all events (or any you care to ignore).

Hope that helps,
- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgHVX0ACgkQ9CaO5/Lv0PC27ACfdh2El6QLeI4LpHaoowJcfJ/Q
cOgAn1ocNzI8qXhax4cs/LLUJYSqWytT
=7EAa
-END PGP SIGNATURE-

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




DISCLAIMER:
**
This communication, including attachments, may contain confidential, 
privileged, copyrighted or other legally protected information.  If you are not 
the intended recipient, you are hereby notified that any use, disclosure, 
dissemination, distribution, or copying of this communication, or any of its 
contents, is strictly prohibited.  If you have received this communication in 
error, please immediately re-send this communication to the sender and delete 
the original message and any copy of it, including all attachments, from your 
computer system.
**


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: sessionListener.sessionDestroyed is called on shutdown of a node in the cluster

2008-04-16 Thread sanjeevtarar

Hello,

I have the same problem.
please let me know if you have got any solution to this.


sanjeev 



Ronald Klop wrote:
 
 In sessionDestroyed I register the user as logged out.
 
 How can I know if sessionDestroyed is called from session.invalidate()
 from the real expiration of the session or shutdown of one cluster node?
 
 
 Ronald.
 
 On Thu Mar 20 17:40:26 CET 2008 Tomcat Users List
 users@tomcat.apache.org wrote:
 It's expected behavior, sessions will always expire on the local node 
 during a graceful shutdown.
 
 expireSessionsOnShutdown=false simply means that we don't expire 
 sessions in the remote nodes
 
 Filip
 
 
 Ronald Klop wrote:
  Hello,
 
  When I shutdown a node in my cluster (tomcat 5.5.26) sessionDestroyed 
  is called on all SessionListeners on that node.
  But I'm running a cluster, so one node stopping doesn't mean the 
  session is destroyed.
 
  My understanding is that expireSessionsOnShutdown=false by default 
  and I don't change it in my config.
 
  Is this a bug, a feature or am I doing something wrong?
 
  Ronald.
 
 
 
  No virus found in this incoming message.
  Checked by AVG. 
  Version: 7.5.519 / Virus Database: 269.21.7/1334 - Release Date:
 3/18/2008 8:52 PM
  
 
 
 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/sessionListener.sessionDestroyed-is-called-on-shutdown-of-a-node-in-the-cluster-tp16178701p16720610.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: sessionListener.sessionDestroyed is called on shutdown of a node in the cluster

2008-03-21 Thread Ronald Klop

In sessionDestroyed I register the user as logged out.

How can I know if sessionDestroyed is called from session.invalidate() from the 
real expiration of the session or shutdown of one cluster node?


Ronald.

On Thu Mar 20 17:40:26 CET 2008 Tomcat Users List users@tomcat.apache.org 
wrote:
It's expected behavior, sessions will always expire on the local node 
during a graceful shutdown.


expireSessionsOnShutdown=false simply means that we don't expire 
sessions in the remote nodes


Filip


Ronald Klop wrote:
 Hello,

 When I shutdown a node in my cluster (tomcat 5.5.26) sessionDestroyed 
 is called on all SessionListeners on that node.
 But I'm running a cluster, so one node stopping doesn't mean the 
 session is destroyed.


 My understanding is that expireSessionsOnShutdown=false by default 
 and I don't change it in my config.


 Is this a bug, a feature or am I doing something wrong?

 Ronald.
 

 No virus found in this incoming message.
 Checked by AVG. 
 Version: 7.5.519 / Virus Database: 269.21.7/1334 - Release Date: 3/18/2008 8:52 PM
 



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: sessionListener.sessionDestroyed is called on shutdown of a node in the cluster

2008-03-20 Thread Filip Hanik - Dev Lists
It's expected behavior, sessions will always expire on the local node 
during a graceful shutdown.


expireSessionsOnShutdown=false simply means that we don't expire 
sessions in the remote nodes


Filip


Ronald Klop wrote:

Hello,

When I shutdown a node in my cluster (tomcat 5.5.26) sessionDestroyed 
is called on all SessionListeners on that node.
But I'm running a cluster, so one node stopping doesn't mean the 
session is destroyed.


My understanding is that expireSessionsOnShutdown=false by default 
and I don't change it in my config.


Is this a bug, a feature or am I doing something wrong?

Ronald.


No virus found in this incoming message.
Checked by AVG. 
Version: 7.5.519 / Virus Database: 269.21.7/1334 - Release Date: 3/18/2008 8:52 PM
  



-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]