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/08/22 19:28:15 UTC
svn commit: r433703 [1/14] - in /tomcat/tc6.0.x/trunk: ./
java/org/apache/catalina/ha/ java/org/apache/catalina/ha/context/
java/org/apache/catalina/ha/deploy/ java/org/apache/catalina/ha/session/
java/org/apache/catalina/ha/tcp/ java/org/apache/catali...
Author: fhanik
Date: Tue Aug 22 10:28:09 2006
New Revision: 433703
URL: http://svn.apache.org/viewvc?rev=433703&view=rev
Log:
First step in cluster integration
Added:
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/CatalinaCluster.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterDeployer.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterListener.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterManager.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterMessage.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterMessageBase.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterRuleSet.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterSession.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterValve.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/Constants.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/LocalStrings.properties
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileChangeListener.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileMessage.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileMessageFactory.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/UndeployMessage.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/WarWatcher.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/mbeans-descriptors.xml
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/package.html
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/BackupManager.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/ClusterManagerBase.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/ClusterSessionListener.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/Constants.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaManager.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaRequest.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/DeltaSession.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/JvmRouteBinderValve.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/JvmRouteSessionIDBinderLifecycleListener.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/JvmRouteSessionIDBinderListener.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/LocalStrings.properties
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/ReplicatedSession.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SerializablePrincipal.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionIDMessage.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessage.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SessionMessageImpl.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/SimpleTcpReplicationManager.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/Constants.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/LocalStrings.properties
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/ReplicationValve.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SendMessageData.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/tcp/mbeans-descriptors.xml
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/util/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/util/IDynamicProperty.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/ByteMessage.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/Channel.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/ChannelException.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/ChannelInterceptor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/ChannelListener.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/ChannelMessage.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/ChannelReceiver.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/ChannelSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/Constants.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/ErrorHandler.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/Heartbeat.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/LocalStrings.properties
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/ManagedChannel.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/Member.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/MembershipListener.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/MembershipService.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/MessageListener.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/RemoteProcessException.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/UniqueId.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/AbsoluteOrder.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/ChannelCoordinator.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/ChannelInterceptorBase.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/GroupChannel.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/InterceptorPayload.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/Response.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/RpcCallback.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/RpcChannel.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/RpcMessage.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/DomainFilterInterceptor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/FragmentationInterceptor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/GzipInterceptor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatch15Interceptor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/NonBlockingCoordinator.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/OrderInterceptor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/StaticMembershipInterceptor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TcpFailureDetector.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/group/interceptors/TwoPhaseCommitInterceptor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/io/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/io/BufferPool.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/io/BufferPool14Impl.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/io/BufferPool15Impl.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/io/ChannelData.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/io/DirectByteArrayOutputStream.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/io/ListenCallback.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/io/ObjectReader.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/io/ReplicationStream.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/mbeans-descriptors.xml
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/Constants.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/LocalStrings.properties
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastService.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/MemberImpl.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/Membership.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/membership/mbeans-descriptors.xml
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/package.html
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/LazyReplicatedMap.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMap.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/ReplicatedMapEntry.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/tipis/Streamable.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/AbstractSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/Constants.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/DataSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/LocalStrings.properties
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/MultiPointSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/PooledSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/ReceiverBase.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/ReplicationTransmitter.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/SenderState.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/ThreadPool.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/WorkerThread.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioReceiver.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioReplicationThread.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/MultipointBioSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/FastQueue.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/LinkObject.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/SingleRemoveSynchronizedAddLock.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/mbeans-descriptors.xml
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/ParallelNioSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/util/
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/util/Arrays.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/util/Logs.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/util/StringManager.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/util/UUIDGenerator.java
Modified:
tomcat/tc6.0.x/trunk/build.xml
Modified: tomcat/tc6.0.x/trunk/build.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/build.xml?rev=433703&r1=433702&r2=433703&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/build.xml (original)
+++ tomcat/tc6.0.x/trunk/build.xml Tue Aug 22 10:28:09 2006
@@ -42,6 +42,8 @@
<property name="jsp-api.jar" value="${tomcat.build}/lib/jsp-api.jar"/>
<property name="el-api.jar" value="${tomcat.build}/lib/el-api.jar"/>
<property name="catalina.jar" value="${tomcat.build}/lib/catalina.jar"/>
+ <property name="catalina-tribes.jar" value="${tomcat.build}/lib/catalina-tribes.jar"/>
+ <property name="catalina-ha.jar" value="${tomcat.build}/lib/catalina-ha.jar"/>
<property name="catalina-ant.jar" value="${tomcat.build}/lib/catalina-ant.jar"/>
<property name="catalina-ant-jmx.jar" value="${tomcat.build}/lib/catalina-ant-jmx.jar"/>
<property name="tomcat-coyote.jar" value="${tomcat.build}/lib/tomcat-coyote.jar"/>
@@ -186,8 +188,29 @@
<!-- Modules -->
<exclude name="org/apache/catalina/ant/**" />
<exclude name="org/apache/catalina/cluster/**" />
+ <exclude name="org/apache/catalina/ha/**" />
+ <exclude name="org/apache/catalina/tribes/**" />
<exclude name="org/apache/catalina/launcher/**" />
<exclude name="org/apache/catalina/storeconfig/**" />
+ </fileset>
+ </jar>
+
+ <!-- Catalina GroupCom/Tribes JAR File -->
+ <jar jarfile="${catalina-tribes.jar}">
+ <fileset dir="${tomcat.classes}">
+ <exclude name="**/package.html" />
+ <exclude name="**/LocalStrings_*" />
+ <!-- Modules -->
+ <include name="org/apache/catalina/tribes/**" />
+ </fileset>
+ </jar>
+ <!-- Catalina Cluster/HA JAR File -->
+ <jar jarfile="${catalina-ha.jar}">
+ <fileset dir="${tomcat.classes}">
+ <exclude name="**/package.html" />
+ <exclude name="**/LocalStrings_*" />
+ <!-- Modules -->
+ <include name="org/apache/catalina/ha/**" />
</fileset>
</jar>
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/CatalinaCluster.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/CatalinaCluster.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/CatalinaCluster.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/CatalinaCluster.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,130 @@
+/*
+ * 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.ha;
+
+import java.util.Map;
+
+import org.apache.catalina.Cluster;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.Manager;
+import org.apache.catalina.Valve;
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.tribes.Member;
+import org.apache.commons.logging.Log;
+
+
+
+/**
+ * A <b>CatalinaCluster</b> interface allows to plug in and out the
+ * different cluster implementations
+ *
+ * @author Filip Hanik
+ * @version $Revision: 379550 $, $Date: 2006-02-21 12:06:35 -0600 (Tue, 21 Feb 2006) $
+ */
+
+public interface CatalinaCluster extends Cluster {
+ // ----------------------------------------------------- Instance Variables
+
+ /**
+ * Descriptive information about this component implementation.
+ */
+ public String info = "CatalinaCluster/2.0";
+
+ /**
+ * Start the cluster, the owning container will invoke this
+ * @throws Exception - if failure to start cluster
+ */
+ public void start() throws Exception;
+
+ /**
+ * Stops the cluster, the owning container will invoke this
+ * @throws LifecycleException
+ */
+ public void stop() throws LifecycleException;
+
+ /**
+ * Returns the associates logger with this cluster.
+ *
+ * @return Log
+ */
+ public Log getLogger();
+
+ /**
+ * Sends a message to all the members in the cluster
+ * @param msg ClusterMessage
+ */
+ public void send(ClusterMessage msg);
+
+ /**
+ * Sends a message to a specific member in the cluster.
+ *
+ * @param msg ClusterMessage
+ * @param dest Member
+ */
+ public void send(ClusterMessage msg, Member dest);
+
+ /**
+ * Sends a message to a all members at local cluster domain
+ *
+ * @param msg ClusterMessage
+ */
+ public void sendClusterDomain(ClusterMessage msg);
+
+ /**
+ * Returns that cluster has members.
+ */
+ public boolean hasMembers();
+
+ /**
+ * Returns all the members currently participating in the cluster.
+ *
+ * @return Member[]
+ */
+ public Member[] getMembers();
+
+ /**
+ * Return the member that represents this node.
+ *
+ * @return Member
+ */
+ public Member getLocalMember();
+
+ public void addValve(Valve valve);
+
+ public void addClusterListener(ClusterListener listener);
+
+ public void removeClusterListener(ClusterListener listener);
+
+ public void setClusterDeployer(ClusterDeployer deployer);
+
+ public ClusterDeployer getClusterDeployer();
+
+ /**
+ * @return The map of managers
+ */
+ public Map getManagers();
+
+ public Manager getManager(String name);
+ public void removeManager(String name,Manager manager);
+ public void addManager(String name,Manager manager);
+ public String getManagerName(String name, Manager manager);
+ public Valve[] getValves();
+
+ public void setChannel(Channel channel);
+ public Channel getChannel();
+
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterDeployer.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterDeployer.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterDeployer.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterDeployer.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,120 @@
+/*
+ * 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
+ * limitations under the License.
+ */
+
+package org.apache.catalina.ha;
+
+/**
+ * A <b>ClusterDeployer</b> interface allows to plug in and out the
+ * different deployment implementations
+ *
+ * @author Filip Hanik
+ * @version $Revision: 378050 $, $Date: 2006-02-15 12:30:02 -0600 (Wed, 15 Feb 2006) $
+ */
+import org.apache.catalina.LifecycleException;
+import java.io.IOException;
+import java.net.URL;
+import org.apache.catalina.tribes.ChannelListener;
+
+public interface ClusterDeployer extends ChannelListener {
+ /**
+ * Descriptive information about this component implementation.
+ */
+ public String info = "ClusterDeployer/1.0";
+ /**
+ * Start the cluster deployer, the owning container will invoke this
+ * @throws Exception - if failure to start cluster
+ */
+ public void start() throws Exception;
+
+ /**
+ * Stops the cluster deployer, the owning container will invoke this
+ * @throws LifecycleException
+ */
+ public void stop() throws LifecycleException;
+
+ /**
+ * Sets the deployer for this cluster deployer to use.
+ * @param deployer Deployer
+ */
+ // FIXME
+ //public void setDeployer(Deployer deployer);
+
+ /**
+ * Install a new web application, whose web application archive is at the
+ * specified URL, into this container and all the other
+ * members of the cluster with the specified context path.
+ * A context path of "" (the empty string) should be used for the root
+ * application for this container. Otherwise, the context path must
+ * start with a slash.
+ * <p>
+ * If this application is successfully installed locally,
+ * a ContainerEvent of type
+ * <code>INSTALL_EVENT</code> will be sent to all registered listeners,
+ * with the newly created <code>Context</code> as an argument.
+ *
+ * @param contextPath The context path to which this application should
+ * be installed (must be unique)
+ * @param war A URL of type "jar:" that points to a WAR file, or type
+ * "file:" that points to an unpacked directory structure containing
+ * the web application to be installed
+ *
+ * @exception IllegalArgumentException if the specified context path
+ * is malformed (it must be "" or start with a slash)
+ * @exception IllegalStateException if the specified context path
+ * is already attached to an existing web application
+ * @exception IOException if an input/output error was encountered
+ * during installation
+ */
+ public void install(String contextPath, URL war) throws IOException;
+
+ /**
+ * Remove an existing web application, attached to the specified context
+ * path. If this application is successfully removed, a
+ * ContainerEvent of type <code>REMOVE_EVENT</code> will be sent to all
+ * registered listeners, with the removed <code>Context</code> as
+ * an argument. Deletes the web application war file and/or directory
+ * if they exist in the Host's appBase.
+ *
+ * @param contextPath The context path of the application to be removed
+ * @param undeploy boolean flag to remove web application from server
+ *
+ * @exception IllegalArgumentException if the specified context path
+ * is malformed (it must be "" or start with a slash)
+ * @exception IllegalArgumentException if the specified context path does
+ * not identify a currently installed web application
+ * @exception IOException if an input/output error occurs during
+ * removal
+ */
+ public void remove(String contextPath, boolean undeploy) throws IOException;
+
+ /**
+ * 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);
+
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterListener.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterListener.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterListener.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterListener.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,113 @@
+/*
+ * 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
+ * limitations under the License.
+ */
+
+package org.apache.catalina.ha;
+
+
+
+
+import org.apache.catalina.tribes.ChannelListener;
+import org.apache.catalina.tribes.ChannelMessage;
+import org.apache.catalina.util.StringManager;
+import java.io.Serializable;
+import org.apache.catalina.tribes.Member;
+
+
+/**
+ * Receive SessionID cluster change from other backup node after primary session
+ * node is failed.
+ *
+ * @author Peter Rossbach
+ * @author Filip Hanik
+ * @version $Revision: 378258 $ $Date: 2006-02-16 08:42:35 -0600 (Thu, 16 Feb 2006) $
+ */
+public abstract class ClusterListener implements ChannelListener {
+
+ public static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ClusterListener.class);
+
+
+ //--Instance Variables--------------------------------------
+
+ /**
+ * The string manager for this package.
+ */
+ protected StringManager sm = StringManager.getManager(Constants.Package);
+
+ protected CatalinaCluster cluster = null;
+
+ //--Constructor---------------------------------------------
+
+ public ClusterListener() {
+ }
+
+ //--Instance Getters/Setters--------------------------------
+
+ public CatalinaCluster getCluster() {
+ return cluster;
+ }
+
+ public void setCluster(CatalinaCluster cluster) {
+ if (log.isDebugEnabled()) {
+ if (cluster != null)
+ log.debug("add ClusterListener " + this.toString() + " to cluster" + cluster);
+ else
+ log.debug("remove ClusterListener " + this.toString() + " from cluster");
+ }
+ this.cluster = cluster;
+ }
+
+ public boolean equals(Object listener) {
+ return super.equals(listener);
+ }
+
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ //--Logic---------------------------------------------------
+
+ public final void messageReceived(Serializable msg, Member member) {
+ if ( msg instanceof ClusterMessage ) messageReceived((ClusterMessage)msg);
+ }
+ public final boolean accept(Serializable msg, Member member) {
+ if ( msg instanceof ClusterMessage ) return true;
+ return false;
+ }
+
+
+
+ /**
+ * Callback from the cluster, when a message is received, The cluster will
+ * broadcast it invoking the messageReceived on the receiver.
+ *
+ * @param msg
+ * ClusterMessage - the message received from the cluster
+ */
+ public abstract void messageReceived(ClusterMessage msg) ;
+
+
+ /**
+ * Accept only SessionIDMessages
+ *
+ * @param msg
+ * ClusterMessage
+ * @return boolean - returns true to indicate that messageReceived should be
+ * invoked. If false is returned, the messageReceived method will
+ * not be invoked.
+ */
+ public abstract boolean accept(ClusterMessage msg) ;
+
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterManager.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterManager.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterManager.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterManager.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,110 @@
+/*
+ * 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.ha;
+
+
+import org.apache.catalina.Manager;
+import java.io.IOException;
+import org.apache.catalina.tribes.io.ReplicationStream;
+
+
+/**
+ * The common interface used by all cluster manager.
+ * This is so that we can have a more pluggable way
+ * of swapping session managers for different algorithms.
+ *
+ * @author Filip Hanik
+ * @author Peter Rossbach
+ */
+public interface ClusterManager extends Manager {
+
+ /**
+ * A message was received from another node, this
+ * is the callback method to implement if you are interested in
+ * receiving replication messages.
+ * @param msg - the message received.
+ */
+ public void messageDataReceived(ClusterMessage msg);
+
+ /**
+ * When the request has been completed, the replication valve
+ * will notify the manager, and the manager will decide whether
+ * any replication is needed or not.
+ * If there is a need for replication, the manager will
+ * create a session message and that will be replicated.
+ * The cluster determines where it gets sent.
+ * @param sessionId - the sessionId that just completed.
+ * @return a SessionMessage to be sent.
+ */
+ public ClusterMessage requestCompleted(String sessionId);
+
+ /**
+ * When the manager expires session not tied to a request.
+ * The cluster will periodically ask for a list of sessions
+ * that should expire and that should be sent across the wire.
+ * @return String[] The invalidated sessions
+ */
+ public String[] getInvalidatedSessions();
+
+ /**
+ * Return the name of the manager, at host /context name and at engine hostname+/context.
+ * @return String
+ * @since 5.5.10
+ */
+ public String getName();
+
+ /**
+ * Set the name of the manager, at host /context name and at engine hostname+/context
+ * @param name
+ * @since 5.5.10
+ */
+ public void setName(String name);
+
+ public CatalinaCluster getCluster();
+
+ public void setCluster(CatalinaCluster cluster);
+
+ /**
+ * @return Manager send only to same cluster domain.
+ * @since 5.5.10
+ */
+ public boolean isSendClusterDomainOnly();
+
+ /**
+ * @param sendClusterDomainOnly Flag value.
+ * @since 5.5.10
+ */
+ public void setSendClusterDomainOnly(boolean sendClusterDomainOnly);
+
+ /**
+ * @param mode The mode
+ * @since 5.5.10
+ */
+ public void setDefaultMode(boolean mode);
+
+ /**
+ * @since 5.5.10
+ */
+ public boolean isDefaultMode();
+
+ public ReplicationStream getReplicationStream(byte[] data) throws IOException;
+
+ public ReplicationStream getReplicationStream(byte[] data, int offset, int length) throws IOException;
+
+ public boolean isNotifyListenersOnReplication();
+
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterMessage.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterMessage.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterMessage.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterMessage.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999,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.ha;
+
+import java.io.Serializable;
+import org.apache.catalina.tribes.Member;
+
+
+/**
+ * @author Filip Hanik
+ *
+ */
+public interface ClusterMessage extends Serializable {
+ public Member getAddress();
+ public void setAddress(Member member);
+ public String getUniqueId();
+ public void setUniqueId(String id);
+ public long getTimestamp();
+ public void setTimestamp(long timestamp);
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterMessageBase.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterMessageBase.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterMessageBase.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterMessageBase.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,61 @@
+package org.apache.catalina.ha;
+
+import org.apache.catalina.tribes.Member;
+
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2005</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class ClusterMessageBase implements ClusterMessage {
+
+ protected transient Member address;
+ private String uniqueId;
+ private long timestamp;
+ public ClusterMessageBase() {
+ }
+
+ /**
+ * getAddress
+ *
+ * @return Member
+ * @todo Implement this org.apache.catalina.ha.ClusterMessage method
+ */
+ public Member getAddress() {
+ return address;
+ }
+
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * setAddress
+ *
+ * @param member Member
+ * @todo Implement this org.apache.catalina.ha.ClusterMessage method
+ */
+ public void setAddress(Member member) {
+ this.address = member;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+}
\ No newline at end of file
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterRuleSet.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterRuleSet.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterRuleSet.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterRuleSet.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,176 @@
+/*
+ * Copyright 1999-2001,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
+ * limitations under the License.
+ */
+
+
+package org.apache.catalina.ha;
+
+
+import org.apache.tomcat.util.digester.Digester;
+import org.apache.tomcat.util.digester.RuleSetBase;
+
+
+/**
+ * <p><strong>RuleSet</strong> for processing the contents of a
+ * Cluster definition element. </p>
+ *
+ * @author Filip Hanik
+ * @author Peter Rossbach
+ * @version $Revision: 387285 $ $Date: 2006-03-20 13:30:50 -0600 (Mon, 20 Mar 2006) $
+ */
+
+public class ClusterRuleSet extends RuleSetBase {
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * The matching pattern prefix to use for recognizing our elements.
+ */
+ protected String prefix = null;
+
+
+ // ------------------------------------------------------------ Constructor
+
+
+ /**
+ * Construct an instance of this <code>RuleSet</code> with the default
+ * matching pattern prefix.
+ */
+ public ClusterRuleSet() {
+
+ this("");
+
+ }
+
+
+ /**
+ * Construct an instance of this <code>RuleSet</code> with the specified
+ * matching pattern prefix.
+ *
+ * @param prefix Prefix for matching pattern rules (including the
+ * trailing slash character)
+ */
+ public ClusterRuleSet(String prefix) {
+ super();
+ this.namespaceURI = null;
+ this.prefix = prefix;
+ }
+
+
+ // --------------------------------------------------------- Public Methods
+
+
+ /**
+ * <p>Add the set of Rule instances defined in this RuleSet to the
+ * specified <code>Digester</code> instance, associating them with
+ * our namespace URI (if any). This method should only be called
+ * by a Digester instance.</p>
+ *
+ * @param digester Digester instance to which the new Rule instances
+ * should be added.
+ */
+ public void addRuleInstances(Digester digester) {
+ //Cluster configuration start
+
+ digester.addObjectCreate(prefix + "Channel",
+ null, // MUST be specified in the element
+ "className");
+ digester.addSetProperties(prefix + "Channel");
+ digester.addSetNext(prefix + "Channel",
+ "setChannel",
+ "org.apache.catalina.tribes.Channel");
+
+
+ String channelPrefix = prefix + "Channel/";
+ { //channel properties
+ digester.addObjectCreate(channelPrefix + "Membership",
+ null, // MUST be specified in the element
+ "className");
+ digester.addSetProperties(channelPrefix + "Membership");
+ digester.addSetNext(channelPrefix + "Membership",
+ "setMembershipService",
+ "org.apache.catalina.tribes.MembershipService");
+
+ digester.addObjectCreate(channelPrefix + "Sender",
+ null, // MUST be specified in the element
+ "className");
+ digester.addSetProperties(channelPrefix + "Sender");
+ digester.addSetNext(channelPrefix + "Sender",
+ "setChannelSender",
+ "org.apache.catalina.tribes.ChannelSender");
+
+ digester.addObjectCreate(channelPrefix + "Sender/Transport",
+ null, // MUST be specified in the element
+ "className");
+ digester.addSetProperties(channelPrefix + "Sender/Transport");
+ digester.addSetNext(channelPrefix + "Sender/Transport",
+ "setTransport",
+ "org.apache.catalina.tribes.tcp.MultiPointSender");
+
+
+ digester.addObjectCreate(channelPrefix + "Receiver",
+ null, // MUST be specified in the element
+ "className");
+ digester.addSetProperties(channelPrefix + "Receiver");
+ digester.addSetNext(channelPrefix + "Receiver",
+ "setChannelReceiver",
+ "org.apache.catalina.tribes.ChannelReceiver");
+
+ digester.addObjectCreate(channelPrefix + "Interceptor",
+ null, // MUST be specified in the element
+ "className");
+ digester.addSetProperties(channelPrefix + "Interceptor");
+ digester.addSetNext(channelPrefix + "Interceptor",
+ "addInterceptor",
+ "org.apache.catalina.tribes.ChannelInterceptor");
+ }
+
+ digester.addObjectCreate(prefix + "Valve",
+ null, // MUST be specified in the element
+ "className");
+ digester.addSetProperties(prefix + "Valve");
+ digester.addSetNext(prefix + "Valve",
+ "addValve",
+ "org.apache.catalina.Valve");
+
+ digester.addObjectCreate(prefix + "Deployer",
+ null, // MUST be specified in the element
+ "className");
+ digester.addSetProperties(prefix + "Deployer");
+ digester.addSetNext(prefix + "Deployer",
+ "setClusterDeployer",
+ "org.apache.catalina.ha.ClusterDeployer");
+
+ digester.addObjectCreate(prefix + "Listener",
+ null, // MUST be specified in the element
+ "className");
+ digester.addSetProperties(prefix + "Listener");
+ digester.addSetNext(prefix + "Listener",
+ "addLifecycleListener",
+ "org.apache.catalina.LifecycleListener");
+
+ digester.addObjectCreate(prefix + "ClusterListener",
+ null, // MUST be specified in the element
+ "className");
+ digester.addSetProperties(prefix + "ClusterListener");
+ digester.addSetNext(prefix + "ClusterListener",
+ "addClusterListener",
+ "org.apache.catalina.ha.ClusterListener");
+ //Cluster configuration end
+ }
+
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterSession.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterSession.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterSession.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterSession.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,39 @@
+/*
+ * 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
+ * limitations under the License.
+ */
+
+
+package org.apache.catalina.ha;
+
+import org.apache.catalina.Session;
+import javax.servlet.http.HttpSession;
+
+public interface ClusterSession extends Session, HttpSession {
+ /**
+ * returns true if this session is the primary session, if that is the
+ * case, the manager can expire it upon timeout.
+ * @return True if this session is primary
+ */
+ public boolean isPrimarySession();
+
+ /**
+ * Sets whether this is the primary session or not.
+ * @param primarySession Flag value
+ */
+ public void setPrimarySession(boolean primarySession);
+
+
+
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterValve.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterValve.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterValve.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/ClusterValve.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,36 @@
+/*
+ * 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
+ * limitations under the License.
+ */
+package org.apache.catalina.ha;
+
+/**
+ * Cluster Valve Interface to mark all Cluster Valves
+ * Only those Valve can'be configured as Cluster Valves
+ * @author Peter Rossbach
+ * @version $Revision: 303842 $, $Date: 2005-04-10 11:20:46 -0500 (Sun, 10 Apr 2005) $
+ */
+public interface ClusterValve {
+ /**
+ * 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);
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/Constants.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/Constants.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/Constants.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,30 @@
+/*
+ * 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
+ * limitations under the License.
+ */
+
+
+package org.apache.catalina.ha;
+
+/**
+ * Manifest constants for the <code>org.apache.catalina.ha</code>
+ * package.
+ *
+ * @author Bip Thelin
+ * @version $Revision: 302726 $, $Date: 2004-02-27 08:59:07 -0600 (Fri, 27 Feb 2004) $
+ */
+
+public final class Constants {
+ public static final String Package = "org.apache.catalina.ha";
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/LocalStrings.properties?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/LocalStrings.properties (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/LocalStrings.properties Tue Aug 22 10:28:09 2006
@@ -0,0 +1 @@
+cluster.mbean.register.already=MBean {0} already registered!
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/context/ReplicatedContext.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,125 @@
+/*
+ * 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.ha.context;
+
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.ha.CatalinaCluster;
+import org.apache.catalina.tribes.tipis.ReplicatedMap;
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.Loader;
+import org.apache.catalina.core.ApplicationContext;
+import org.apache.catalina.Globals;
+import javax.servlet.ServletContext;
+import java.util.HashMap;
+import org.apache.catalina.tribes.tipis.LazyReplicatedMap;
+
+/**
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class ReplicatedContext extends StandardContext {
+ private int mapSendOptions = Channel.SEND_OPTIONS_DEFAULT;
+ public static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog( ReplicatedContext.class );
+
+ protected static long DEFAULT_REPL_TIMEOUT = 15000;//15 seconds
+
+
+
+ public synchronized void start() throws LifecycleException {
+ if ( this.started ) return;
+ try {
+ CatalinaCluster catclust = (CatalinaCluster)this.getCluster();
+ if (this.context == null) this.context = new ReplApplContext(this.getBasePath(), this);
+ if ( catclust != null ) {
+ ReplicatedMap map = new ReplicatedMap(this,catclust.getChannel(),DEFAULT_REPL_TIMEOUT,
+ getName(),getClassLoaders());
+ map.setChannelSendOptions(mapSendOptions);
+ ((ReplApplContext)this.context).setAttributeMap(map);
+ if (getAltDDName() != null) context.setAttribute(Globals.ALT_DD_ATTR, getAltDDName());
+ }
+ super.start();
+ } catch ( Exception x ) {
+ log.error("Unable to start ReplicatedContext",x);
+ throw new LifecycleException("Failed to start ReplicatedContext",x);
+ }
+ }
+
+ public synchronized void stop() throws LifecycleException
+ {
+ ReplicatedMap map = (ReplicatedMap)((ReplApplContext)this.context).getAttributeMap();
+ if ( map!=null ) {
+ map.breakdown();
+ }
+ if ( !this.started ) return;
+ try {
+ } catch ( Exception x ){
+ log.error("Unable to stop ReplicatedContext",x);
+ throw new LifecycleException("Failed to stop ReplicatedContext",x);
+ } finally {
+ super.stop();
+ }
+
+ }
+
+
+ public void setMapSendOptions(int mapSendOptions) {
+ this.mapSendOptions = mapSendOptions;
+ }
+
+ public int getMapSendOptions() {
+ return mapSendOptions;
+ }
+
+ public ClassLoader[] getClassLoaders() {
+ Loader loader = null;
+ ClassLoader classLoader = null;
+ loader = this.getLoader();
+ if (loader != null) classLoader = loader.getClassLoader();
+ if ( classLoader == null ) classLoader = Thread.currentThread().getContextClassLoader();
+ if ( classLoader == Thread.currentThread().getContextClassLoader() ) {
+ return new ClassLoader[] {classLoader};
+ } else {
+ return new ClassLoader[] {classLoader,Thread.currentThread().getContextClassLoader()};
+ }
+ }
+
+ public ServletContext getServletContext() {
+ return ((ReplApplContext)context).getFacade();
+
+ }
+
+
+ protected static class ReplApplContext extends ApplicationContext {
+ public ReplApplContext(String basePath, StandardContext context) {
+ super(basePath,context);
+ }
+
+ protected ServletContext getFacade() {
+ return super.getFacade();
+ }
+
+ public HashMap getAttributeMap() {
+ return (HashMap)this.attributes;
+ }
+ public void setAttributeMap(HashMap map) {
+ this.attributes = map;
+ }
+
+ }
+
+
+}
\ No newline at end of file
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FarmWarDeployer.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,741 @@
+/*
+ * 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.ha.deploy;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.Engine;
+import org.apache.catalina.Host;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.ha.CatalinaCluster;
+import org.apache.catalina.ha.ClusterDeployer;
+import org.apache.catalina.ha.ClusterListener;
+import org.apache.catalina.ha.ClusterMessage;
+import org.apache.catalina.tribes.Member;
+import org.apache.tomcat.util.modeler.Registry;
+
+
+/**
+ * <p>
+ * A farm war deployer is a class that is able to deploy/undeploy web
+ * applications in WAR form within the cluster.
+ * </p>
+ * Any host can act as the admin, and will have three directories
+ * <ul>
+ * <li>deployDir - the directory where we watch for changes</li>
+ * <li>applicationDir - the directory where we install applications</li>
+ * <li>tempDir - a temporaryDirectory to store binary data when downloading a
+ * war from the cluster</li>
+ * </ul>
+ * Currently we only support deployment of WAR files since they are easier to
+ * send across the wire.
+ *
+ * @author Filip Hanik
+ * @author Peter Rossbach
+ * @version $Revision: 390639 $
+ */
+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);
+ /**
+ * The descriptive information about this implementation.
+ */
+ private static final String info = "FarmWarDeployer/1.2";
+
+ /*--Instance Variables--------------------------------------*/
+ protected CatalinaCluster cluster = null;
+
+ protected boolean started = false; //default 5 seconds
+
+ protected HashMap fileFactories = new HashMap();
+
+ protected String deployDir;
+
+ protected String tempDir;
+
+ protected String watchDir;
+
+ protected boolean watchEnabled = false;
+
+ protected WarWatcher watcher = null;
+
+ /**
+ * Iteration count for background processing.
+ */
+ private int count = 0;
+
+ /**
+ * Frequency of the Farm watchDir check. Cluster wide deployment will be
+ * done once for the specified amount of backgrondProcess calls (ie, the
+ * lower the amount, the most often the checks will occur).
+ */
+ protected int processDeployFrequency = 2;
+
+ /**
+ * Path where context descriptors should be deployed.
+ */
+ protected File configBase = null;
+
+ /**
+ * The associated host.
+ */
+ protected Host host = null;
+
+ /**
+ * The host appBase.
+ */
+ protected File appBase = null;
+
+ /**
+ * MBean server.
+ */
+ protected MBeanServer mBeanServer = null;
+
+ /**
+ * The associated deployer ObjectName.
+ */
+ protected ObjectName oname = null;
+
+ /*--Constructor---------------------------------------------*/
+ public FarmWarDeployer() {
+ }
+
+ /**
+ * Return descriptive information about this deployer implementation and the
+ * corresponding version number, in the format
+ * <code><description>/<version></code>.
+ */
+ public String getInfo() {
+
+ return (info);
+
+ }
+
+ /*--Logic---------------------------------------------------*/
+ public void start() throws Exception {
+ if (started)
+ return;
+ getCluster().addClusterListener(this);
+ if (watchEnabled) {
+ watcher = new WarWatcher(this, new File(getWatchDir()));
+ if (log.isInfoEnabled())
+ log.info("Cluster deployment is watching " + getWatchDir()
+ + " for changes.");
+ }
+
+ // Check to correct engine and host setup
+ host = (Host) getCluster().getContainer();
+ Engine engine = (Engine) host.getParent();
+ try {
+ oname = new ObjectName(engine.getName() + ":type=Deployer,host="
+ + host.getName());
+ } catch (Exception e) {
+ log.error("Can't construct MBean object name" + e);
+ }
+ configBase = new File(System.getProperty("catalina.base"), "conf");
+ if (engine != null) {
+ configBase = new File(configBase, engine.getName());
+ }
+ if (host != null) {
+ configBase = new File(configBase, host.getName());
+ }
+
+ // Retrieve the MBean server
+ mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
+
+ started = true;
+ count = 0;
+ if (log.isInfoEnabled())
+ log.info("Cluster FarmWarDeployer started.");
+ }
+
+ /*
+ * stop cluster wide deployments
+ *
+ * @see org.apache.catalina.cluster.ClusterDeployer#stop()
+ */
+ public void stop() throws LifecycleException {
+ started = false;
+ getCluster().removeClusterListener(this);
+ count = 0;
+ if (watcher != null) {
+ watcher.clear();
+ watcher = null;
+
+ }
+ if (log.isInfoEnabled())
+ log.info("Cluster FarmWarDeployer stopped.");
+ }
+
+ public void cleanDeployDir() {
+ throw new java.lang.UnsupportedOperationException(
+ "Method cleanDeployDir() not yet implemented.");
+ }
+
+ /**
+ * Callback from the cluster, when a message is received, The cluster will
+ * broadcast it invoking the messageReceived on the receiver.
+ *
+ * @param msg
+ * ClusterMessage - the message received from the cluster
+ */
+ public void messageReceived(ClusterMessage msg) {
+ try {
+ if (msg instanceof FileMessage && msg != null) {
+ FileMessage fmsg = (FileMessage) msg;
+ if (log.isDebugEnabled())
+ log.debug("receive cluster deployment [ path: "
+ + fmsg.getContextPath() + " war: "
+ + fmsg.getFileName() + " ]");
+ FileMessageFactory factory = getFactory(fmsg);
+ // TODO correct second try after app is in service!
+ if (factory.writeMessage(fmsg)) {
+ //last message received war file is completed
+ String name = factory.getFile().getName();
+ if (!name.endsWith(".war"))
+ name = name + ".war";
+ File deployable = new File(getDeployDir(), name);
+ try {
+ String path = fmsg.getContextPath();
+ if (!isServiced(path)) {
+ addServiced(path);
+ try {
+ remove(path);
+ factory.getFile().renameTo(deployable);
+ check(path);
+ } finally {
+ removeServiced(path);
+ }
+ if (log.isDebugEnabled())
+ log.debug("deployment from " + path
+ + " finished.");
+ } else
+ log.error("Application " + path
+ + " in used. touch war file " + name
+ + " again!");
+ } catch (Exception ex) {
+ log.error(ex);
+ } finally {
+ removeFactory(fmsg);
+ }
+ }
+ } else if (msg instanceof UndeployMessage && msg != null) {
+ try {
+ UndeployMessage umsg = (UndeployMessage) msg;
+ String path = umsg.getContextPath();
+ if (log.isDebugEnabled())
+ log.debug("receive cluster undeployment from " + path);
+ if (!isServiced(path)) {
+ addServiced(path);
+ try {
+ remove(path);
+ } finally {
+ removeServiced(path);
+ }
+ if (log.isDebugEnabled())
+ log.debug("undeployment from " + path
+ + " finished.");
+ } else
+ log.error("Application "
+ + path
+ + " in used. Sorry not remove from backup cluster nodes!");
+ } catch (Exception ex) {
+ log.error(ex);
+ }
+ }
+ } catch (java.io.IOException x) {
+ log.error("Unable to read farm deploy file message.", x);
+ }
+ }
+
+ /**
+ * create factory for all transported war files
+ *
+ * @param msg
+ * @return Factory for all app message (war files)
+ * @throws java.io.FileNotFoundException
+ * @throws java.io.IOException
+ */
+ public synchronized FileMessageFactory getFactory(FileMessage msg)
+ throws java.io.FileNotFoundException, java.io.IOException {
+ File tmpFile = new File(msg.getFileName());
+ File writeToFile = new File(getTempDir(), tmpFile.getName());
+ FileMessageFactory factory = (FileMessageFactory) fileFactories.get(msg
+ .getFileName());
+ if (factory == null) {
+ factory = FileMessageFactory.getInstance(writeToFile, true);
+ fileFactories.put(msg.getFileName(), factory);
+ }
+ return factory;
+ }
+
+ /**
+ * Remove file (war) from messages)
+ *
+ * @param msg
+ */
+ public void removeFactory(FileMessage msg) {
+ fileFactories.remove(msg.getFileName());
+ }
+
+ /**
+ * Before the cluster invokes messageReceived the cluster will ask the
+ * receiver to accept or decline the message, In the future, when messages
+ * get big, the accept method will only take a message header
+ *
+ * @param msg
+ * ClusterMessage
+ * @return boolean - returns true to indicate that messageReceived should be
+ * invoked. If false is returned, the messageReceived method will
+ * not be invoked.
+ */
+ public boolean accept(ClusterMessage msg) {
+ return (msg instanceof FileMessage) || (msg instanceof UndeployMessage);
+ }
+
+ /**
+ * Install a new web application, whose web application archive is at the
+ * specified URL, into this container and all the other members of the
+ * cluster with the specified context path. A context path of "" (the empty
+ * string) should be used for the root application for this container.
+ * Otherwise, the context path must start with a slash.
+ * <p>
+ * If this application is successfully installed locally, a ContainerEvent
+ * of type <code>INSTALL_EVENT</code> will be sent to all registered
+ * listeners, with the newly created <code>Context</code> as an argument.
+ *
+ * @param contextPath
+ * The context path to which this application should be installed
+ * (must be unique)
+ * @param war
+ * A URL of type "jar:" that points to a WAR file, or type
+ * "file:" that points to an unpacked directory structure
+ * containing the web application to be installed
+ *
+ * @exception IllegalArgumentException
+ * if the specified context path is malformed (it must be ""
+ * or start with a slash)
+ * @exception IllegalStateException
+ * if the specified context path is already attached to an
+ * existing web application
+ * @exception IOException
+ * if an input/output error was encountered during
+ * installation
+ */
+ public void install(String contextPath, URL war) throws IOException {
+ Member[] members = getCluster().getMembers();
+ Member localMember = getCluster().getLocalMember();
+ FileMessageFactory factory = FileMessageFactory.getInstance(new File(
+ war.getFile()), false);
+ FileMessage msg = new FileMessage(localMember, war.getFile(),
+ contextPath);
+ if(log.isDebugEnabled())
+ log.debug("Send cluster war deployment [ path:"
+ + contextPath + " war: " + war + " ] started.");
+ msg = factory.readMessage(msg);
+ while (msg != null) {
+ for (int i = 0; i < members.length; i++) {
+ if (log.isDebugEnabled())
+ log.debug("Send cluster war fragment [ path: "
+ + contextPath + " war: " + war + " to: " + members[i] + " ]");
+ getCluster().send(msg, members[i]);
+ }
+ msg = factory.readMessage(msg);
+ }
+ if(log.isDebugEnabled())
+ log.debug("Send cluster war deployment [ path: "
+ + contextPath + " war: " + war + " ] finished.");
+ }
+
+ /**
+ * Remove an existing web application, attached to the specified context
+ * path. If this application is successfully removed, a ContainerEvent of
+ * type <code>REMOVE_EVENT</code> will be sent to all registered
+ * listeners, with the removed <code>Context</code> as an argument.
+ * Deletes the web application war file and/or directory if they exist in
+ * the Host's appBase.
+ *
+ * @param contextPath
+ * The context path of the application to be removed
+ * @param undeploy
+ * boolean flag to remove web application from server
+ *
+ * @exception IllegalArgumentException
+ * if the specified context path is malformed (it must be ""
+ * or start with a slash)
+ * @exception IllegalArgumentException
+ * if the specified context path does not identify a
+ * currently installed web application
+ * @exception IOException
+ * if an input/output error occurs during removal
+ */
+ public void remove(String contextPath, boolean undeploy) throws IOException {
+ if (log.isInfoEnabled())
+ log.info("Cluster wide remove of web app " + contextPath);
+ Member localMember = getCluster().getLocalMember();
+ UndeployMessage msg = new UndeployMessage(localMember, System
+ .currentTimeMillis(), "Undeploy:" + contextPath + ":"
+ + System.currentTimeMillis(), contextPath, undeploy);
+ if (log.isDebugEnabled())
+ log.debug("Send cluster wide undeployment from "
+ + contextPath );
+ cluster.send(msg);
+ // remove locally
+ if (undeploy) {
+ try {
+ if (!isServiced(contextPath)) {
+ addServiced(contextPath);
+ try {
+ remove(contextPath);
+ } finally {
+ removeServiced(contextPath);
+ }
+ } else
+ log.error("Local remove from " + contextPath
+ + "failed, other manager has app in service!");
+
+ } catch (Exception ex) {
+ log.error("local remove from " + contextPath + " failed", ex);
+ }
+ }
+
+ }
+
+ /*
+ * Modifcation from watchDir war detected!
+ *
+ * @see org.apache.catalina.cluster.deploy.FileChangeListener#fileModified(java.io.File)
+ */
+ public void fileModified(File newWar) {
+ try {
+ File deployWar = new File(getDeployDir(), newWar.getName());
+ copy(newWar, deployWar);
+ String contextName = getContextName(deployWar);
+ if (log.isInfoEnabled())
+ log.info("Installing webapp[" + contextName + "] from "
+ + deployWar.getAbsolutePath());
+ try {
+ remove(contextName, false);
+ } catch (Exception x) {
+ log.error("No removal", x);
+ }
+ install(contextName, deployWar.toURL());
+ } catch (Exception x) {
+ log.error("Unable to install WAR file", x);
+ }
+ }
+
+ /*
+ * War remvoe from watchDir
+ *
+ * @see org.apache.catalina.cluster.deploy.FileChangeListener#fileRemoved(java.io.File)
+ */
+ public void fileRemoved(File removeWar) {
+ try {
+ String contextName = getContextName(removeWar);
+ if (log.isInfoEnabled())
+ log.info("Removing webapp[" + contextName + "]");
+ remove(contextName, true);
+ } catch (Exception x) {
+ log.error("Unable to remove WAR file", x);
+ }
+ }
+
+ /**
+ * Create a context path from war
+ * @param war War filename
+ * @return '/filename' or if war name is ROOT.war context name is empty string ''
+ */
+ protected String getContextName(File war) {
+ String contextName = "/"
+ + war.getName().substring(0,
+ war.getName().lastIndexOf(".war"));
+ if("/ROOT".equals(contextName))
+ contextName= "" ;
+ return contextName ;
+ }
+
+ /**
+ * Given a context path, get the config file name.
+ */
+ protected String getConfigFile(String path) {
+ String basename = null;
+ if (path.equals("")) {
+ basename = "ROOT";
+ } else {
+ basename = path.substring(1).replace('/', '#');
+ }
+ return (basename);
+ }
+
+ /**
+ * Given a context path, get the config file name.
+ */
+ protected String getDocBase(String path) {
+ String basename = null;
+ if (path.equals("")) {
+ basename = "ROOT";
+ } else {
+ basename = path.substring(1);
+ }
+ return (basename);
+ }
+
+ /**
+ * Return a File object representing the "application root" directory for
+ * our associated Host.
+ */
+ protected File getAppBase() {
+
+ if (appBase != null) {
+ return appBase;
+ }
+
+ File file = new File(host.getAppBase());
+ if (!file.isAbsolute())
+ file = new File(System.getProperty("catalina.base"), host
+ .getAppBase());
+ try {
+ appBase = file.getCanonicalFile();
+ } catch (IOException e) {
+ appBase = file;
+ }
+ return (appBase);
+
+ }
+
+ /**
+ * Invoke the remove method on the deployer.
+ */
+ protected void remove(String path) throws Exception {
+ // TODO Handle remove also work dir content !
+ // Stop the context first to be nicer
+ Context context = (Context) host.findChild(path);
+ if (context != null) {
+ if(log.isDebugEnabled())
+ log.debug("Undeploy local context " +path );
+ ((Lifecycle) context).stop();
+ File war = new File(getAppBase(), getDocBase(path) + ".war");
+ File dir = new File(getAppBase(), getDocBase(path));
+ File xml = new File(configBase, getConfigFile(path) + ".xml");
+ if (war.exists()) {
+ war.delete();
+ } else if (dir.exists()) {
+ undeployDir(dir);
+ } else {
+ xml.delete();
+ }
+ // Perform new deployment and remove internal HostConfig state
+ check(path);
+ }
+
+ }
+
+ /**
+ * Delete the specified directory, including all of its contents and
+ * subdirectories recursively.
+ *
+ * @param dir
+ * File object representing the directory to be deleted
+ */
+ protected void undeployDir(File dir) {
+
+ String files[] = dir.list();
+ if (files == null) {
+ files = new String[0];
+ }
+ for (int i = 0; i < files.length; i++) {
+ File file = new File(dir, files[i]);
+ if (file.isDirectory()) {
+ undeployDir(file);
+ } else {
+ file.delete();
+ }
+ }
+ dir.delete();
+
+ }
+
+ /*
+ * Call watcher to check for deploy changes
+ *
+ * @see org.apache.catalina.cluster.ClusterDeployer#backgroundProcess()
+ */
+ public void backgroundProcess() {
+ if (started) {
+ count = (count + 1) % processDeployFrequency;
+ if (count == 0 && watchEnabled) {
+ watcher.check();
+ }
+ }
+
+ }
+
+ /*--Deployer Operations ------------------------------------*/
+
+ /**
+ * Invoke the check method on the deployer.
+ */
+ protected void check(String name) throws Exception {
+ String[] params = { name };
+ String[] signature = { "java.lang.String" };
+ mBeanServer.invoke(oname, "check", params, signature);
+ }
+
+ /**
+ * Invoke the check method on the deployer.
+ */
+ protected boolean isServiced(String name) throws Exception {
+ String[] params = { name };
+ String[] signature = { "java.lang.String" };
+ Boolean result = (Boolean) mBeanServer.invoke(oname, "isServiced",
+ params, signature);
+ return result.booleanValue();
+ }
+
+ /**
+ * Invoke the check method on the deployer.
+ */
+ protected void addServiced(String name) throws Exception {
+ String[] params = { name };
+ String[] signature = { "java.lang.String" };
+ mBeanServer.invoke(oname, "addServiced", params, signature);
+ }
+
+ /**
+ * Invoke the check method on the deployer.
+ */
+ protected void removeServiced(String name) throws Exception {
+ String[] params = { name };
+ String[] signature = { "java.lang.String" };
+ mBeanServer.invoke(oname, "removeServiced", params, signature);
+ }
+
+ /*--Instance Getters/Setters--------------------------------*/
+ public CatalinaCluster getCluster() {
+ return cluster;
+ }
+
+ public void setCluster(CatalinaCluster cluster) {
+ this.cluster = cluster;
+ }
+
+ public boolean equals(Object listener) {
+ return super.equals(listener);
+ }
+
+ public int hashCode() {
+ return super.hashCode();
+ }
+
+ public String getDeployDir() {
+ return deployDir;
+ }
+
+ public void setDeployDir(String deployDir) {
+ this.deployDir = deployDir;
+ }
+
+ public String getTempDir() {
+ return tempDir;
+ }
+
+ public void setTempDir(String tempDir) {
+ this.tempDir = tempDir;
+ }
+
+ public String getWatchDir() {
+ return watchDir;
+ }
+
+ public void setWatchDir(String watchDir) {
+ this.watchDir = watchDir;
+ }
+
+ public boolean isWatchEnabled() {
+ return watchEnabled;
+ }
+
+ public boolean getWatchEnabled() {
+ return watchEnabled;
+ }
+
+ public void setWatchEnabled(boolean watchEnabled) {
+ this.watchEnabled = watchEnabled;
+ }
+
+ /**
+ * Return the frequency of watcher checks.
+ */
+ public int getProcessDeployFrequency() {
+
+ return (this.processDeployFrequency);
+
+ }
+
+ /**
+ * Set the watcher checks frequency.
+ *
+ * @param processExpiresFrequency
+ * the new manager checks frequency
+ */
+ public void setProcessDeployFrequency(int processExpiresFrequency) {
+
+ if (processExpiresFrequency <= 0) {
+ return;
+ }
+ this.processDeployFrequency = processExpiresFrequency;
+ }
+
+ /**
+ * Copy a file to the specified temp directory.
+ * @param from copy from temp
+ * @param to to host appBase directory
+ * @return true, copy successful
+ */
+ protected boolean copy(File from, File to) {
+ try {
+ if (!to.exists())
+ to.createNewFile();
+ java.io.FileInputStream is = new java.io.FileInputStream(from);
+ java.io.FileOutputStream os = new java.io.FileOutputStream(to,
+ false);
+ byte[] buf = new byte[4096];
+ while (true) {
+ int len = is.read(buf);
+ if (len < 0)
+ break;
+ os.write(buf, 0, len);
+ }
+ is.close();
+ os.close();
+ } catch (IOException e) {
+ log.error("Unable to copy file from:" + from + " to:" + to, e);
+ return false;
+ }
+ return true;
+ }
+
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileChangeListener.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileChangeListener.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileChangeListener.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileChangeListener.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,23 @@
+/*
+ * 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
+ * limitations under the License.
+ */
+
+package org.apache.catalina.ha.deploy;
+import java.io.File;
+
+public interface FileChangeListener {
+ public void fileModified(File f);
+ public void fileRemoved(File f);
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileMessage.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileMessage.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileMessage.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/ha/deploy/FileMessage.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,112 @@
+/*
+ * 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
+ * limitations under the License.
+ */
+
+package org.apache.catalina.ha.deploy;
+
+import java.io.Serializable;
+
+import org.apache.catalina.ha.ClusterMessage;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.ha.ClusterMessageBase;
+
+/**
+ * Contains the data for a file being transferred over TCP, this is
+ * essentially a fragment of a file, read and written by the FileMessageFactory
+ * @author Filip Hanik
+ * @version 1.0
+ */
+
+public class FileMessage extends ClusterMessageBase implements ClusterMessage, Serializable {
+ private int messageNumber;
+ private byte[] data;
+ private int dataLength;
+
+ private long totalLength;
+ private long totalNrOfMsgs;
+ private String fileName;
+ private String contextPath;
+
+ public FileMessage(Member source,
+ String fileName,
+ String contextPath) {
+ this.address=source;
+ this.fileName=fileName;
+ this.contextPath=contextPath;
+ }
+
+ /*
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+
+ }
+ */
+
+ public int getMessageNumber() {
+ return messageNumber;
+ }
+ public void setMessageNumber(int messageNumber) {
+ this.messageNumber = messageNumber;
+ }
+ public long getTotalNrOfMsgs() {
+ return totalNrOfMsgs;
+ }
+ public void setTotalNrOfMsgs(long totalNrOfMsgs) {
+ this.totalNrOfMsgs = totalNrOfMsgs;
+ }
+ public byte[] getData() {
+ return data;
+ }
+ public void setData(byte[] data, int length) {
+ this.data = data;
+ this.dataLength = length;
+ }
+ public int getDataLength() {
+ return dataLength;
+ }
+ public void setDataLength(int dataLength) {
+ this.dataLength = dataLength;
+ }
+ public long getTotalLength() {
+ return totalLength;
+ }
+ public void setTotalLength(long totalLength) {
+ this.totalLength = totalLength;
+ }
+
+ public String getUniqueId() {
+ StringBuffer result = new StringBuffer(getFileName());
+ result.append("#-#");
+ result.append(getMessageNumber());
+ result.append("#-#");
+ result.append(System.currentTimeMillis());
+ return result.toString();
+ }
+
+
+ public String getFileName() {
+ return fileName;
+ }
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+ public String getContextPath() {
+ return contextPath;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org