Author: kfujino Date: Wed May 15 05:12:59 2013 New Revision: 1482682 URL: http://svn.apache.org/r1482682 Log: ReplicationValve is instance of ClusterValve. Rather than get cluster instance from container on every request, use instance variable.
Modified: tomcat/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java Modified: tomcat/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java?rev=1482682&r1=1482681&r2=1482682&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java (original) +++ tomcat/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java Wed May 15 05:12:59 2013 @@ -26,7 +26,9 @@ import java.util.regex.PatternSyntaxExce import javax.servlet.ServletException; +import org.apache.catalina.Cluster; import org.apache.catalina.Context; +import org.apache.catalina.LifecycleException; import org.apache.catalina.Manager; import org.apache.catalina.Session; import org.apache.catalina.connector.Request; @@ -317,24 +319,18 @@ public class ReplicationValve crossContextSessions.set(new ArrayList<DeltaSession>()); } getNext().invoke(request, response); - if(context != null) { + if(context != null && cluster != null) { Manager manager = context.getManager(); if (manager != null && manager instanceof ClusterManager) { ClusterManager clusterManager = (ClusterManager) manager; - CatalinaCluster containerCluster = (CatalinaCluster) getContainer().getCluster(); - if (containerCluster == null) { - if (log.isWarnEnabled()) { - log.warn(sm.getString("ReplicationValve.nocluster")); - } - return; - } + // valve cluster can access manager - other cluster handle replication // at host level - hopefully! - if(containerCluster.getManager(clusterManager.getName()) == null) { + if(cluster.getManager(clusterManager.getName()) == null) { return ; } - if(containerCluster.hasMembers()) { - sendReplicationMessage(request, totalstart, isCrossContext, clusterManager, containerCluster); + if(cluster.hasMembers()) { + sendReplicationMessage(request, totalstart, isCrossContext, clusterManager, cluster); } else { resetReplicationRequest(request,isCrossContext); } @@ -368,6 +364,28 @@ public class ReplicationValve nrOfCrossContextSendRequests = 0; } + /** + * Start this component and implement the requirements + * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. + * + * @exception LifecycleException if this component detects a fatal error + * that prevents this component from being used + */ + @Override + protected synchronized void startInternal() throws LifecycleException { + if (cluster == null) { + Cluster containerCluster = getContainer().getCluster(); + if (containerCluster instanceof CatalinaCluster) { + setCluster((CatalinaCluster)containerCluster); + } else { + if (log.isWarnEnabled()) { + log.warn(sm.getString("ReplicationValve.nocluster")); + } + } + } + super.startInternal(); + } + // --------------------------------------------------------- Protected Methods --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org