You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2004/01/12 08:50:07 UTC
cvs commit: jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp ReplicationValve.java SimpleTcpCluster.java
fhanik 2004/01/11 23:50:07
Modified: modules/cluster/src/share/org/apache/catalina/cluster
ClusterManager.java
modules/cluster/src/share/org/apache/catalina/cluster/session
DeltaManager.java DeltaRequest.java
DeltaSession.java SimpleTcpReplicationManager.java
modules/cluster/src/share/org/apache/catalina/cluster/tcp
ReplicationValve.java SimpleTcpCluster.java
Log:
skeleton of delta replication is complete.
Revision Changes Path
1.2 +18 -2 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/ClusterManager.java
Index: ClusterManager.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/ClusterManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClusterManager.java 15 Nov 2003 00:58:20 -0000 1.1
+++ ClusterManager.java 12 Jan 2004 07:50:06 -0000 1.2
@@ -73,6 +73,8 @@
*/
import org.apache.catalina.Manager;
+import org.apache.catalina.cluster.tcp.SimpleTcpCluster;
+
public interface ClusterManager extends Manager {
@@ -103,5 +105,19 @@
* @return
*/
public String[] getInvalidatedSessions();
+
+ /**
+ * Return the name of the manager, typically the context name such as /replicator
+ * @return String
+ */
+ public String getName();
+
+ public void setName(String name);
+
+ public void setExpireSessionsOnShutdown(boolean expireSessionsOnShutdown);
+
+ public void setUseDirtyFlag(boolean useDirtyFlag);
+
+ public void setCluster(SimpleTcpCluster cluster);
}
1.3 +107 -54 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java
Index: DeltaManager.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DeltaManager.java 12 Jan 2004 05:23:10 -0000 1.2
+++ DeltaManager.java 12 Jan 2004 07:50:06 -0000 1.3
@@ -174,10 +174,12 @@
private SimpleTcpCluster cluster = null;
private boolean stateTransferred;
+ private boolean useDirtyFlag;
+ private boolean expireSessionsOnShutdown;
+ private boolean printToScreen;
// ------------------------------------------------------------- Constructor
- public DeltaManager(SimpleTcpCluster cluster) {
+ public DeltaManager() {
super();
- this.cluster = cluster;
}
// ------------------------------------------------------------- Properties
@@ -350,13 +352,7 @@
}
// Recycle or create a Session instance
- Session session = getNewDeltaSession();
-
- // Initialize the properties of the new session and return it
- session.setNew(true);
- session.setValid(true);
- session.setCreationTime(System.currentTimeMillis());
- session.setMaxInactiveInterval(this.maxInactiveInterval);
+ DeltaSession session = getNewDeltaSession();
String sessionId = generateSessionId();
String jvmRoute = getJvmRoute();
@@ -376,7 +372,16 @@
}
session.setId(sessionId);
+ session.resetDeltaRequest();
+ // Initialize the properties of the new session and return it
+ session.setNew(true);
+ session.setValid(true);
+ session.setCreationTime(System.currentTimeMillis());
+ session.setMaxInactiveInterval(this.maxInactiveInterval);
+
sessionCounter++;
+
+
if ( distribute ) {
SessionMessage msg = new SessionMessage(
getName(),
@@ -384,8 +389,9 @@
null,
sessionId);
cluster.send(msg);
+ session.resetDeltaRequest();
}
-
+
return (session);
}
@@ -400,7 +406,28 @@
}
-
+ private DeltaRequest loadDeltaRequest(byte[] data) throws
+ ClassNotFoundException, IOException {
+ ByteArrayInputStream fis = null;
+ ReplicationStream ois = null;
+ Loader loader = null;
+ ClassLoader classLoader = null;
+ fis = new ByteArrayInputStream(data);
+ BufferedInputStream bis = new BufferedInputStream(fis);
+ ois = new ReplicationStream(fis,container.getLoader().getClassLoader());
+ DeltaRequest dreq = (DeltaRequest)ois.readObject();
+ ois.close();
+ return dreq;
+ }
+
+ private byte[] unloadDeltaRequest(DeltaRequest deltaRequest) throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ oos.writeObject(deltaRequest);
+ oos.flush();
+ oos.close();
+ return bos.toByteArray();
+ }
/**
* Load any currently active sessions that were previously unloaded
* to the appropriate persistence mechanism, if any. If persistence is not
@@ -617,11 +644,7 @@
started = true;
// Force initialization of the random number generator
- if (log.isDebugEnabled())
- log.debug("Force random number initialization starting");
String dummy = generateSessionId();
- if (log.isDebugEnabled())
- log.debug("Force random number initialization completed");
// Load unloaded sessions, if any
try {
@@ -748,7 +771,7 @@
* @param msg - the message received.
*/
public void messageDataReceived(SessionMessage msg) {
-
+ messageReceived(msg, msg.getAddress()!=null?(Member)msg.getAddress():null);
}
/**
@@ -762,9 +785,32 @@
* @return a SessionMessage to be sent,
*/
public SessionMessage requestCompleted(String sessionId) {
- return null;
+ try {
+ DeltaSession session = (DeltaSession) findSession(sessionId);
+ DeltaRequest deltaRequest = session.getDeltaRequest();
+ SessionMessage msg = null;
+ if (deltaRequest.getSize() > 0) {
+
+ byte[] data = unloadDeltaRequest(deltaRequest);
+ msg = new SessionMessage(name, SessionMessage.EVT_SESSION_DELTA,
+ data, sessionId);
+ session.resetDeltaRequest();
+ } else if ( !session.isPrimarySession() ) {
+ msg = new SessionMessage(getName(),
+ SessionMessage.EVT_SESSION_ACCESSED,
+ null,
+ sessionId);
+ }
+ session.setPrimarySession(true);
+ return msg;
+ }
+ catch (IOException x) {
+ log.error("Unable to serialize delta request", x);
+ return null;
+ }
+
}
-
+
/**
* When the manager expires session not tied to a request.
* The cluster will periodically ask for a list of sessions
@@ -772,7 +818,7 @@
* @return
*/
public String[] getInvalidatedSessions() {
- return null;
+ return new String[0];
}
@@ -790,22 +836,7 @@
switch (msg.getEventType()) {
case SessionMessage.EVT_GET_ALL_SESSIONS: {
//get a list of all the session from this manager
- Object[] sessions = findSessions();
- java.io.ByteArrayOutputStream bout = new java.io.
- ByteArrayOutputStream();
- java.io.ObjectOutputStream oout = new java.io.
- ObjectOutputStream(bout);
- oout.writeInt(sessions.length);
- for (int i = 0; i < sessions.length; i++) {
- ReplicatedSession ses = (ReplicatedSession) sessions[i];
- oout.writeUTF(ses.getId());
- byte[] data = null;//todo writeSession(ses);
- oout.writeObject(data);
- } //for
- //don't send a message if we don't have to
- oout.flush();
- oout.close();
- byte[] data = bout.toByteArray();
+ byte[] data = doUnload();
SessionMessage newmsg = new SessionMessage(name,
SessionMessage.EVT_ALL_SESSION_DATA,
data, "");
@@ -813,26 +844,17 @@
break;
}
case SessionMessage.EVT_ALL_SESSION_DATA: {
- java.io.ByteArrayInputStream bin =
- new java.io.ByteArrayInputStream(msg.getSession());
- java.io.ObjectInputStream oin = new java.io.
- ObjectInputStream(bin);
- int size = oin.readInt();
- for (int i = 0; i < size; i++) {
- String id = oin.readUTF();
- byte[] data = (byte[]) oin.readObject();
- Session session = null; //todo readSession(data, id);
- session.setManager(this);
- add(session);
- } //for
+ byte[] data = msg.getSession();
+ doLoad(data);
stateTransferred = true;
break;
}
case SessionMessage.EVT_SESSION_CREATED: {
- Session session = createSession(false);
- session.setManager(this);
+ DeltaSession session = (DeltaSession)createSession(false);
session.setId(msg.getSessionID());
session.setNew(false);
+ session.setPrimarySession(false);
+ session.resetDeltaRequest();
break;
}
case SessionMessage.EVT_SESSION_EXPIRED: {
@@ -844,12 +866,22 @@
break;
}
case SessionMessage.EVT_SESSION_ACCESSED: {
- Session session = findSession(msg.getSessionID());
+ DeltaSession session = (DeltaSession)findSession(msg.getSessionID());
if (session != null) {
session.access();
+ session.setPrimarySession(false);
}
break;
}
+ case SessionMessage.EVT_SESSION_DELTA : {
+ byte[] delta = msg.getSession();
+ DeltaRequest dreq = loadDeltaRequest(delta);
+ DeltaSession session = (DeltaSession)findSession(msg.getSessionID());
+ dreq.execute(session);
+ session.setPrimarySession(false);
+
+ break;
+ }
default: {
//we didn't recognize the message type, do nothing
break;
@@ -911,6 +943,27 @@
public void unload() {
+ }
+ public boolean getUseDirtyFlag() {
+ return useDirtyFlag;
+ }
+ public void setUseDirtyFlag(boolean useDirtyFlag) {
+ this.useDirtyFlag = useDirtyFlag;
+ }
+ public boolean getExpireSessionsOnShutdown() {
+ return expireSessionsOnShutdown;
+ }
+ public void setExpireSessionsOnShutdown(boolean expireSessionsOnShutdown) {
+ this.expireSessionsOnShutdown = expireSessionsOnShutdown;
+ }
+ public boolean getPrintToScreen() {
+ return printToScreen;
+ }
+ public void setPrintToScreen(boolean printToScreen) {
+ this.printToScreen = printToScreen;
+ }
+ public void setName(String name) {
+ this.name = name;
}
1.2 +19 -4 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java
Index: DeltaRequest.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaRequest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeltaRequest.java 12 Jan 2004 05:23:10 -0000 1.1
+++ DeltaRequest.java 12 Jan 2004 07:50:06 -0000 1.2
@@ -98,8 +98,8 @@
private boolean recordAllActions = false;
public DeltaRequest(String sessionId, boolean recordAllActions) {
- this.sessionId = sessionId;
- this.recordAllActions = recordAllActions;
+ this.recordAllActions=recordAllActions;
+ setSessionId(sessionId);
}
@@ -179,6 +179,21 @@
}//for
}
+ public void reset() {
+ actions.clear();
+ }
+ public String getSessionId() {
+ return sessionId;
+ }
+ public void setSessionId(String sessionId) {
+ this.sessionId = sessionId;
+ if ( sessionId == null ) {
+ new Exception("Session Id is null for setSessionId").fillInStackTrace().printStackTrace();
+ }
+ }
+ public int getSize() {
+ return actions.size();
+ }
public static class AttributeInfo implements java.io.Serializable {
private String name = null;
1.6 +50 -57 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java
Index: DeltaSession.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/DeltaSession.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DeltaSession.java 12 Jan 2004 05:23:10 -0000 1.5
+++ DeltaSession.java 12 Jan 2004 07:50:06 -0000 1.6
@@ -129,6 +129,9 @@
implements HttpSession, Session, Serializable,
ClusterSession {
+ public static org.apache.commons.logging.Log log =
+ org.apache.commons.logging.LogFactory.getLog( DeltaManager.class );
+
// ----------------------------------------------------------- Constructors
@@ -321,7 +324,13 @@
* made a request on another server.
*/
private transient boolean isPrimarySession = true;
-
+
+ /**
+ * The delta request contains all the action info
+ *
+ */
+ private transient DeltaRequest deltaRequest = null;
+
// ----------------------------------------------------- Session Properties
/**
@@ -447,7 +456,7 @@
;
}
// FIXME - should we do anything besides log these?
- log(sm.getString("standardSession.sessionEvent"), t);
+ log.error(sm.getString("standardSession.sessionEvent"), t);
}
}
}
@@ -530,6 +539,8 @@
this.maxInactiveInterval = interval;
if (isValid && interval == 0) {
expire();
+ } else {
+ deltaRequest.setMaxInactiveInterval(interval);
}
}
@@ -541,9 +552,8 @@
* @param isNew The new value for the <code>isNew</code> flag
*/
public void setNew(boolean isNew) {
-
this.isNew = isNew;
-
+ deltaRequest.setNew(isNew);
}
@@ -574,7 +584,7 @@
Principal oldPrincipal = this.principal;
this.principal = principal;
support.firePropertyChange("principal", oldPrincipal, this.principal);
-
+ deltaRequest.setPrincipal(principal);
}
@@ -605,7 +615,7 @@
* Return the <code>isValid</code> flag for this session.
*/
public boolean isValid() {
-
+
if (this.expiring){
return true;
}
@@ -617,7 +627,7 @@
if (maxInactiveInterval >= 0) {
long timeNow = System.currentTimeMillis();
int timeIdle = (int) ((timeNow - lastAccessedTime) / 1000L);
- if (timeIdle >= maxInactiveInterval) {
+ if ( (timeIdle >= maxInactiveInterval) && (isPrimarySession()) ) {
expire(true);
}
}
@@ -728,7 +738,7 @@
;
}
// FIXME - should we do anything besides log these?
- log(sm.getString("standardSession.sessionEvent"), t);
+ log.error(sm.getString("standardSession.sessionEvent"), t);
}
}
}
@@ -900,6 +910,15 @@
writeObject(stream);
}
+
+ public void resetDeltaRequest() {
+ if ( deltaRequest == null ) {
+ deltaRequest = new DeltaRequest(getId(),false);
+ } else {
+ deltaRequest.reset();
+ deltaRequest.setSessionId(getId());
+ }
+ }
// ------------------------------------------------- HttpSession Properties
@@ -1161,6 +1180,8 @@
return;
}
}
+
+ deltaRequest.removeAttribute(name);
// Do we need to do valueUnbound() and attributeRemoved() notification?
if (!notify) {
@@ -1201,7 +1222,7 @@
;
}
// FIXME - should we do anything besides log these?
- log(sm.getString("standardSession.attributeEvent"), t);
+ log.error(sm.getString("standardSession.attributeEvent"), t);
}
}
@@ -1265,6 +1286,8 @@
if ( ! (value instanceof java.io.Serializable) ) {
throw new IllegalArgumentException("Attribute ["+name+"] is not serializable");
}
+
+ deltaRequest.setAttribute(name,value);
// Validate our current state
if (!isValid())
@@ -1343,7 +1366,7 @@
;
}
// FIXME - should we do anything besides log these?
- log(sm.getString("standardSession.attributeEvent"), t);
+ log.error(sm.getString("standardSession.attributeEvent"), t);
}
}
@@ -1379,8 +1402,8 @@
principal = null; // Transient only
// setId((String) stream.readObject());
id = (String) stream.readObject();
- if (debug >= 2)
- log("readObject() loading session " + id);
+ if (log.isDebugEnabled())
+ log.debug("readObject() loading session " + id);
// Deserialize the attribute count and attribute values
if (attributes == null)
@@ -1393,8 +1416,8 @@
Object value = (Object) stream.readObject();
if ((value instanceof String) && (value.equals(NOT_SERIALIZED)))
continue;
- if (debug >= 2)
- log(" loading attribute '" + name +
+ if (log.isDebugEnabled())
+ log.debug(" loading attribute '" + name +
"' with value '" + value + "'");
synchronized (attributes) {
attributes.put(name, value);
@@ -1434,8 +1457,8 @@
stream.writeObject(new Boolean(isValid));
stream.writeObject(new Long(thisAccessedTime));
stream.writeObject(id);
- if (debug >= 2)
- log("writeObject() storing session " + id);
+ if (log.isDebugEnabled())
+ log.debug("writeObject() storing session " + id);
// Accumulate the names of serializable and non-serializable attributes
String keys[] = keys();
@@ -1461,15 +1484,14 @@
stream.writeObject((String) saveNames.get(i));
try {
stream.writeObject(saveValues.get(i));
- if (debug >= 2)
- log(" storing attribute '" + saveNames.get(i) +
+ if (log.isDebugEnabled())
+ log.debug(" storing attribute '" + saveNames.get(i) +
"' with value '" + saveValues.get(i) + "'");
} catch (NotSerializableException e) {
- log(sm.getString("standardSession.notSerializable",
+ log.error(sm.getString("standardSession.notSerializable",
saveNames.get(i), id), e);
stream.writeObject(NOT_SERIALIZED);
- if (debug >= 2)
- log(" storing attribute '" + saveNames.get(i) +
+ log.error(" storing attribute '" + saveNames.get(i) +
"' with value NOT_SERIALIZED");
}
}
@@ -1489,7 +1511,7 @@
try {
expire();
} catch (Throwable t) {
- log(sm.getString("standardSession.expireException"), t);
+ log.error(sm.getString("standardSession.expireException"), t);
}
}
@@ -1583,37 +1605,8 @@
}
- /**
- * Log a message on the Logger associated with our Manager (if any).
- *
- * @param message Message to be logged
- */
- protected void log(String message) {
-
- //if ((manager != null) && (manager instanceof ManagerBase)) {
- //noop, implement proper logging
- //} else {
- System.out.println("DeltaSession: " + message);
- //}
-
- }
-
-
- /**
- * Log a message on the Logger associated with our Manager (if any).
- *
- * @param message Message to be logged
- * @param throwable Associated exception
- */
- protected void log(String message, Throwable throwable) {
-
- //if ((manager != null) && (manager instanceof ManagerBase)) {
- // ((ManagerBase) manager).log(message, throwable);
- //} else {
- System.out.println("DeltaSession: " + message);
- throwable.printStackTrace(System.out);
- //}
-
+ public DeltaRequest getDeltaRequest() {
+ return deltaRequest;
}
1.20 +7 -5 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java
Index: SimpleTcpReplicationManager.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- SimpleTcpReplicationManager.java 12 Jan 2004 05:23:10 -0000 1.19
+++ SimpleTcpReplicationManager.java 12 Jan 2004 07:50:06 -0000 1.20
@@ -160,10 +160,9 @@
* Constructor, just calls super()
*
*/
- public SimpleTcpReplicationManager(String name)
+ public SimpleTcpReplicationManager()
{
super();
- this.name = name;
}
@@ -674,5 +673,8 @@
}
SimpleTcpCluster.log.error(lmsg,x);
}//end if
+ }
+ public void setName(String name) {
+ this.name = name;
}
}
1.8 +18 -44 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationValve.java
Index: ReplicationValve.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationValve.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ReplicationValve.java 12 Jan 2004 05:23:11 -0000 1.7
+++ ReplicationValve.java 12 Jan 2004 07:50:07 -0000 1.8
@@ -88,10 +88,10 @@
import org.apache.catalina.ValveContext;
import org.apache.catalina.util.StringManager;
import org.apache.catalina.valves.*;
-import org.apache.catalina.cluster.session.SimpleTcpReplicationManager;
import org.apache.catalina.cluster.SessionMessage;
import org.apache.catalina.cluster.tcp.SimpleTcpCluster;
import org.apache.catalina.cluster.ClusterSession;
+import org.apache.catalina.cluster.ClusterManager;
/**
* <p>Implementation of a Valve that logs interesting contents from the
@@ -187,10 +187,13 @@
HttpRequest hrequest = (HttpRequest) request;
HttpServletRequest hreq = (HttpServletRequest) hrequest.getRequest();
HttpSession session = hreq.getSession(false);
- SimpleTcpReplicationManager manager = (SimpleTcpReplicationManager)request.getContext().getManager();
+
+ if (!( request.getContext().getManager() instanceof ClusterManager) ) return;
+
+ ClusterManager manager = (ClusterManager)request.getContext().getManager();
SimpleTcpCluster cluster = (SimpleTcpCluster)getContainer().getCluster();
if ( cluster == null ) {
- log("No cluster configured for this request.",2);
+ log.warn("No cluster configured for this request.");
return;
}
//first check for session invalidations
@@ -203,7 +206,7 @@
if (imsg != null)
cluster.send(imsg);
}catch ( Exception x ) {
- log("Unable to send session invalid message over cluster.",x,2);
+ log.error("Unable to send session invalid message over cluster.",x);
}
}
}
@@ -218,7 +221,7 @@
return;
if ( (request.getContext().getManager()==null) ||
- (!(request.getContext().getManager() instanceof SimpleTcpReplicationManager)))
+ (!(request.getContext().getManager() instanceof ClusterManager)))
return;
@@ -234,17 +237,10 @@
if ( filterfound )
return;
- if ( debug > 4 ) log("Invoking replication request on "+uri,4);
+ log.debug("Invoking replication request on "+uri);
- ClusterSession cs = (ClusterSession)session;
+
SessionMessage msg = manager.requestCompleted(id);
- if ( (msg == null) && (!cs.isPrimarySession()) ) {
- msg = new SessionMessage(manager.getName(),
- SessionMessage.EVT_SESSION_ACCESSED,
- null,
- id);
- }
- cs.setPrimarySession(true);
if ( msg == null ) return;
@@ -254,7 +250,7 @@
}catch (Exception x)
{
- log("Unable to perform replication request.",x,2);
+ log.error("Unable to perform replication request.",x);
}
}
@@ -274,20 +270,20 @@
public void setFilter(String filter)
{
- log("Loading request filters="+filter,3);
+ log.debug("Loading request filters="+filter);
java.util.StringTokenizer t = new java.util.StringTokenizer(filter,";");
this.reqFilters = new java.util.regex.Pattern[t.countTokens()];
int i = 0;
while ( t.hasMoreTokens() )
{
String s = t.nextToken();
- log("Request filter="+s,3);
+ log.debug("Request filter="+s);
try
{
reqFilters[i++] = java.util.regex.Pattern.compile(s);
}catch ( Exception x )
{
- log("Unable to compile filter "+s,x,3);
+ log.error("Unable to compile filter "+s,x);
}
}
}
@@ -299,28 +295,6 @@
// ------------------------------------------------------ Protected Methods
-
- /**
- * Log a message on the Logger associated with our Container (if any).
- *
- * @param message Message to be logged
- */
- protected void log(String message,int level) {
- if ( debug < level ) return;
- log.debug(message);
- }
-
-
- /**
- * Log a message on the Logger associated with our Container (if any).
- *
- * @param message Message to be logged
- * @param throwable Associated exception
- */
- protected void log(String message, Throwable throwable,int level) {
- if ( debug < level ) return;
- log.debug(message,throwable);
- }
}
1.24 +19 -8 jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
Index: SimpleTcpCluster.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- SimpleTcpCluster.java 9 Jan 2004 23:24:09 -0000 1.23
+++ SimpleTcpCluster.java 12 Jan 2004 07:50:07 -0000 1.24
@@ -97,7 +97,6 @@
import org.apache.catalina.cluster.SessionMessage;
import org.apache.catalina.cluster.session.ReplicationStream;
import org.apache.catalina.cluster.ClusterManager;
-import org.apache.catalina.cluster.session.SimpleTcpReplicationManager;
import org.apache.catalina.cluster.Constants;
import org.apache.commons.logging.Log;
@@ -273,6 +272,7 @@
private long msgSendTime = 0;
private long lastChecked = System.currentTimeMillis();
private boolean isJdk13 = false;
+ private String managerClassName = "org.apache.catalina.cluster.session.SimpleTcpReplicationManager";
// ------------------------------------------------------------- Properties
@@ -410,13 +410,18 @@
public synchronized Manager createManager(String name) {
- SimpleTcpReplicationManager manager = new SimpleTcpReplicationManager(name);
+ ClusterManager manager = null;
+ try {
+ manager = (ClusterManager)getClass().getClassLoader().loadClass(getManagerClassName()).newInstance();
+ } catch ( Exception x ) {
+ log.error("Unable to load class for replication manager",x);
+ manager = new org.apache.catalina.cluster.session.SimpleTcpReplicationManager();
+ }
+ manager.setName(name);
manager.setCluster(this);
manager.setDistributable(true);
manager.setExpireSessionsOnShutdown(expireSessionsOnShutdown);
- manager.setPrintToScreen(printToScreen);
manager.setUseDirtyFlag(useDirtyFlag);
- manager.setDebug(debug);
allmanagers.put(name, manager);
managers.put(name,manager);
return manager;
@@ -812,6 +817,12 @@
}
public void setIsJdk13(boolean isJdk13) {
this.isJdk13 = isJdk13;
+ }
+ public String getManagerClassName() {
+ return managerClassName;
+ }
+ public void setManagerClassName(String managerClassName) {
+ this.managerClassName = managerClassName;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
Found and fixed 2 bugs in mod_jk2 using REX in uri
Posted by Max Masetti <ma...@bolbusiness.it>.
hi,
as I asked for help to this list to configure and use regular expressions
into uri in mod_jk2, I found and resolved some bugs in the code. I think its
nice to send you (I don't know exactly who can evalauate and accept my
suggestions).
The bugs are 2.
1. Cant't use metacharacter ']' in rex because this char is used to
terminate the [uri:...] declaration.
2. Can't use rex in uri without prepending a host, it cause a segmentation
fault.
The solution I found:
1.
Change the file <jk2-src>/jk/native2/common/jk_config_file.c
187 /* Support windows-style 'sections' - for cleaner config
188 */
189 if( (prp[0] == '[') ) {
190 #ifdef HAS_PCRE
191 v=strrchr(prp, ']' );
192 #else
193 v=strchr(prp, ']' );
194 #endif
195 *v='\0';
196 jk2_trim( v );
197 prp++;
2.
Change file <jk2-src>/jk/native2/common/jk_uriEnv.c near line 91 adding
if (*name == '$') {
++name;
uriEnv->match_type = MATCH_TYPE_REGEXP;
#ifdef HAS_PCRE
uriEnv->uri = uriEnv->pool->pstrdup(env, uriEnv->pool, name);
env->l->jkLog(env, env->l, JK_LOG_INFO,
"uriEnv.parseName() parsing %s regexp\n", name);
{
int errcode;
regex_t *preg = (regex_t *)uriEnv->pool->calloc( env,
uriEnv->pool, sizeof(regex_t));
if( errcode = regcomp(preg, uriEnv->name, REG_EXTENDED) ) {
char errbuf[1024];
env->l->jkLog(env, env->l, JK_LOG_DEBUG,
"uriEnv.parseName() error #%d compiling regexp
%s\n",
errcode, name);
return JK_ERR;
}
uriEnv->regexp = preg;
uriEnv->virtual = "*";
}
#else
env->l->jkLog(env, env->l, JK_LOG_INFO,
"uriEnv.parseName() parsing regexp %s not supported\n", name);
#endif
return JK_OK;
}
--------------------------------------
Hope this could help someone. For any more info feel free to contact me.
by
max
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org