Author: fhanik Date: Wed Feb 15 10:30:02 2006 New Revision: 378050 URL: http://svn.apache.org/viewcvs?rev=378050&view=rev Log: Refactor: ClusterListener is not the same as MessageListener The ClusterListener is a listener that is added to the Cluster element. A MessageListener is solely a listener for messages on a replication channel
Added: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/CatalinaCluster.java tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterChannel.java tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterDeployer.java tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MessageListener.java tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterListener.java tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/CatalinaCluster.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/CatalinaCluster.java?rev=378050&r1=378049&r2=378050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/CatalinaCluster.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/CatalinaCluster.java Wed Feb 15 10:30:02 2006 @@ -23,6 +23,7 @@ import org.apache.catalina.Manager; import org.apache.catalina.Valve; import org.apache.commons.logging.Log; +import org.apache.catalina.cluster.session.ClusterListener; /** * A <b>CatalinaCluster</b> interface allows to plug in and out the @@ -120,9 +121,9 @@ public void addValve(Valve valve); - public void addClusterListener(MessageListener listener); + public void addClusterListener(ClusterListener listener); - public void removeClusterListener(MessageListener listener); + public void removeClusterListener(ClusterListener listener); public void setClusterDeployer(ClusterDeployer deployer); Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterChannel.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterChannel.java?rev=378050&r1=378049&r2=378050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterChannel.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterChannel.java Wed Feb 15 10:30:02 2006 @@ -51,10 +51,10 @@ * The svc parameter can be the logical or value of any constants * @param svc int value of <BR> * DEFAULT - will shutdown all services <BR> - * MBR_RX_SEQ - starts the membership receiver <BR> - * MBR_TX_SEQ - starts the membership broadcaster <BR> - * SND_TX_SEQ - starts the replication transmitter<BR> - * SND_RX_SEQ - starts the replication receiver<BR> + * MBR_RX_SEQ - stops the membership receiver <BR> + * MBR_TX_SEQ - stops the membership broadcaster <BR> + * SND_TX_SEQ - stops the replication transmitter<BR> + * SND_RX_SEQ - stops the replication receiver<BR> * @throws ChannelException if a startup error occurs or the service is already started. */ public void stop(int svc) throws ChannelException; Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterDeployer.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterDeployer.java?rev=378050&r1=378049&r2=378050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterDeployer.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/ClusterDeployer.java Wed Feb 15 10:30:02 2006 @@ -103,4 +103,17 @@ * call from container Background Process */ public void backgroundProcess(); + + /** + * Returns the cluster the cluster deployer is associated with + * @return CatalinaCluster + */ + public CatalinaCluster getCluster(); + + /** + * Associates the cluster deployer with a cluster + * @param cluster CatalinaCluster + */ + public void setCluster(CatalinaCluster cluster); + } Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MessageListener.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MessageListener.java?rev=378050&r1=378049&r2=378050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MessageListener.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/MessageListener.java Wed Feb 15 10:30:02 2006 @@ -24,18 +24,5 @@ public boolean equals(Object listener); public int hashCode(); - - /** - * Returns the cluster the cluster deployer is associated with - * @return CatalinaCluster - */ - public CatalinaCluster getCluster(); - - /** - * Associates the cluster deployer with a cluster - * @param cluster CatalinaCluster - */ - public void setCluster(CatalinaCluster cluster); - } Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java?rev=378050&r1=378049&r2=378050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/deploy/FarmWarDeployer.java Wed Feb 15 10:30:02 2006 @@ -34,6 +34,7 @@ import org.apache.catalina.cluster.ClusterMessage; import org.apache.catalina.cluster.Member; import org.apache.commons.modeler.Registry; +import org.apache.catalina.cluster.session.ClusterListener; /** * <p> @@ -54,7 +55,7 @@ * @author Peter Rossbach * @version 1.1 */ -public class FarmWarDeployer implements ClusterDeployer, FileChangeListener { +public class FarmWarDeployer extends ClusterListener implements ClusterDeployer, FileChangeListener { /*--Static Variables----------------------------------------*/ public static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory .getLog(FarmWarDeployer.class); Added: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java?rev=378050&view=auto ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java (added) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java Wed Feb 15 10:30:02 2006 @@ -0,0 +1,30 @@ +/* + * Copyright 1999,2004-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.cluster.group; + +/** + * The channel coordinator object coordinates the membership service, + * the sender and the receiver. + * This is the last interceptor in the chain. + * @author Filip Hanik + * @version $Revision: 304032 $, $Date: 2005-07-27 10:11:55 -0500 (Wed, 27 Jul 2005) $ + */ +public class ChannelCoordinator extends ChannelInterceptorBase { + public ChannelCoordinator() { + super(); + } + +} Added: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java?rev=378050&view=auto ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java (added) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java Wed Feb 15 10:30:02 2006 @@ -0,0 +1,86 @@ +/* + * Copyright 1999,2004-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.catalina.cluster.group; + +import org.apache.catalina.cluster.ClusterMessage; +import org.apache.catalina.cluster.Member; +import org.apache.catalina.cluster.MembershipListener; +import org.apache.catalina.cluster.MessageListener; + +/** + * Abstract class for the interceptor base class. + * @author Filip Hanik + * @version $Revision: 304032 $, $Date: 2005-07-27 10:11:55 -0500 (Wed, 27 Jul 2005) $ + */ + +public abstract class ChannelInterceptorBase implements MembershipListener, MessageListener { + + private ChannelInterceptorBase next; + private ChannelInterceptorBase previous; + + public ChannelInterceptorBase() { + + } + + protected final void setNext(ChannelInterceptorBase next) { + this.next = next; + } + + public final ChannelInterceptorBase getNext() { + return next; + } + + protected final void setPrevious(ChannelInterceptorBase previous) { + this.previous = previous; + } + + public final ChannelInterceptorBase getPrevious() { + return previous; + } + + public ClusterMessage[] sendMessage(Member[] destination, ClusterMessage msg, int options) { + return getNext().sendMessage(destination, msg,options); + } + + public void messageReceived(ClusterMessage msg) { + getPrevious().messageReceived(msg); + } + + public boolean accept(ClusterMessage msg) { + return true; + } + + + public void memberAdded(Member member) { + //notify upwards + getPrevious().memberAdded(member); + } + + public void memberDisappeared(Member member) { + //notify upwards + getPrevious().memberDisappeared(member); + } + + + + + + + + + + +} Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterListener.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterListener.java?rev=378050&r1=378049&r2=378050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterListener.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/ClusterListener.java Wed Feb 15 10:30:02 2006 @@ -30,8 +30,7 @@ */ public abstract class ClusterListener implements MessageListener { - public static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory - .getLog(ClusterListener.class); + public static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ClusterListener.class); //--Instance Variables-------------------------------------- Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java?rev=378050&r1=378049&r2=378050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/session/JvmRouteSessionIDBinderLifecycleListener.java Wed Feb 15 10:30:02 2006 @@ -25,7 +25,7 @@ import org.apache.catalina.LifecycleEvent; import org.apache.catalina.LifecycleListener; import org.apache.catalina.cluster.CatalinaCluster; -import org.apache.catalina.cluster.MessageListener; + import org.apache.catalina.core.StandardHost; import org.apache.catalina.util.StringManager; import org.apache.commons.logging.Log; @@ -70,7 +70,7 @@ private Registry registry = null; - private MessageListener sessionMoverListener; + private ClusterListener sessionMoverListener; /* * start and stop cluster Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java?rev=378050&r1=378049&r2=378050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java Wed Feb 15 10:30:02 2006 @@ -50,7 +50,7 @@ import org.apache.catalina.cluster.Member; import org.apache.catalina.cluster.MembershipListener; import org.apache.catalina.cluster.MembershipService; -import org.apache.catalina.cluster.MessageListener; +import org.apache.catalina.cluster.session.ClusterListener; import org.apache.catalina.cluster.mcast.McastService; import org.apache.catalina.cluster.session.ClusterSessionListener; import org.apache.catalina.cluster.session.DeltaManager; @@ -357,14 +357,13 @@ * Get the cluster listeners associated with this cluster. If this Array has * no listeners registered, a zero-length array is returned. */ - public MessageListener[] findClusterListeners() { + public ClusterListener[] findClusterListeners() { if (clusterListeners.size() > 0) { - MessageListener[] listener = new MessageListener[clusterListeners - .size()]; + ClusterListener[] listener = new ClusterListener[clusterListeners.size()]; clusterListeners.toArray(listener); return listener; } else - return new MessageListener[0]; + return new ClusterListener[0]; } @@ -373,7 +372,7 @@ * * @see org.apache.catalina.cluster.CatalinaCluster#addClusterListener(org.apache.catalina.cluster.MessageListener) */ - public void addClusterListener(MessageListener listener) { + public void addClusterListener(ClusterListener listener) { if (listener != null && !clusterListeners.contains(listener)) { clusterListeners.add(listener); listener.setCluster(this); @@ -385,7 +384,7 @@ * * @see org.apache.catalina.cluster.CatalinaCluster#removeClusterListener(org.apache.catalina.cluster.MessageListener) */ - public void removeClusterListener(MessageListener listener) { + public void removeClusterListener(ClusterListener listener) { if (listener != null) { clusterListeners.remove(listener); listener.setCluster(null); @@ -1160,7 +1159,7 @@ boolean accepted = false; if (message != null) { for (Iterator iter = clusterListeners.iterator(); iter.hasNext();) { - MessageListener listener = (MessageListener) iter.next(); + ClusterListener listener = (ClusterListener) iter.next(); if (listener.accept(message)) { accepted = true; listener.messageReceived(message); Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java?rev=378050&r1=378049&r2=378050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java Wed Feb 15 10:30:02 2006 @@ -140,6 +140,7 @@ if (log.isTraceEnabled()) { log.trace("sending " + pkgcnt + " ack packages to " + channel.socket().getLocalPort() ); } + if (sendAck) { while ( pkgcnt > 0 ) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]