public class FarmWarDeployer extends ClusterListener implements ClusterDeployer, FileChangeListener
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| Modifier and Type | Field and Description |
|---|---|
protected File |
configBase
Path where context descriptors should be deployed.
|
protected String |
deployDir
Deployment directory.
|
protected HashMap<String,FileMessageFactory> |
fileFactories |
protected Host |
host
The associated host.
|
protected int |
maxValidTime
The maximum valid time(in seconds) for FileMessageFactory.
|
protected MBeanServer |
mBeanServer
MBean server.
|
protected ObjectName |
oname
The associated deployer ObjectName.
|
protected int |
processDeployFrequency
Frequency of the Farm watchDir check.
|
protected boolean |
started |
protected String |
tempDir
Temporary directory.
|
protected String |
watchDir
Watch directory.
|
protected boolean |
watchEnabled |
protected WarWatcher |
watcher |
cluster| Constructor and Description |
|---|
FarmWarDeployer() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(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 header
|
protected void |
addServiced(String name)
Mark a context as being services.
|
void |
backgroundProcess()
Call watcher to check for deploy changes
|
protected void |
check(String name)
Check a context for deployment operations.
|
protected boolean |
copy(File from,
File to)
Copy a file to the specified temp directory.
|
boolean |
equals(Object listener) |
void |
fileModified(File newWar)
Modification from watchDir war detected!
|
void |
fileRemoved(File removeWar)
War remove from watchDir
|
String |
getDeployDir() |
File |
getDeployDirFile() |
FileMessageFactory |
getFactory(FileMessage msg)
Create factory for all transported war files
|
int |
getMaxValidTime() |
int |
getProcessDeployFrequency() |
String |
getTempDir() |
File |
getTempDirFile() |
String |
getWatchDir() |
File |
getWatchDirFile() |
boolean |
getWatchEnabled() |
int |
hashCode() |
void |
install(String contextName,
File webapp)
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 name.
|
protected boolean |
isServiced(String name)
Verified if a context is being services.
|
boolean |
isWatchEnabled() |
void |
messageReceived(ClusterMessage msg)
Callback from the cluster, when a message is received, The cluster will
broadcast it invoking the messageReceived on the receiver.
|
protected void |
remove(String contextName)
Invoke the remove method on the deployer.
|
void |
remove(String contextName,
boolean undeploy)
Remove an existing web application, attached to the specified context
name.
|
void |
removeFactory(FileMessage msg)
Remove file (war) from messages
|
protected void |
removeInvalidFileFactories() |
protected void |
removeServiced(String name)
Mark a context as no longer being serviced.
|
void |
setDeployDir(String deployDir) |
void |
setMaxValidTime(int maxValidTime) |
void |
setProcessDeployFrequency(int processExpiresFrequency)
Set the watcher checks frequency.
|
void |
setTempDir(String tempDir) |
void |
setWatchDir(String watchDir) |
void |
setWatchEnabled(boolean watchEnabled) |
void |
start()
Start the cluster deployer, the owning container will invoke this
|
void |
stop()
Stops the cluster deployer, the owning container will invoke this
|
protected void |
undeployDir(File dir)
Delete the specified directory, including all of its contents and
subdirectories recursively.
|
accept, getCluster, messageReceived, setClusterclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetCluster, setClusteraccept, messageReceivedprotected boolean started
protected final HashMap<String,FileMessageFactory> fileFactories
protected String deployDir
protected String tempDir
protected String watchDir
protected boolean watchEnabled
protected WarWatcher watcher
protected int processDeployFrequency
protected File configBase
protected Host host
protected MBeanServer mBeanServer
protected ObjectName oname
protected int maxValidTime
public void start()
throws Exception
ClusterDeployerstart in interface ClusterDeployerException - - if failure to start clusterpublic void stop()
throws LifecycleException
ClusterDeployerstop in interface ClusterDeployerLifecycleException - Error stopping cluster deployerpublic void messageReceived(ClusterMessage msg)
messageReceived in class ClusterListenermsg - ClusterMessage - the message received from the clusterpublic FileMessageFactory getFactory(FileMessage msg) throws FileNotFoundException, IOException
msg - The fileFileNotFoundException - Missing file errorIOException - Other IO errorpublic void removeFactory(FileMessage msg)
msg - The filepublic boolean accept(ClusterMessage msg)
accept in class ClusterListenermsg - ClusterMessagepublic void install(String contextName, File webapp) throws IOException
If this application is successfully installed locally, a ContainerEvent
of type INSTALL_EVENT will be sent to all registered
listeners, with the newly created Context as an argument.
install in interface ClusterDeployercontextName - 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 installedIllegalArgumentException - if the specified context name is malformedIllegalStateException - if the specified context name is already deployedIOException - if an input/output error was encountered during
installationpublic void remove(String contextName, boolean undeploy) throws IOException
REMOVE_EVENT will be sent to all registered
listeners, with the removed Context as an argument.
Deletes the web application war file and/or directory if they exist in
the Host's appBase.remove in interface ClusterDeployercontextName - The context name of the application to be removedundeploy - boolean flag to remove web application from serverIllegalArgumentException - if the specified context name is malformedIllegalArgumentException - if the specified context name does not identify a
currently installed web applicationIOException - if an input/output error occurs during removalpublic void fileModified(File newWar)
fileModified in interface FileChangeListenerFileChangeListener.fileModified(File)public void fileRemoved(File removeWar)
fileRemoved in interface FileChangeListenerFileChangeListener.fileRemoved(File)protected void remove(String contextName) throws Exception
contextName - The context to removeException - If an error occurs removing the contextprotected void undeployDir(File dir)
dir - File object representing the directory to be deletedpublic void backgroundProcess()
backgroundProcess in interface ClusterDeployerClusterDeployer.backgroundProcess()protected void check(String name) throws Exception
name - The context nameException - Error invoking the deployerprotected boolean isServiced(String name) throws Exception
name - The context nametrue if the context is being servicedException - Error invoking the deployerprotected void addServiced(String name) throws Exception
name - The context nameException - Error invoking the deployerprotected void removeServiced(String name) throws Exception
name - The context nameException - Error invoking the deployerpublic boolean equals(Object listener)
equals in interface ChannelListenerequals in class Objectlistener - ObjectObject.equals(Object)public int hashCode()
hashCode in interface ChannelListenerhashCode in class ObjectObject.hashCode()public String getDeployDir()
public File getDeployDirFile()
public void setDeployDir(String deployDir)
public String getTempDir()
public File getTempDirFile()
public void setTempDir(String tempDir)
public String getWatchDir()
public File getWatchDirFile()
public void setWatchDir(String watchDir)
public boolean isWatchEnabled()
public boolean getWatchEnabled()
public void setWatchEnabled(boolean watchEnabled)
public int getProcessDeployFrequency()
public void setProcessDeployFrequency(int processExpiresFrequency)
processExpiresFrequency - the new manager checks frequencypublic int getMaxValidTime()
public void setMaxValidTime(int maxValidTime)
protected boolean copy(File from, File to)
from - copy from tempto - to host appBase directoryprotected void removeInvalidFileFactories()
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.