Costin:
I noticed that my patch email got line-wrapped. So, I'm sending them as an
attachment.
Tom
----- Original Message -----
From: "Tom Drake" <[EMAIL PROTECTED]>
To: "Tomcat Developers List" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, January 14, 2002 6:19 AM
Subject: [PATCH] JvmRoute changes
| Costin:
|
| Sorry for the late response, but here are the patches you requested for
| JvmRoute.
| This tests out using the session example servlet.
|
| After inclusion of these patches, adding the following attribute to the
| <Engine>
| tag in server.xml
|
| jvmRoute="fubar"
|
| Causes ".fubar" to be appended to the end of all session id's (generated
| by ManagerBase) as follows:
|
| 70AB699891C12D3748248D026012F815.fubar
|
| Tom
|
| P.S. Having never submitted a patch before, I wasn't sure whether you
wanted
| them all strung together like I've done here, or as attachments.
|
|
| Index: Engine.java
| ===================================================================
| RCS file:
|
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/En
| gine.java,v
| retrieving revision 1.7
| diff -u -r1.7 Engine.java
| --- Engine.java 16 Oct 2001 23:14:13 -0000 1.7
| +++ Engine.java 14 Jan 2002 13:48:07 -0000
| @@ -132,6 +132,18 @@
| */
| public void addDefaultContext(DefaultContext defaultContext);
|
| + /**
| + * Set the JvmRouteId for this engine.
| + *
| + * @param jvmRouteId the (new) JVM Route ID. Each Engine within a
| cluster
| + * must have the same JVM Route ID.
| + */
| + public void setJvmRoute(String jvmRouteId);
| +
| + /**
| + * Retrieve the JvmRouteId for this engine.
| + */
| + public String getJvmRoute();
|
| // --------------------------------------------------------- Public
| Methods
|
|
|
| Index: StandardEngine.java
| ===================================================================
| RCS file:
|
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/co
| re/StandardEngine.java,v
| retrieving revision 1.12
| diff -u -r1.12 StandardEngine.java
| --- StandardEngine.java 21 Dec 2001 21:15:45 -0000 1.12
| +++ StandardEngine.java 14 Jan 2002 13:55:03 -0000
| @@ -143,6 +143,11 @@
| */
| private DefaultContext defaultContext;
|
| + /**
| + * The JVM Route ID for this Tomcat instance. All Route ID's must be
| unique
| + * across the cluster.
| + */
| + private String jvmRouteId;
|
| // -------------------------------------------------------------
| Properties
|
| @@ -278,6 +283,24 @@
|
| }
|
| + /**
| + * Set the cluster-wide unique identifier for this Engine.
| + * This value is only useful in a load-balancing scenario.
| + * <p>
| + * This property should not be changed once it is set.
| + */
| + public void setJvmRoute(String routeId) {
| + this.log("StandardEngine.setJvmRoute="+routeId);
| + jvmRouteId = routeId;
| + }
| +
| + /**
| + * Retrieve the cluster-wide unique identifier for this Engine.
| + * This value is only useful in a load-balancing scenario.
| + */
| + public String getJvmRoute() {
| + return jvmRouteId;
| + }
|
| /**
| * Disallow any attempt to set a parent for this Container, since an
|
| Index: ManagerBase.java
| ===================================================================
| RCS file:
|
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/se
| ssion/ManagerBase.java,v
| retrieving revision 1.10
| diff -u -r1.10 ManagerBase.java
| --- ManagerBase.java 10 Dec 2001 01:24:41 -0000 1.10
| +++ ManagerBase.java 14 Jan 2002 14:06:45 -0000
| @@ -74,6 +74,7 @@
| import java.util.HashMap;
| import java.util.Random;
| import org.apache.catalina.Container;
| +import org.apache.catalina.Engine;
| import org.apache.catalina.Logger;
| import org.apache.catalina.Manager;
| import org.apache.catalina.Session;
| @@ -516,6 +517,30 @@
|
|
| /**
| + * Retrieve the enclosing Engine for this Manager.
| + *
| + * @return an Engine object (or null).
| + */
| + public Engine getEngine() {
| + Engine e = null;
| + for (Container c=getContainer(); e == null && c != null ;c =
| c.getParent()) {
| + if (c != null && c instanceof Engine) {
| + e = (Engine)c;
| + }
| + }
| + return e;
| + }
| +
| + /**
| + * Retrieve the JvmRoute for the enclosing Engine.
| + * @return the JvmRoute or null.
| + */
| + public String getJvmRoute() {
| + Engine e = getEngine();
| + return e == null ? null : e.getJvmRoute();
| + }
| +
| + /**
| * Construct and return a new session object, based on the default
| * settings specified by this Manager's properties. The session
| * id will be assigned by this method, and available via the getId()
| @@ -547,6 +572,12 @@
| session.setCreationTime(System.currentTimeMillis());
| session.setMaxInactiveInterval(this.maxInactiveInterval);
| String sessionId = generateSessionId();
| + String jvmRoute = getJvmRoute();
| + // @todo Move appending of jvmRoute generateSessionId()???
| + if (jvmRoute != null) {
| + sessionId += '.' + jvmRoute;
| + session.setId(sessionId);
| + }
| /*
| synchronized (sessions) {
| while (sessions.get(sessionId) != null) // Guarantee
| uniqueness
|
|
|
|
| ----- Original Message -----
| From: <[EMAIL PROTECTED]>
| To: "Tomcat Developers List" <[EMAIL PROTECTED]>
| Sent: Thursday, January 10, 2002 8:44 AM
| Subject: Re: Todo list for 4.0.2 b2
|
|
| | On Thu, 10 Jan 2002, Tom Drake wrote:
| |
| | > FYI:
| | >
| | > Based on previous discussions on this list, I've added
| setJvmRoute/JvmRoute
| | > to Engine
| | > (and StandardEngine) as part of the work I've been doing for
distributed
| | > sessions.
| |
| | Can you send the patch for this one ?
| |
| | There are just 2 changes that are needed - the methods in Engine and
| | about 2 lines of code in the session manager ( to check if vmRoute is
set
| | and if so add it to the session id ).
| |
| |
| |
| | Costin
| |
| |
| |
| | --
| | To unsubscribe, e-mail:
| <mailto:[EMAIL PROTECTED]>
| | For additional commands, e-mail:
| <mailto:[EMAIL PROTECTED]>
| |
| |
| |
|
Index: Engine.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/Engine.java,v
retrieving revision 1.7
diff -u -r1.7 Engine.java
--- Engine.java 16 Oct 2001 23:14:13 -0000 1.7
+++ Engine.java 14 Jan 2002 14:24:14 -0000
@@ -132,6 +132,18 @@
*/
public void addDefaultContext(DefaultContext defaultContext);
+ /**
+ * Set the JvmRouteId for this engine.
+ *
+ * @param jvmRouteId the (new) JVM Route ID. Each Engine within a cluster
+ * must have the same JVM Route ID.
+ */
+ public void setJvmRoute(String jvmRouteId);
+
+ /**
+ * Retrieve the JvmRouteId for this engine.
+ */
+ public String getJvmRoute();
// --------------------------------------------------------- Public Methods
Index: StandardEngine.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardEngine.java,v
retrieving revision 1.12
diff -u -r1.12 StandardEngine.java
--- StandardEngine.java 21 Dec 2001 21:15:45 -0000 1.12
+++ StandardEngine.java 14 Jan 2002 14:23:50 -0000
@@ -143,6 +143,11 @@
*/
private DefaultContext defaultContext;
+ /**
+ * The JVM Route ID for this Tomcat instance. All Route ID's must be unique
+ * across the cluster.
+ */
+ private String jvmRouteId;
// ------------------------------------------------------------- Properties
@@ -278,6 +283,24 @@
}
+ /**
+ * Set the cluster-wide unique identifier for this Engine.
+ * This value is only useful in a load-balancing scenario.
+ * <p>
+ * This property should not be changed once it is set.
+ */
+ public void setJvmRoute(String routeId) {
+ this.log("StandardEngine.setJvmRoute="+routeId);
+ jvmRouteId = routeId;
+ }
+
+ /**
+ * Retrieve the cluster-wide unique identifier for this Engine.
+ * This value is only useful in a load-balancing scenario.
+ */
+ public String getJvmRoute() {
+ return jvmRouteId;
+ }
/**
* Disallow any attempt to set a parent for this Container, since an
Index: ManagerBase.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/session/ManagerBase.java,v
retrieving revision 1.10
diff -u -r1.10 ManagerBase.java
--- ManagerBase.java 10 Dec 2001 01:24:41 -0000 1.10
+++ ManagerBase.java 14 Jan 2002 14:06:45 -0000
@@ -74,6 +74,7 @@
import java.util.HashMap;
import java.util.Random;
import org.apache.catalina.Container;
+import org.apache.catalina.Engine;
import org.apache.catalina.Logger;
import org.apache.catalina.Manager;
import org.apache.catalina.Session;
@@ -516,6 +517,30 @@
/**
+ * Retrieve the enclosing Engine for this Manager.
+ *
+ * @return an Engine object (or null).
+ */
+ public Engine getEngine() {
+ Engine e = null;
+ for (Container c=getContainer(); e == null && c != null ;c = c.getParent()) {
+ if (c != null && c instanceof Engine) {
+ e = (Engine)c;
+ }
+ }
+ return e;
+ }
+
+ /**
+ * Retrieve the JvmRoute for the enclosing Engine.
+ * @return the JvmRoute or null.
+ */
+ public String getJvmRoute() {
+ Engine e = getEngine();
+ return e == null ? null : e.getJvmRoute();
+ }
+
+ /**
* Construct and return a new session object, based on the default
* settings specified by this Manager's properties. The session
* id will be assigned by this method, and available via the getId()
@@ -547,6 +572,12 @@
session.setCreationTime(System.currentTimeMillis());
session.setMaxInactiveInterval(this.maxInactiveInterval);
String sessionId = generateSessionId();
+ String jvmRoute = getJvmRoute();
+ // @todo Move appending of jvmRoute generateSessionId()???
+ if (jvmRoute != null) {
+ sessionId += '.' + jvmRoute;
+ session.setId(sessionId);
+ }
/*
synchronized (sessions) {
while (sessions.get(sessionId) != null) // Guarantee uniqueness
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>