Package org.apache.catalina.ha.deploy
Class FarmWarDeployer
java.lang.Object
org.apache.catalina.ha.ClusterListener
org.apache.catalina.ha.deploy.FarmWarDeployer
- All Implemented Interfaces:
- ClusterDeployer,- FileChangeListener,- ChannelListener
A farm war deployer is a class that is able to deploy/undeploy web applications in WAR from within the cluster.
Any host can act as the admin, and will have three directories- watchDir - the directory where we watch for changes
- deployDir - the directory where we install applications
- tempDir - a temporaryDirectory to store binary data when downloading a war from the cluster
- Author:
- Peter Rossbach
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected FilePath where context descriptors should be deployed.protected StringDeployment directory.protected final HashMap<String,FileMessageFactory> protected HostThe associated host.protected intThe maximum valid time(in seconds) for FileMessageFactory.protected MBeanServerMBean server.protected ObjectNameThe associated deployer ObjectName.protected intFrequency of the Farm watchDir check.protected booleanprotected StringTemporary directory.protected StringWatch directory.protected booleanprotected WarWatcherFields inherited from class org.apache.catalina.ha.ClusterListenercluster
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaccept(ClusterMessage msg) 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 headervoidCall watcher to check for deploy changesprotected voidCheck a context for deployment operations.protected booleanCopy a file to the specified temp directory.booleanvoidfileModified(File newWar) Modification from watchDir war detected!voidfileRemoved(File removeWar) War remove from watchDirgetFactory(FileMessage msg) Create factory for all transported war filesintintbooleaninthashCode()voidInstall 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 name.booleanvoidCallback from the cluster, when a message is received, The cluster will broadcast it invoking the messageReceived on the receiver.protected voidInvoke the remove method on the deployer.voidRemove an existing web application, attached to the specified context name.voidremoveFactory(FileMessage msg) Remove file (war) from messagesprotected voidprotected voidremoveServiced(String name) Mark a context as no longer being serviced.voidsetDeployDir(String deployDir) voidsetMaxValidTime(int maxValidTime) voidsetProcessDeployFrequency(int processExpiresFrequency) Set the watcher checks frequency.voidsetTempDir(String tempDir) voidsetWatchDir(String watchDir) voidsetWatchEnabled(boolean watchEnabled) voidstart()Start the cluster deployer, the owning container will invoke thisvoidstop()Stops the cluster deployer, the owning container will invoke thisprotected booleantryAddServiced(String name) Attempt to mark a context as being servicedprotected voidundeployDir(File dir) Delete the specified directory, including all of its contents and subdirectories recursively.Methods inherited from class org.apache.catalina.ha.ClusterListeneraccept, getCluster, messageReceived, setClusterMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.catalina.tribes.ChannelListeneraccept, messageReceivedMethods inherited from interface org.apache.catalina.ha.ClusterDeployergetCluster, setCluster
- 
Field Details- 
startedprotected boolean started
- 
fileFactories
- 
deployDirDeployment directory.
- 
tempDirTemporary directory.
- 
watchDirWatch directory.
- 
watchEnabledprotected boolean watchEnabled
- 
watcher
- 
processDeployFrequencyprotected int processDeployFrequencyFrequency of the Farm watchDir check. Cluster wide deployment will be done once for the specified amount of backgroundProcess calls (ie, the lower the amount, the most often the checks will occur).
- 
configBasePath where context descriptors should be deployed.
- 
hostThe associated host.
- 
mBeanServerMBean server.
- 
onameThe associated deployer ObjectName.
- 
maxValidTimeprotected int maxValidTimeThe maximum valid time(in seconds) for FileMessageFactory.
 
- 
- 
Constructor Details- 
FarmWarDeployerpublic FarmWarDeployer()
 
- 
- 
Method Details- 
startDescription copied from interface:ClusterDeployerStart the cluster deployer, the owning container will invoke this- Specified by:
- startin interface- ClusterDeployer
- Throws:
- Exception- - if failure to start cluster
 
- 
stopDescription copied from interface:ClusterDeployerStops the cluster deployer, the owning container will invoke this- Specified by:
- stopin interface- ClusterDeployer
- Throws:
- LifecycleException- Error stopping cluster deployer
 
- 
messageReceivedCallback from the cluster, when a message is received, The cluster will broadcast it invoking the messageReceived on the receiver.- Specified by:
- messageReceivedin class- ClusterListener
- Parameters:
- msg- ClusterMessage - the message received from the cluster
 
- 
getFactoryCreate factory for all transported war files- Parameters:
- msg- The file
- Returns:
- Factory for all app message (war files)
- Throws:
- FileNotFoundException- Missing file error
- IOException- Other IO error
 
- 
removeFactoryRemove file (war) from messages- Parameters:
- msg- The file
 
- 
acceptBefore 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- Specified by:
- acceptin class- ClusterListener
- Parameters:
- msg- ClusterMessage
- Returns:
- boolean - returns true to indicate that messageReceived should be invoked. If false is returned, the messageReceived method will not be invoked.
 
- 
installInstall 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 name.If this application is successfully installed locally, a ContainerEvent of type INSTALL_EVENTwill be sent to all registered listeners, with the newly createdContextas an argument.- Specified by:
- installin interface- ClusterDeployer
- Parameters:
- contextName- The context name to which this application should be installed (must be unique)
- webapp- A WAR file or unpacked directory structure containing the web application to be installed
- Throws:
- IllegalArgumentException- if the specified context name is malformed
- IllegalStateException- if the specified context name is already deployed
- IOException- if an input/output error was encountered during installation
 
- 
removeRemove an existing web application, attached to the specified context name. If this application is successfully removed, a ContainerEvent of typeREMOVE_EVENTwill be sent to all registered listeners, with the removedContextas an argument. Deletes the web application war file and/or directory if they exist in the Host's appBase.- Specified by:
- removein interface- ClusterDeployer
- Parameters:
- contextName- The context name of the application to be removed
- undeploy- boolean flag to remove web application from server
- Throws:
- IllegalArgumentException- if the specified context name is malformed
- IllegalArgumentException- if the specified context name does not identify a currently installed web application
- IOException- if an input/output error occurs during removal
 
- 
fileModifiedModification from watchDir war detected!- Specified by:
- fileModifiedin interface- FileChangeListener
- See Also:
 
- 
fileRemovedWar remove from watchDir- Specified by:
- fileRemovedin interface- FileChangeListener
- See Also:
 
- 
removeInvoke the remove method on the deployer.- Parameters:
- contextName- The context to remove
- Throws:
- Exception- If an error occurs removing the context
 
- 
undeployDirDelete the specified directory, including all of its contents and subdirectories recursively.- Parameters:
- dir- File object representing the directory to be deleted
 
- 
backgroundProcesspublic void backgroundProcess()Call watcher to check for deploy changes- Specified by:
- backgroundProcessin interface- ClusterDeployer
- See Also:
 
- 
checkCheck a context for deployment operations.- Parameters:
- name- The context name
- Throws:
- Exception- Error invoking the deployer
 
- 
tryAddServicedAttempt to mark a context as being serviced- Parameters:
- name- The context name
- Returns:
- trueif the application was marked as being serviced and- falseif the application was already marked as being serviced
- Throws:
- Exception- Error invoking the deployer
 
- 
removeServicedMark a context as no longer being serviced.- Parameters:
- name- The context name
- Throws:
- Exception- Error invoking the deployer
 
- 
equals- Specified by:
- equalsin interface- ChannelListener
- Overrides:
- equalsin class- Object
- Parameters:
- listener- Object
- Returns:
- boolean
- See Also:
 
- 
hashCodepublic int hashCode()- Specified by:
- hashCodein interface- ChannelListener
- Overrides:
- hashCodein class- Object
- Returns:
- int
- See Also:
 
- 
getDeployDir
- 
getDeployDirFile
- 
setDeployDir
- 
getTempDir
- 
getTempDirFile
- 
setTempDir
- 
getWatchDir
- 
getWatchDirFile
- 
setWatchDir
- 
isWatchEnabledpublic boolean isWatchEnabled()
- 
getWatchEnabledpublic boolean getWatchEnabled()
- 
setWatchEnabledpublic void setWatchEnabled(boolean watchEnabled) 
- 
getProcessDeployFrequencypublic int getProcessDeployFrequency()- Returns:
- the frequency of watcher checks.
 
- 
setProcessDeployFrequencypublic void setProcessDeployFrequency(int processExpiresFrequency) Set the watcher checks frequency.- Parameters:
- processExpiresFrequency- the new manager checks frequency
 
- 
getMaxValidTimepublic int getMaxValidTime()
- 
setMaxValidTimepublic void setMaxValidTime(int maxValidTime) 
- 
copyCopy a file to the specified temp directory.- Parameters:
- from- copy from temp
- to- to host appBase directory
- Returns:
- true, copy successful
 
- 
removeInvalidFileFactoriesprotected void removeInvalidFileFactories()
 
-