Author: rjung Date: Wed Sep 9 09:50:13 2009 New Revision: 812861 URL: http://svn.apache.org/viewvc?rev=812861&view=rev Log: Introduce base class for cluster messages and make all cluster message classes extending the base class.
Backport from TC6.0.x. Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/authenticator/SingleSignOnMessage.java tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/deploy/FileMessage.java tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/LocalStrings.properties tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/LocalStrings_es.properties tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/authenticator/SingleSignOnMessage.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/authenticator/SingleSignOnMessage.java?rev=812861&r1=812860&r2=812861&view=diff ============================================================================== --- tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/authenticator/SingleSignOnMessage.java (original) +++ tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/authenticator/SingleSignOnMessage.java Wed Sep 9 09:50:13 2009 @@ -20,6 +20,7 @@ import java.io.Serializable; import org.apache.catalina.cluster.ClusterMessage; +import org.apache.catalina.cluster.ClusterMessageBase; import org.apache.catalina.cluster.Member; /** @@ -28,7 +29,7 @@ * @author Fabien Carrion */ -public class SingleSignOnMessage implements ClusterMessage, Serializable { +public class SingleSignOnMessage extends ClusterMessageBase implements ClusterMessage, Serializable { public static final int ADD_SESSION = 1; @@ -56,16 +57,6 @@ private String username = null; - private Member address = null; - - private long timestamp = 0; - - private String uniqueId = null; - - private int resend = ClusterMessage.FLAG_DEFAULT; - - private int compress = ClusterMessage.FLAG_DEFAULT; - public SingleSignOnMessage(Member source, String ssoId, String sessionId) { this.address = source; this.ssoId = ssoId; @@ -73,60 +64,21 @@ } /** - * Get the address that this message originated from. This would be set if - * the message was being relayed from a host other than the one that - * originally sent it. - */ - public Member getAddress() { - return address; - } - - /** - * Called by the cluster before sending it to the other nodes. - * - * @param member - * Member - */ - public void setAddress(Member member) { - this.address = member; - } - - /** - * Timestamp message. - * - * @return long - */ - public long getTimestamp() { - return timestamp; - } - - /** - * Called by the cluster before sending out the message. - * - * @param timestamp - * The timestamp - */ - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - /** * Each message must have a unique ID, in case of using async replication, * and a smart queue, this id is used to replace messages not yet sent. * * @return String */ public String getUniqueId() { - if (this.uniqueId != null) - return this.uniqueId; + String uniqueId = super.getUniqueId(); + if (uniqueId != null) + return uniqueId; StringBuffer result = new StringBuffer(getSsoId()); result.append("#-#"); result.append(System.currentTimeMillis()); - return result.toString(); - } - - public void setUniqueId(String uniqueId) { - this.uniqueId = uniqueId; + uniqueId = result.toString(); + setUniqueId(uniqueId); + return uniqueId; } public int getAction() { @@ -185,40 +137,6 @@ this.username = username; } - /** - * @return Returns the compress. - * @since 5.5.10 - */ - public int getCompress() { - return compress; - } - - /** - * @param compress - * The compress to set. - * @since 5.5.10 - */ - public void setCompress(int compress) { - this.compress = compress; - } - - /** - * @return Returns the resend. - * @since 5.5.10 - */ - public int getResend() { - return resend; - } - - /** - * @param resend - * The resend to set. - * @since 5.5.10 - */ - public void setResend(int resend) { - this.resend = resend; - } - // --------------------------------------------------------- Public Methods /** Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/deploy/FileMessage.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/deploy/FileMessage.java?rev=812861&r1=812860&r2=812861&view=diff ============================================================================== --- tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/deploy/FileMessage.java (original) +++ tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/deploy/FileMessage.java Wed Sep 9 09:50:13 2009 @@ -18,6 +18,7 @@ package org.apache.catalina.cluster.deploy; import org.apache.catalina.cluster.ClusterMessage; +import org.apache.catalina.cluster.ClusterMessageBase; import org.apache.catalina.cluster.Member; import java.io.Serializable; @@ -28,19 +29,15 @@ * @version 1.0 */ -public class FileMessage implements ClusterMessage, Serializable { +public class FileMessage extends ClusterMessageBase implements ClusterMessage, Serializable { private int messageNumber; private byte[] data; private int dataLength; - private org.apache.catalina.cluster.Member address; - private long timestamp; private long totalLength; private long totalNrOfMsgs; private String fileName; private String contextPath; - private int resend = ClusterMessage.FLAG_FORBIDDEN; - private int compress = ClusterMessage.FLAG_DEFAULT ; public FileMessage(Member source, String fileName, @@ -91,12 +88,7 @@ public void setTotalLength(long totalLength) { this.totalLength = totalLength; } - public org.apache.catalina.cluster.Member getAddress() { - return address; - } - public void setAddress(org.apache.catalina.cluster.Member address) { - this.address = address; - } + public String getUniqueId() { StringBuffer result = new StringBuffer(getFileName()); result.append("#-#"); @@ -106,12 +98,6 @@ return result.toString(); } - public long getTimestamp() { - return timestamp; - } - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } public String getFileName() { return fileName; } @@ -122,32 +108,4 @@ return contextPath; } - /** - * @return Returns the compress. - * @since 5.5.10 - */ - public int getCompress() { - return compress; - } - /** - * @param compress The compress to set. - * @since 5.5.10 - */ - public void setCompress(int compress) { - this.compress = compress; - } - /** - * @return Returns the resend. - * @since 5.5.10 - */ - public int getResend() { - return resend; - } - /** - * @param resend The resend to set. - * @since 5.5.10 - */ - public void setResend(int resend) { - this.resend = resend; - } } Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java?rev=812861&r1=812860&r2=812861&view=diff ============================================================================== --- tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java (original) +++ tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/deploy/UndeployMessage.java Wed Sep 9 09:50:13 2009 @@ -18,16 +18,12 @@ package org.apache.catalina.cluster.deploy; import org.apache.catalina.cluster.ClusterMessage; +import org.apache.catalina.cluster.ClusterMessageBase; import org.apache.catalina.cluster.Member; import java.io.Serializable; -public class UndeployMessage implements ClusterMessage,Serializable { - private Member address; - private long timestamp; - private String uniqueId; +public class UndeployMessage extends ClusterMessageBase implements ClusterMessage,Serializable { private String contextPath; private boolean undeploy; - private int resend = ClusterMessage.FLAG_DEFAULT ; - private int compress = ClusterMessage.FLAG_DEFAULT ; public UndeployMessage() {} //for serialization public UndeployMessage(Member address, @@ -36,35 +32,11 @@ String contextPath, boolean undeploy) { this.address = address; - this.timestamp= timestamp; this.undeploy = undeploy; - this.uniqueId = uniqueId; this.undeploy = undeploy; this.contextPath = contextPath; - } - - public Member getAddress() { - return address; - } - - public void setAddress(Member address) { - this.address = address; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getUniqueId() { - return uniqueId; - } - - public void setUniqueId(String uniqueId) { - this.uniqueId = uniqueId; + setUniqueId(uniqueId); + setTimestamp(timestamp); } public String getContextPath() { @@ -82,33 +54,5 @@ public void setUndeploy(boolean undeploy) { this.undeploy = undeploy; } - /** - * @return Returns the compress. - * @since 5.5.10 - */ - public int getCompress() { - return compress; - } - /** - * @param compress The compress to set. - * @since 5.5.10 - */ - public void setCompress(int compress) { - this.compress = compress; - } - /** - * @return Returns the resend. - * @since 5.5.10 - */ - public int getResend() { - return resend; - } - /** - * @param resend The resend to set. - * @since 5.5.10 - */ - public void setResend(int resend) { - this.resend = resend; - } } Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java?rev=812861&r1=812860&r2=812861&view=diff ============================================================================== --- tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java (original) +++ tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteBinderValve.java Wed Sep 9 09:50:13 2009 @@ -135,7 +135,7 @@ */ protected long numberOfSessions = 0; - protected String sessionIdAttribute = "org.apache.catalina.cluster.session.JvmRouteOrignalSessionID"; + protected String sessionIdAttribute = "org.apache.catalina.cluster.session.JvmRouteOriginalSessionID"; /** * The lifecycle event support for this component. @@ -413,7 +413,7 @@ // change if (sessionIdAttribute != null && !"".equals(sessionIdAttribute)) { if (log.isDebugEnabled()) { - log.debug(sm.getString("jvmRoute.set.orignalsessionid",sessionIdAttribute,sessionId)); + log.debug(sm.getString("jvmRoute.set.originalsessionid",sessionIdAttribute,sessionId)); } request.setAttribute(sessionIdAttribute, sessionId); } @@ -433,7 +433,7 @@ protected void sendSessionIDClusterBackup(ClusterManager manager,Request request,String sessionId, String newSessionID) { SessionIDMessage msg = new SessionIDMessage(); - msg.setOrignalSessionID(sessionId); + msg.setOriginalSessionID(sessionId); msg.setBackupSessionID(newSessionID); Context context = request.getContext(); msg.setContextPath(context.getPath()); Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java?rev=812861&r1=812860&r2=812861&view=diff ============================================================================== --- tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java (original) +++ tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderListener.java Wed Sep 9 09:50:13 2009 @@ -113,7 +113,7 @@ if (log.isDebugEnabled()) log.debug(sm.getString( "jvmRoute.receiveMessage.sessionIDChanged", sessionmsg - .getOrignalSessionID(), sessionmsg + .getOriginalSessionID(), sessionmsg .getBackupSessionID(), sessionmsg .getContextPath())); Container container = getCluster().getContainer(); @@ -129,12 +129,12 @@ if (context != null) { try { Session session = context.getManager().findSession( - sessionmsg.getOrignalSessionID()); + sessionmsg.getOriginalSessionID()); if (session != null) { session.setId(sessionmsg.getBackupSessionID()); } else if (log.isInfoEnabled()) log.info(sm.getString("jvmRoute.lostSession", - sessionmsg.getOrignalSessionID(), + sessionmsg.getOriginalSessionID(), sessionmsg.getContextPath())); } catch (IOException e) { log.error(e); Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/LocalStrings.properties?rev=812861&r1=812860&r2=812861&view=diff ============================================================================== --- tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/LocalStrings.properties (original) +++ tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/LocalStrings.properties Wed Sep 9 09:50:13 2009 @@ -86,7 +86,7 @@ jvmRoute.valve.notStarted=jvmRoute backup sessionID correction run already jvmRoute.valve.started=JvmRouteBinderValve started jvmRoute.valve.stopped=JvmRouteBinderValve stopped -jvmRoute.set.orignalsessionid=Set Orginal Session id at request attriute {0} value: {1} +jvmRoute.set.originalsessionid=Set Orginal Session id at request attriute {0} value: {1} standardSession.notSerializable=Cannot serialize session attribute {0} for session {1} standardSession.removeAttribute.ise=removeAttribute: Session already invalidated standardSession.sessionEvent=Session event listener threw exception Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/LocalStrings_es.properties URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/LocalStrings_es.properties?rev=812861&r1=812860&r2=812861&view=diff ============================================================================== --- tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/LocalStrings_es.properties (original) +++ tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/LocalStrings_es.properties Wed Sep 9 09:50:13 2009 @@ -85,7 +85,7 @@ jvmRoute.valve.notStarted = ya se ha iniciado la correcci\u00F3n de respaldo de sessionID de jvmRoute jvmRoute.valve.started = JvmRouteBinderValve arrancada jvmRoute.valve.stopped = JvmRouteBinderValve parada -jvmRoute.set.orignalsessionid = Puesta id Orginal de Sesi\u00F3n en atributo de requerimiento {0} valor\: {1} +jvmRoute.set.originalsessionid = Puesta id Orginal de Sesi\u00F3n en atributo de requerimiento {0} valor\: {1} standardSession.notSerializable = No puedo serializar atributo de sesi\u00F3n {0} para sesi\u00F3n {1} standardSession.removeAttribute.ise = removeAttribute\: Sesi\u00F3n ya invalidada standardSession.sessionEvent = El oyente de evento de sesi\u00F3n lanz\u00F3 excepci\u00F3n Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java?rev=812861&r1=812860&r2=812861&view=diff ============================================================================== --- tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java (original) +++ tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/SessionIDMessage.java Wed Sep 9 09:50:13 2009 @@ -17,6 +17,7 @@ package org.apache.catalina.cluster.session; import org.apache.catalina.cluster.ClusterMessage; +import org.apache.catalina.cluster.ClusterMessageBase; /** * Session id change cluster message @@ -25,33 +26,19 @@ * * @version $Revision$ $Date$ */ -public class SessionIDMessage implements ClusterMessage { - - private org.apache.catalina.cluster.Member address; +public class SessionIDMessage extends ClusterMessageBase implements ClusterMessage { private int messageNumber; - private long timestamp; - - private String orignalSessionID; + private String originalSessionID; private String backupSessionID; private String host ; private String contextPath; - private int resend = ClusterMessage.FLAG_DEFAULT ; - private int compress = ClusterMessage.FLAG_DEFAULT ; - - public org.apache.catalina.cluster.Member getAddress() { - return address; - } - - public void setAddress(org.apache.catalina.cluster.Member address) { - this.address = address; - } public String getUniqueId() { - StringBuffer result = new StringBuffer(getOrignalSessionID()); + StringBuffer result = new StringBuffer(getOriginalSessionID()); result.append("#-#"); result.append(getHost()); result.append("#-#"); @@ -105,21 +92,6 @@ } /** - * @return Returns the timestamp. - */ - public long getTimestamp() { - return timestamp; - } - - /** - * @param timestamp - * The timestamp to set. - */ - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - /** * @return Returns the backupSessionID. */ public String getBackupSessionID() { @@ -135,49 +107,22 @@ } /** - * @return Returns the orignalSessionID. + * @return Returns the originalSessionID. */ - public String getOrignalSessionID() { - return orignalSessionID; + public String getOriginalSessionID() { + return originalSessionID; } /** - * @param orignalSessionID - * The orignalSessionID to set. + * @param originalSessionID + * The originalSessionID to set. */ - public void setOrignalSessionID(String orignalSessionID) { - this.orignalSessionID = orignalSessionID; + public void setOriginalSessionID(String originalSessionID) { + this.originalSessionID = originalSessionID; } - /** - * @return Returns the compress. - * @since 5.5.10 - */ - public int getCompress() { - return compress; - } - /** - * @param compress The compress to set. - * @since 5.5.10 - */ - public void setCompress(int compress) { - this.compress = compress; - } - /** - * @return Returns the resend. - * @since 5.5.10 - */ - public int getResend() { - return resend; - } - /** - * @param resend The resend to set. - * @since 5.5.10 - */ - public void setResend(int resend) { - this.resend = resend; + public String toString() { + return "SESSIONID-UPDATE#" + getHost() + "." + getContextPath() + "#" + getOriginalSessionID() + ":" + getBackupSessionID(); } - } - Modified: tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java URL: http://svn.apache.org/viewvc/tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java?rev=812861&r1=812860&r2=812861&view=diff ============================================================================== --- tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java (original) +++ tomcat/sandbox/tomcat-oacc/trunk/src/share/org/apache/catalina/cluster/session/SessionMessageImpl.java Wed Sep 9 09:50:13 2009 @@ -17,7 +17,7 @@ package org.apache.catalina.cluster.session; -import org.apache.catalina.cluster.ClusterMessage; +import org.apache.catalina.cluster.ClusterMessageBase; import org.apache.catalina.cluster.Member; /** @@ -28,7 +28,7 @@ * * @version $Revision$ $Date$ */ -public class SessionMessageImpl implements SessionMessage, java.io.Serializable { +public class SessionMessageImpl extends ClusterMessageBase implements SessionMessage, java.io.Serializable { public SessionMessageImpl() { } @@ -41,13 +41,9 @@ private int mEvtType = -1; private byte[] mSession; private String mSessionID; - private Member mSrc; private String mContextName; private long serializationTimestamp; private boolean timestampSet = false ; - private String uniqueId; - private int resend = ClusterMessage.FLAG_DEFAULT ; - private int compress = ClusterMessage.FLAG_DEFAULT ; private SessionMessageImpl( String contextName, @@ -59,7 +55,7 @@ mSession = session; mSessionID = sessionID; mContextName = contextName; - uniqueId = sessionID; + setUniqueId(sessionID); } /** @@ -94,7 +90,7 @@ String uniqueID) { this(contextName,eventtype,session,sessionID); - uniqueId = uniqueID; + setUniqueId(uniqueID); } /** @@ -146,63 +142,8 @@ } } - /** - * Get the address that this message originated from. This would be set - * if the message was being relayed from a host other than the one - * that originally sent it. - */ - public Member getAddress() - { - return this.mSrc; - } - - /** - * Use this method to set the address that this message originated from. - * This can be used when re-sending the EVT_GET_ALL_SESSIONS message to - * another machine in the group. - */ - public void setAddress(Member src) - { - this.mSrc = src; - } - public String getContextName() { return mContextName; } - public String getUniqueId() { - return uniqueId; - } - public void setUniqueId(String uniqueId) { - this.uniqueId = uniqueId; - } - - /** - * @return Returns the compress. - * @since 5.5.10 - */ - public int getCompress() { - return compress; - } - /** - * @param compress The compress to set. - * @since 5.5.10 - */ - public void setCompress(int compress) { - this.compress = compress; - } - /** - * @return Returns the resend. - * @since 5.5.10 - */ - public int getResend() { - return resend; - } - /** - * @param resend The resend to set. - * @since 5.5.10 - */ - public void setResend(int resend) { - this.resend = resend; - } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org