RE: [PATCH] Saving sessions across tomcat instances (#1)

2000-12-18 Thread Nacho

Hola Shai:

IMHO your patch very interesting, i want use it on my own ( prior to
commit it after a review by people )..

In mean time, please send patches as attached files, not embedded in a
message, and another silly advice, please please dont send messages in
HTML, for the people that have big screens ( as i ) sending html results
on a lot of glass to add to my glasses :-) 

Saludos ,
Ignacio J. Ortega

-Mensaje original-
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Enviado el: lunes 18 de diciembre de 2000 10:28
Para: [EMAIL PROTECTED]
Asunto: [PATCH] Saving sessions across tomcat instances (#1)


Hi all,

As discussed, attached first patch to allow tomcat share session
information across processes.
This patch enable context to specify (by adding serialize="true") that
it want to save/reload session information while restarting and going
down.
 
The session information will be stored and reloaded for temp files
located at bin directory.

Index: src/share/org/apache/tomcat/core/Context.java
===
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.
java,v
retrieving revision 1.100.2.4
diff -w -u -r1.100.2.4 Context.java
--- src/share/org/apache/tomcat/core/Context.java 2000/11/18 00:09:42
1.100.2.4
+++ src/share/org/apache/tomcat/core/Context.java 2000/12/18 07:11:01
@@ -97,6 +97,7 @@
 * @author [EMAIL PROTECTED]
 * @author Gal Shachor [EMAIL PROTECTED]
 * @author Arieh Markel [[EMAIL PROTECTED]]
+ * @author Shai Fultheim [[EMAIL PROTECTED]]
 */
public class Context {
 private static StringManager sm
=StringManager.getManager("org.apache.tomcat.core");
@@ -114,6 +115,7 @@
 private boolean crossContext = true;
 private ServletLoader servletL;
 boolean reloadable=true; // XXX change default to false after testing
+ private boolean serialize = false; // Don't save session info across
run.

 private Hashtable attributes = new Hashtable();

@@ -281,6 +283,19 @@
 return reloadable;
 }

+ // -- Serializeable ? --
+ public void setSerialize( String s ) {
+ serialize=new Boolean( s ).booleanValue();
+ }
+
+ public void setSerialize( boolean b ) {
+ serialize=b;
+ }
+
+ public boolean getSerialize() {
+ return serialize;
+ }
+
 //  Web.xml properties 

 public Enumeration getWelcomeFiles() {
Index: src/share/org/apache/tomcat/session/StandardManager.java
===
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/session/Attic
/StandardManager.java,v
retrieving revision 1.11.2.1
diff -w -u -r1.11.2.1 StandardManager.java
--- src/share/org/apache/tomcat/session/StandardManager.java 2000/11/18
01:33:59 1.11.2.1
+++ src/share/org/apache/tomcat/session/StandardManager.java 2000/12/18
07:11:09
@@ -64,14 +64,14 @@

package org.apache.tomcat.session;

-import java.io.IOException;
+import java.io.*;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import org.apache.tomcat.util.*;
-import org.apache.tomcat.core.Request;
+import org.apache.tomcat.core.*;

/**
 * Standard implementation of the bManager/b interface that provides
@@ -83,7 +83,7 @@
 * code
 * lt;Manager className="org.apache.tomcat.session.StandardManager"
 * checkInterval="60" maxActiveSessions="-1"
- * maxInactiveInterval="-1" /
+ * maxInactiveInterval="-1" serialize="true"/
 * /code
 * where you can adjust the following parameters, with default values
 * in square brackets:
@@ -97,6 +97,8 @@
 * a session, or -1 for no limit. This value should be overridden from
 * the default session timeout specified in the web application
deployment
 * descriptor, if any. [-1]
+ * libserialize/b - Allow tomcat save and reload session information
+ * from file over system startup. [false]
 * /ul
 *
 * @author Craig R. McClanahan
@@ -162,9 +164,15 @@
 */
 private String threadName = "StandardManager";

+ /**
+ * Contain owner's context object
+ */
+ private Context ctx = null;
+
 // -
Constructor

- public StandardManager() {
+ public StandardManager(Context ctx) {
+ this.ctx = ctx;
 }

 // -
Properties
@@ -378,6 +386,14 @@
 session.setMaxInactiveInterval(this.maxInactiveInterval);
 session.setId(SessionUtil.generateSessionId(jsIdent));

+ if (ctx.getDebug()  10) {
+ HttpSession Sessions[] = findSessions();
+ ctx.log(ctx.toString() + " Sessions: " + Sessions.length);
+ for(int i=0; iSessions.length; i++) {
+ ctx.log(" " + i + ": " + Sessions[i].getId());
+ }
+ }
+
 return (session);
 }

@@ -398,7 +414,39 @@
 public void start() {
 // Start the background reaper thread
 threadStart();
+
+ if (ctx.getSerialize()) {
+ FileInputStream Stream = null;
+ try {
+ Stream = new FileInputStream(getFileName());
+ 

RE: [PATCH] Saving sessions across tomcat instances (#1)

2000-12-18 Thread shai

Agree.
How do I configure wincvs to give me file with differences.
How do I configure wincvs to do diff -u ? (default is -w) ?

--Shai

-Original Message-
From: Nacho [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 18, 2000 16:48
To: 'tomcat-dev'
Subject: RE: [PATCH] Saving sessions across tomcat instances (#1)

Hola Shai:

IMHO your patch very interesting, i want use it on my own ( prior to
commit it after a review by people )..

In mean time, please send patches as attached files, not embedded in a
message, and another silly advice, please please dont send messages in
HTML, for the people that have big screens ( as i ) sending html results
on a lot of glass to add to my glasses :-)

Saludos ,
Ignacio J. Ortega

-Mensaje original-
De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Enviado el: lunes 18 de diciembre de 2000 10:28
Para: [EMAIL PROTECTED]
Asunto: [PATCH] Saving sessions across tomcat instances (#1)


Hi all,

As discussed, attached first patch to allow tomcat share session
information across processes.
This patch enable context to specify (by adding serialize="true") that
it want to save/reload session information while restarting and going
down.

The session information will be stored and reloaded for temp files
located at bin directory.

Index: src/share/org/apache/tomcat/core/Context.java
===
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.
java,v
retrieving revision 1.100.2.4
diff -w -u -r1.100.2.4 Context.java
--- src/share/org/apache/tomcat/core/Context.java 2000/11/18 00:09:42
1.100.2.4
+++ src/share/org/apache/tomcat/core/Context.java 2000/12/18 07:11:01
@@ -97,6 +97,7 @@
 * @author [EMAIL PROTECTED]
 * @author Gal Shachor [EMAIL PROTECTED]
 * @author Arieh Markel [[EMAIL PROTECTED]]
+ * @author Shai Fultheim [[EMAIL PROTECTED]]
 */
public class Context {
 private static StringManager sm
=StringManager.getManager("org.apache.tomcat.core");
@@ -114,6 +115,7 @@
 private boolean crossContext = true;
 private ServletLoader servletL;
 boolean reloadable=true; // XXX change default to false after testing
+ private boolean serialize = false; // Don't save session info across
run.

 private Hashtable attributes = new Hashtable();

@@ -281,6 +283,19 @@
 return reloadable;
 }

+ // -- Serializeable ? --
+ public void setSerialize( String s ) {
+ serialize=new Boolean( s ).booleanValue();
+ }
+
+ public void setSerialize( boolean b ) {
+ serialize=b;
+ }
+
+ public boolean getSerialize() {
+ return serialize;
+ }
+
 //  Web.xml properties 

 public Enumeration getWelcomeFiles() {
Index: src/share/org/apache/tomcat/session/StandardManager.java
===
RCS file:
/home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/session/Attic
/StandardManager.java,v
retrieving revision 1.11.2.1
diff -w -u -r1.11.2.1 StandardManager.java
--- src/share/org/apache/tomcat/session/StandardManager.java 2000/11/18
01:33:59 1.11.2.1
+++ src/share/org/apache/tomcat/session/StandardManager.java 2000/12/18
07:11:09
@@ -64,14 +64,14 @@

package org.apache.tomcat.session;

-import java.io.IOException;
+import java.io.*;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import org.apache.tomcat.util.*;
-import org.apache.tomcat.core.Request;
+import org.apache.tomcat.core.*;

/**
 * Standard implementation of the bManager/b interface that provides
@@ -83,7 +83,7 @@
 * code
 * lt;Manager className="org.apache.tomcat.session.StandardManager"
 * checkInterval="60" maxActiveSessions="-1"
- * maxInactiveInterval="-1" /
+ * maxInactiveInterval="-1" serialize="true"/
 * /code
 * where you can adjust the following parameters, with default values
 * in square brackets:
@@ -97,6 +97,8 @@
 * a session, or -1 for no limit. This value should be overridden from
 * the default session timeout specified in the web application
deployment
 * descriptor, if any. [-1]
+ * libserialize/b - Allow tomcat save and reload session information
+ * from file over system startup. [false]
 * /ul
 *
 * @author Craig R. McClanahan
@@ -162,9 +164,15 @@
 */
 private String threadName = "StandardManager";

+ /**
+ * Contain owner's context object
+ */
+ private Context ctx = null;
+
 // -
Constructor

- public StandardManager() {
+ public StandardManager(Context ctx) {
+ this.ctx = ctx;
 }

 // -
Properties
@@ -378,6 +386,14 @@
 session.setMaxInactiveInterval(this.maxInactiveInterval);
 session.setId(SessionUtil.generateSessionId(jsIdent));

+ if (ctx.getDebug()  10) {
+ HttpSession Sessions[] =