Author: fhanik
Date: Mon Apr 3 07:51:30 2006
New Revision: 391057
URL: http://svn.apache.org/viewcvs?rev=391057&view=rev
Log:
Fixed ROOT.war deployment, aligned with Pero's fixes
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterDeployer.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterListener.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/FarmWarDeployer.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/UndeployMessage.java
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/WarWatcher.java
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterDeployer.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterDeployer.java?rev=391057&r1=391056&r2=391057&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterDeployer.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterDeployer.java
Mon Apr 3 07:51:30 2006
@@ -26,9 +26,9 @@
import org.apache.catalina.LifecycleException;
import java.io.IOException;
import java.net.URL;
-import org.apache.catalina.tribes.MessageListener;
+import org.apache.catalina.tribes.ChannelListener;
-public interface ClusterDeployer extends MessageListener {
+public interface ClusterDeployer extends ChannelListener {
/**
* Descriptive information about this component implementation.
*/
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterListener.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterListener.java?rev=391057&r1=391056&r2=391057&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterListener.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/ClusterListener.java
Mon Apr 3 07:51:30 2006
@@ -19,9 +19,11 @@
-import org.apache.catalina.util.StringManager;
-import org.apache.catalina.tribes.MessageListener;
+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;
/**
@@ -32,7 +34,7 @@
* @author Filip Hanik
* @version $Revision: 378258 $ $Date: 2006-02-16 08:42:35 -0600 (Thu, 16 Feb
2006) $
*/
-public abstract class ClusterListener implements MessageListener {
+public abstract class ClusterListener implements ChannelListener {
public static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(ClusterListener.class);
@@ -76,14 +78,15 @@
}
//--Logic---------------------------------------------------
- public final void messageReceived(ChannelMessage msg) {
+
+ public final void messageReceived(Serializable msg, Member member) {
if ( msg instanceof ClusterMessage )
messageReceived((ClusterMessage)msg);
}
-
- public final boolean accept(ChannelMessage msg) {
+ public final boolean accept(Serializable msg, Member member) {
if ( msg instanceof ClusterMessage ) return true;
return false;
}
+
/**
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/FarmWarDeployer.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/FarmWarDeployer.java?rev=391057&r1=391056&r2=391057&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/FarmWarDeployer.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/FarmWarDeployer.java
Mon Apr 3 07:51:30 2006
@@ -34,6 +34,7 @@
import org.apache.catalina.ha.ClusterMessage;
import org.apache.catalina.tribes.Member;
import org.apache.commons.modeler.Registry;
+import java.io.Serializable;
import org.apache.catalina.ha.ClusterListener;
/**
@@ -53,12 +54,16 @@
*
* @author Filip Hanik
* @author Peter Rossbach
- * @version 1.1
+ * @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;
@@ -118,6 +123,17 @@
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)
@@ -128,7 +144,7 @@
if (log.isInfoEnabled())
log.info("Cluster deployment is watching " + getWatchDir()
+ " for changes.");
- } //end if
+ }
// Check to correct engine and host setup
host = (Host) getCluster().getContainer();
@@ -159,7 +175,7 @@
/*
* stop cluster wide deployments
*
- * @see org.apache.catalina.ha.ClusterDeployer#stop()
+ * @see org.apache.catalina.cluster.ClusterDeployer#stop()
*/
public void stop() throws LifecycleException {
started = false;
@@ -186,8 +202,6 @@
* @param msg
* ClusterMessage - the message received from the cluster
*/
-
-
public void messageReceived(ClusterMessage msg) {
try {
if (msg instanceof FileMessage && msg != null) {
@@ -227,7 +241,7 @@
} finally {
removeFactory(fmsg);
}
- } //end if
+ }
} else if (msg instanceof UndeployMessage && msg != null) {
try {
UndeployMessage umsg = (UndeployMessage) msg;
@@ -245,18 +259,16 @@
log.debug("undeployment from " + path
+ " finished.");
} else
- log
- .error("Application "
- + path
- + " in used. Sorry not remove from
backup cluster nodes!");
+ log.error("Application "
+ + path
+ + " in used. Sorry not remove from backup cluster
nodes!");
} catch (Exception ex) {
log.error(ex);
}
- } //end if
+ }
} catch (java.io.IOException x) {
log.error("Unable to read farm deploy file message.", x);
}
- return;
}
/**
@@ -350,9 +362,9 @@
log.debug("Send cluster war fragment [ path: "
+ contextPath + " war: " + war + " to: " +
members[i] + " ]");
getCluster().send(msg, members[i]);
- } //for
+ }
msg = factory.readMessage(msg);
- } //while
+ }
if(log.isDebugEnabled())
log.debug("Send cluster war deployment [ path: "
+ contextPath + " war: " + war + " ] finished.");
@@ -383,8 +395,8 @@
public void remove(String contextPath, boolean undeploy) throws
IOException {
if (log.isInfoEnabled())
log.info("Cluster wide remove of web app " + contextPath);
- // send to other nodes
- UndeployMessage msg = new UndeployMessage(System
+ Member localMember = getCluster().getLocalMember();
+ UndeployMessage msg = new UndeployMessage(localMember, System
.currentTimeMillis(), "Undeploy:" + contextPath + ":"
+ System.currentTimeMillis(), contextPath, undeploy);
if (log.isDebugEnabled())
@@ -415,15 +427,13 @@
/*
* Modifcation from watchDir war detected!
*
- * @see
org.apache.catalina.ha.deploy.FileChangeListener#fileModified(java.io.File)
+ * @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 = "/"
- + deployWar.getName().substring(0,
- deployWar.getName().lastIndexOf(".war"));
+ String contextName = getContextName(deployWar);
if (log.isInfoEnabled())
log.info("Installing webapp[" + contextName + "] from "
+ deployWar.getAbsolutePath());
@@ -441,13 +451,11 @@
/*
* War remvoe from watchDir
*
- * @see
org.apache.catalina.ha.deploy.FileChangeListener#fileRemoved(java.io.File)
+ * @see
org.apache.catalina.cluster.deploy.FileChangeListener#fileRemoved(java.io.File)
*/
public void fileRemoved(File removeWar) {
try {
- String contextName = "/"
- + removeWar.getName().substring(0,
- removeWar.getName().lastIndexOf(".war"));
+ String contextName = getContextName(removeWar);
if (log.isInfoEnabled())
log.info("Removing webapp[" + contextName + "]");
remove(contextName, true);
@@ -457,6 +465,20 @@
}
/**
+ * 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) {
@@ -560,7 +582,7 @@
/*
* Call watcher to check for deploy changes
*
- * @see org.apache.catalina.ha.ClusterDeployer#backgroundProcess()
+ * @see org.apache.catalina.cluster.ClusterDeployer#backgroundProcess()
*/
public void backgroundProcess() {
if (started) {
@@ -689,8 +711,10 @@
}
/**
- * Copy a file to the specified temp directory. This is required only
- * because Jasper depends on it.
+ * 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 {
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/UndeployMessage.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/UndeployMessage.java?rev=391057&r1=391056&r2=391057&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/UndeployMessage.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/UndeployMessage.java
Mon Apr 3 07:51:30 2006
@@ -16,22 +16,25 @@
package org.apache.catalina.ha.deploy;
-import java.io.Serializable;
-
import org.apache.catalina.ha.ClusterMessage;
-import org.apache.catalina.ha.ClusterMessageBase;
-
-public class UndeployMessage extends ClusterMessageBase implements
ClusterMessage,Serializable {
+import org.apache.catalina.tribes.Member;
+import java.io.Serializable;
+public class UndeployMessage implements ClusterMessage,Serializable {
+ private Member address;
private long timestamp;
private String uniqueId;
private String contextPath;
private boolean undeploy;
+ private int resend = 0;
+ private int compress = 0;
public UndeployMessage() {} //for serialization
- public UndeployMessage(long timestamp,
+ public UndeployMessage(Member address,
+ long timestamp,
String uniqueId,
String contextPath,
boolean undeploy) {
+ this.address = address;
this.timestamp= timestamp;
this.undeploy = undeploy;
this.uniqueId = uniqueId;
@@ -39,6 +42,13 @@
this.contextPath = contextPath;
}
+ public Member getAddress() {
+ return address;
+ }
+
+ public void setAddress(Member address) {
+ this.address = address;
+ }
public long getTimestamp() {
return timestamp;
@@ -71,4 +81,33 @@
public void setUndeploy(boolean undeploy) {
this.undeploy = undeploy;
}
+ /**
+ * @return Returns the compress.
+ * @since 5.5.10
+ */
+ public int getCompress() {
+ return compress;
+ }
+ /**
+ * @param compress The compress to set.
+ * @since 5.5.10
+ */
+ public void setCompress(int compress) {
+ this.compress = compress;
+ }
+ /**
+ * @return Returns the resend.
+ * @since 5.5.10
+ */
+ public int getResend() {
+ return resend;
+ }
+ /**
+ * @param resend The resend to set.
+ * @since 5.5.10
+ */
+ public void setResend(int resend) {
+ this.resend = resend;
+ }
+
}
Modified:
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/WarWatcher.java
URL:
http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/WarWatcher.java?rev=391057&r1=391056&r2=391057&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/WarWatcher.java
(original)
+++
tomcat/container/tc5.5.x/modules/ha/src/share/org/apache/catalina/ha/deploy/WarWatcher.java
Mon Apr 3 07:51:30 2006
@@ -79,7 +79,7 @@
//first make sure all the files are listed in our current status
for (int i = 0; i < list.length; i++) {
addWarInfo(list[i]);
- }//for
+ }
//check all the status codes and update the FarmDeployer
for (Iterator i = currentStatus.entrySet().iterator(); i.hasNext();) {
@@ -92,8 +92,8 @@
listener.fileRemoved(info.getWar());
//no need to keep in memory
currentStatus.remove(info.getWar());
- }//end if
- }//for
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]