public class Deployer extends Object
| ORIGINAL | CURRENT | NEW | What To Do... |
|---|---|---|---|
| X | X | X | New file is installed over current* |
| X | X | Y | New file is installed over current |
| X | Y | X | Current file is left as-is |
| X | Y | Y | New file is installed over current* |
| X | Y | Z | New file is installed over current, current is backed up |
| none | ? | ? | New file is installed over current, current is backed up |
| X | none | ? | New file is installed |
| ? | ? | none | Current file is backed up and deleted |
DeploymentsMetadata.BACKUP_DIR. If a file
that needs to be backed up is referred to via an absolute path (that is, outside the destination
directory), it will be copied to the DeploymentsMetadata.EXT_BACKUP_DIR directory found
in the metadata directory.| Constructor and Description |
|---|
Deployer(DeploymentData deploymentData)
Constructors that prepares this object to deploy content to a destination on the local file system.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkDiskUsage()
This will get an
estimate of how much disk space the deployment will need
and compare it to the amount of estimated disk space is currently usable. |
FileHashcodeMap |
deploy(DeployDifferences diff)
Convienence method that is equivalent to
deploy(diff, false). |
FileHashcodeMap |
deploy(DeployDifferences diff,
boolean clean,
boolean dryRun)
Deploys all files to their destinations.
|
FileHashcodeMap |
dryRun(DeployDifferences diff)
Convienence method that is equivalent to
deploy(diff, true). |
DeploymentDiskUsage |
estimateDiskUsage()
Returns an estimated amount of disk space the deployment will need if it gets installed.
|
DeploymentData |
getDeploymentData() |
boolean |
isDestinationDirectoryManaged() |
FileHashcodeMap |
redeployAndRestoreBackupFiles(DeployDifferences diff,
boolean clean,
boolean dryRun)
This will first perform a deploy (e.g.
|
public Deployer(DeploymentData deploymentData)
deploymentData - the data needed to know what to do for this deploymentpublic DeploymentData getDeploymentData()
public boolean isDestinationDirectoryManaged()
true if the deployer is to install the deployment data in a directory
that already has a managed deployment in it. false if there is currently
no managed deployments in the destination directory.public FileHashcodeMap deploy(DeployDifferences diff) throws Exception
deploy(diff, false).Exception#deploy(DeployDifferences, boolean)public FileHashcodeMap dryRun(DeployDifferences diff) throws Exception
deploy(diff, true).Exception#deploy(DeployDifferences, boolean)public FileHashcodeMap deploy(DeployDifferences diff, boolean clean, boolean dryRun) throws Exception
diff object with what would have been done.
The caller can ask that an existing deployment directory be cleaned (i.e. wiped from the file system)
before the new deployment is laid down. This is useful if there are ignored files/directories
that would be left alone as-is, had a clean not been requested. Note that the clean
parameter is ignored if a dry run is being requested.diff - this method will populate this object with information about what
changed on the file system due to this deploymentclean - if true, the caller is telling this method to first wipe clean
any existing deployment files found in the destination directory before installing the
new deployment. Note that this will have no effect if dryRun
is true since a dry run by definition never affects the file system.dryRun - if true, the file system won't actually be changed; however,
the diff object will still be populated with information about
what would have occurred on the file system had it not been a dry runException - if the deployment failed for some reasonpublic FileHashcodeMap redeployAndRestoreBackupFiles(DeployDifferences diff, boolean clean, boolean dryRun) throws Exception
deploy(diff, clean, dryRun))
and then, if there are backup files from the previous deployment, those backup files will be restored to their
original locations.
This is useful when you want to "undeploy" something where "undeploy" infers you want to go back to
how the file system looked previously to a subsequent deployment (the one this method is being told
to "redeploy"), including manual changes that were made over top the previous deployment.
For example, suppose you deployed deployment ID #1 and then the user manually changed some files
within that #1 deployment. Later on, you deploy deployment ID #2 (which will not only deploy
#2's files but will also backup the files that were manually changed within deployment #1).
You find that deployment #2 is bad and you want to revert back to how the file system looked
previously. You could opt to rollback to deployment ID #1 minus those manual changes - to do
this you simply deploy #1 again. However, if you want to
go back to the previous content including those manual changes, you first deploy #1 and
then restore the backup files - essentially overlaying the manual changes over top #1 files. This
method accomplishes that latter task.diff - see deploy(DeployDifferences, boolean, boolean)clean - see deploy(DeployDifferences, boolean, boolean)dryRun - see deploy(DeployDifferences, boolean, boolean)deploy(DeployDifferences, boolean, boolean)Exception - if either the deployment or backup file restoration failedpublic DeploymentDiskUsage estimateDiskUsage() throws Exception
Exception - if cannot determine the estimated disk usagepublic void checkDiskUsage()
throws Exception
estimate of how much disk space the deployment will need
and compare it to the amount of estimated disk space is currently usable. If there does not appear to be
enough usable disk space to fit the deployment, this method will thrown an exception. Otherwise, this
method will simply return normally.
This can be used to fail-fast a deployment - there is no need to process the deployment if there is not
enough disk space to start with.Exception - if there does not appear to be enough disk space to store the deployment contentCopyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.