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 2006/02/24 01:35:02 UTC
svn commit: r380284 - in /tomcat/container/tc5.5.x/modules:
groupcom/src/share/org/apache/catalina/cluster/
groupcom/src/share/org/apache/catalina/cluster/group/
groupcom/src/share/org/apache/catalina/cluster/group/interceptors/
groupcom/src/share/org/...
Author: fhanik
Date: Thu Feb 23 16:34:59 2006
New Revision: 380284
URL: http://svn.apache.org/viewcvs?rev=380284&view=rev
Log:
Implemented a heart beat through the channel
Added:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/interceptors/
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/interceptors/FragmentationInterceptor.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/ClusterManagerBase.java
Removed:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/ReplicationStream.java
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelInterceptor.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSender.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/ReplicationStream.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/XByteBuffer.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelInterceptor.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelInterceptor.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelInterceptor.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ChannelInterceptor.java Thu Feb 23 16:34:59 2006
@@ -38,5 +38,6 @@
public ChannelInterceptor getPrevious();
public ClusterMessage[] sendMessage(Member[] destination, ClusterMessage msg, int options) throws IOException;
-
+
+ public void heartbeat();
}
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSender.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/ClusterSender.java Thu Feb 23 16:34:59 2006
@@ -33,7 +33,7 @@
public void stop();
- public void backgroundProcess() ;
+ public void heartbeat() ;
public void sendMessage(ClusterMessage message, Member member) throws java.io.IOException;
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelCoordinator.java Thu Feb 23 16:34:59 2006
@@ -160,5 +160,10 @@
this.membershipService = membershipService;
this.membershipService.setMembershipListener(this);
}
+
+ public void hearbeat() {
+ if ( clusterSender!=null ) clusterSender.heartbeat();
+ super.heartbeat();
+ }
}
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/ChannelInterceptorBase.java Thu Feb 23 16:34:59 2006
@@ -78,7 +78,9 @@
-
+ public void heartbeat() {
+ if ( getNext() != null ) getNext().heartbeat();
+ }
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/GroupChannel.java Thu Feb 23 16:34:59 2006
@@ -63,7 +63,9 @@
}
}
-
+ public void heartbeat() {
+ getFirstInterceptor().heartbeat();
+ }
/**
* Send a message to one or more members in the cluster
@@ -79,11 +81,15 @@
msg.setTimestamp(System.currentTimeMillis());
msg.setResend(msg.FLAG_FORBIDDEN);
try {
- if (interceptors != null)return interceptors.sendMessage(destination, msg, options);
- else return this.coordinator.sendMessage(destination, msg, options);
+ return getFirstInterceptor().sendMessage(destination, msg, options);
}catch ( Exception x ) {
throw new ChannelException(x);
}
+ }
+
+ public ChannelInterceptor getFirstInterceptor() {
+ if (interceptors != null) return interceptors;
+ else return coordinator;
}
/**
Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/interceptors/FragmentationInterceptor.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/interceptors/FragmentationInterceptor.java?rev=380284&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/interceptors/FragmentationInterceptor.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/group/interceptors/FragmentationInterceptor.java Thu Feb 23 16:34:59 2006
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999,2004 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
+ */
+
+package org.apache.catalina.cluster.group.interceptors;
+
+import org.apache.catalina.cluster.group.ChannelInterceptorBase;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2005</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class FragmentationInterceptor extends ChannelInterceptorBase {
+}
\ No newline at end of file
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/ReplicationStream.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/ReplicationStream.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/ReplicationStream.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/ReplicationStream.java Thu Feb 23 16:34:59 2006
@@ -39,7 +39,7 @@
/**
* The class loader we will use to resolve classes.
*/
- private ClassLoader classLoader = null;
+ private ClassLoader[] classLoaders = null;
/**
* Construct a new instance of CustomObjectInputStream
@@ -50,11 +50,11 @@
* @exception IOException if an input/output error occurs
*/
public ReplicationStream(InputStream stream,
- ClassLoader classLoader)
+ ClassLoader[] classLoaders)
throws IOException {
super(stream);
- this.classLoader = classLoader;
+ this.classLoaders = classLoaders;
}
/**
@@ -92,8 +92,18 @@
}
public Class findExternalClass(String name)
- throws ClassNotFoundException, IOException {
- return Class.forName(name, false, classLoader);
+ throws ClassNotFoundException {
+
+ ClassNotFoundException cnfe = null;
+ for (int i=0; i<classLoaders.length; i++ ) {
+ try {
+ return Class.forName(name, false, classLoaders[i]);
+ } catch ( ClassNotFoundException x ) {
+ cnfe = x;
+ }
+ }
+ if ( cnfe != null ) throw cnfe;
+ else throw new ClassNotFoundException(name);
}
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/XByteBuffer.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/XByteBuffer.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/XByteBuffer.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/io/XByteBuffer.java Thu Feb 23 16:34:59 2006
@@ -374,7 +374,7 @@
} else {
instream = new ByteArrayInputStream(data.getMessage());
}
- ReplicationStream stream = new ReplicationStream(instream,XByteBuffer.class.getClassLoader());
+ ReplicationStream stream = new ReplicationStream(instream,new ClassLoader[] {XByteBuffer.class.getClassLoader()});
message = stream.readObject();
instream.close();
}
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java Thu Feb 23 16:34:59 2006
@@ -495,7 +495,7 @@
*
* @see SimpleTcpCluster#backgroundProcess()
*/
- public void backgroundProcess() {
+ public void heartbeat() {
count = (count + 1) % processSenderFrequency;
if (count == 0) {
checkKeepAlive();
Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java (original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/CatalinaCluster.java Thu Feb 23 16:34:59 2006
@@ -23,6 +23,8 @@
import org.apache.catalina.Manager;
import org.apache.catalina.Valve;
import org.apache.commons.logging.Log;
+import org.apache.catalina.cluster.io.ReplicationStream;
+import java.io.IOException;
Added: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/ClusterManagerBase.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/ClusterManagerBase.java?rev=380284&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/ClusterManagerBase.java (added)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/ClusterManagerBase.java Thu Feb 23 16:34:59 2006
@@ -0,0 +1,67 @@
+/*
+ * 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.session;
+
+import org.apache.catalina.cluster.ClusterManager;
+import java.beans.PropertyChangeListener;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.session.ManagerBase;
+import org.apache.catalina.Loader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import org.apache.catalina.cluster.io.ReplicationStream;
+
+/**
+ *
+ * @author Filip Hanik
+ * @version $Revision: 380100 $ $Date: 2006-02-23 06:08:14 -0600 (Thu, 23 Feb 2006) $
+ */
+
+public abstract class ClusterManagerBase extends ManagerBase implements Lifecycle, PropertyChangeListener, ClusterManager{
+ /**
+ * Open Stream and use correct ClassLoader (Container) Switch
+ * ThreadClassLoader
+ *
+ * @param data
+ * @return The object input stream
+ * @throws IOException
+ */
+ public ReplicationStream getReplicationStream(byte[] data) throws IOException {
+ ByteArrayInputStream fis =null;
+ ReplicationStream ois = null;
+ Loader loader = null;
+ ClassLoader classLoader = null;
+ //fix to be able to run the DeltaManager
+ //stand alone without a container.
+ //use the Threads context class loader
+ if (container != null)
+ loader = container.getLoader();
+ if (loader != null)
+ classLoader = loader.getClassLoader();
+ else
+ classLoader = Thread.currentThread().getContextClassLoader();
+ //end fix
+ fis = new ByteArrayInputStream(data);
+ if ( classLoader == Thread.currentThread().getContextClassLoader() ) {
+ ois = new ReplicationStream(fis, new ClassLoader[] {classLoader});
+ } else {
+ ois = new ReplicationStream(fis, new ClassLoader[] {classLoader,Thread.currentThread().getContextClassLoader()});
+ }
+ return ois;
+ }
+
+}
\ No newline at end of file
Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java (original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/DeltaManager.java Thu Feb 23 16:34:59 2006
@@ -50,6 +50,7 @@
import org.apache.catalina.util.LifecycleSupport;
import org.apache.catalina.util.StringManager;
import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.cluster.io.ReplicationStream;
/**
* The DeltaManager manages replicated sessions by only replicating the deltas
@@ -70,8 +71,7 @@
* @version $Revision: 380100 $ $Date: 2006-02-23 06:08:14 -0600 (Thu, 23 Feb 2006) $
*/
-public class DeltaManager extends ManagerBase implements Lifecycle,
- PropertyChangeListener, ClusterManager {
+public class DeltaManager extends ClusterManagerBase{
// ---------------------------------------------------- Security Classes
@@ -676,22 +676,7 @@
*/
protected DeltaRequest loadDeltaRequest(DeltaSession session, byte[] data)
throws ClassNotFoundException, IOException {
- ByteArrayInputStream fis = null;
- ReplicationStream ois = null;
- Loader loader = null;
- ClassLoader classLoader = null;
- //fix to be able to run the DeltaManager
- //stand alone without a container.
- //use the Threads context class loader
- if (container != null)
- loader = container.getLoader();
- if (loader != null)
- classLoader = loader.getClassLoader();
- else
- classLoader = Thread.currentThread().getContextClassLoader();
- //end fix
- fis = new ByteArrayInputStream(data);
- ois = new ReplicationStream(fis, classLoader);
+ ReplicationStream ois = getReplicationStream(data);
session.getDeltaRequest().readExternal(ois);
ois.close();
return session.getDeltaRequest();
@@ -730,12 +715,11 @@
// Initialize our internal data structures
//sessions.clear(); //should not do this
// Open an input stream to the specified pathname, if any
- ClassLoader originalLoader = Thread.currentThread()
- .getContextClassLoader();
+ ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
ObjectInputStream ois = null;
// Load the previously unloaded active sessions
try {
- ois = openDeserializeObjectStream(data);
+ ois = getReplicationStream(data);
Integer count = (Integer) ois.readObject();
int n = count.intValue();
for (int i = 0; i < n; i++) {
@@ -788,54 +772,7 @@
}
- /**
- * Open Stream and use correct ClassLoader (Container) Switch
- * ThreadClassLoader
- *
- * @param data
- * @return The object input stream
- * @throws IOException
- */
- protected ObjectInputStream openDeserializeObjectStream(byte[] data) throws IOException {
- ObjectInputStream ois = null;
- ByteArrayInputStream fis = null;
- try {
- Loader loader = null;
- ClassLoader classLoader = null;
- fis = new ByteArrayInputStream(data);
- BufferedInputStream bis = new BufferedInputStream(fis);
- if (container != null)
- loader = container.getLoader();
- if (loader != null)
- classLoader = loader.getClassLoader();
- if (classLoader != null) {
- if (log.isTraceEnabled())
- log.trace(sm.getString(
- "deltaManager.loading.withContextClassLoader",
- getName()));
- ois = new CustomObjectInputStream(bis, classLoader);
- Thread.currentThread().setContextClassLoader(classLoader);
- } else {
- if (log.isTraceEnabled())
- log.trace(sm.getString(
- "deltaManager.loading.withoutClassLoader",
- getName()));
- ois = new ObjectInputStream(bis);
- }
- } catch (IOException e) {
- log.error(sm.getString("deltaManager.loading.ioe", e), e);
- if (ois != null) {
- try {
- ois.close();
- } catch (IOException f) {
- ;
- }
- ois = null;
- }
- throw e;
- }
- return ois;
- }
+
/**
* Save any currently active sessions in the appropriate persistence
Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java (original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/session/SimpleTcpReplicationManager.java Thu Feb 23 16:34:59 2006
@@ -25,6 +25,9 @@
import org.apache.catalina.cluster.Member;
import org.apache.catalina.realm.GenericPrincipal;
import org.apache.catalina.session.StandardManager;
+import org.apache.catalina.cluster.io.ReplicationStream;
+import java.io.ByteArrayInputStream;
+import org.apache.catalina.Loader;
/**
* Title: Tomcat Session Replication for Tomcat 4.0 <BR>
@@ -359,6 +362,41 @@
}
return null;
}
+
+ /**
+ * Open Stream and use correct ClassLoader (Container) Switch
+ * ThreadClassLoader
+ *
+ * @param data
+ * @return The object input stream
+ * @throws IOException
+ */
+ public ReplicationStream getReplicationStream(byte[] data) throws IOException {
+ ByteArrayInputStream fis =null;
+ ReplicationStream ois = null;
+ Loader loader = null;
+ ClassLoader classLoader = null;
+ //fix to be able to run the DeltaManager
+ //stand alone without a container.
+ //use the Threads context class loader
+ if (container != null)
+ loader = container.getLoader();
+ if (loader != null)
+ classLoader = loader.getClassLoader();
+ else
+ classLoader = Thread.currentThread().getContextClassLoader();
+ //end fix
+ fis = new ByteArrayInputStream(data);
+ if ( classLoader == Thread.currentThread().getContextClassLoader() ) {
+ ois = new ReplicationStream(fis, new ClassLoader[] {classLoader});
+ } else {
+ ois = new ReplicationStream(fis, new ClassLoader[] {classLoader,Thread.currentThread().getContextClassLoader()});
+ }
+ return ois;
+ }
+
+
+
/**
* Reinstantiates a serialized session from the data passed in.
@@ -373,8 +411,7 @@
{
try
{
- java.io.ByteArrayInputStream session_data = new java.io.ByteArrayInputStream(data);
- ReplicationStream session_in = new ReplicationStream(session_data,container.getLoader().getClassLoader());
+ ReplicationStream session_in = getReplicationStream(data);
Session session = sessionId!=null?this.findSession(sessionId):null;
boolean isNew = (session==null);
Modified: tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java?rev=380284&r1=380283&r2=380284&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java (original)
+++ tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java Thu Feb 23 16:34:59 2006
@@ -54,6 +54,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tomcat.util.IntrospectionUtils;
+import org.apache.catalina.cluster.io.ReplicationStream;
+import java.io.ByteArrayInputStream;
+import org.apache.catalina.Loader;
/**
* A <b>Cluster </b> implementation using simple multicast. Responsible for
@@ -489,8 +492,7 @@
+ " using class " + getManagerClassName());
Manager manager = null;
try {
- manager = (Manager) getClass().getClassLoader().loadClass(
- getManagerClassName()).newInstance();
+ manager = (Manager) 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.DeltaManager();
@@ -584,8 +586,7 @@
public Manager getManager(String name) {
return (Manager) managers.get(name);
}
-
-
+
// ------------------------------------------------------ Lifecycle Methods
/**
@@ -596,10 +597,9 @@
* @see ReplicationTransmitter#backgroundProcess()
*/
public void backgroundProcess() {
- if (clusterDeployer != null)
- clusterDeployer.backgroundProcess();
-// if (this.channel.getClusterSender() != null)
-// this.channel.getClusterSender().backgroundProcess();
+ if (clusterDeployer != null) clusterDeployer.backgroundProcess();
+ //send a heartbeat through the channel
+ heartbeat();
}
/**
@@ -668,9 +668,12 @@
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(BEFORE_START_EVENT, this);
try {
+ if ( clusterDeployer != null ) clusterDeployer.setCluster(this);
this.registerClusterValve();
channel.addInterceptor(this);
channel.start(channel.DEFAULT);
+ if (clusterDeployer != null) clusterDeployer.start();
+
this.started = true;
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(AFTER_START_EVENT, this);
@@ -742,11 +745,10 @@
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, this);
- if (clusterDeployer != null) {
- clusterDeployer.stop();
- }
+ if (clusterDeployer != null) clusterDeployer.stop();
this.managers.clear();
try {
+ if ( clusterDeployer != null ) clusterDeployer.setCluster(null);
channel.stop(ClusterChannel.DEFAULT);
this.unregisterClusterValve();
} catch (Exception x) {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org