public abstract class AbstractSoftwareProcessDriver extends java.lang.Object implements SoftwareProcessDriver
SoftwareProcessDriver
.Constructor and Description |
---|
AbstractSoftwareProcessDriver(EntityLocal entity,
Location location) |
Modifier and Type | Method and Description |
---|---|
void |
copyCustomizeResources()
Files and templates to be copied to the server before customize.
|
void |
copyInstallResources()
Files and templates to be copied to the server before installation.
|
void |
copyPreInstallResources()
Files and templates to be copied to the server before pre-install.
|
int |
copyResource(java.io.File file,
java.lang.String target) |
int |
copyResource(java.io.InputStream source,
java.lang.String target) |
abstract int |
copyResource(java.util.Map<java.lang.Object,java.lang.Object> sshFlags,
java.io.InputStream source,
java.lang.String target,
boolean createParentDir) |
int |
copyResource(java.util.Map<java.lang.Object,java.lang.Object> sshFlags,
java.io.Reader source,
java.lang.String target,
boolean createParent) |
abstract int |
copyResource(java.util.Map<java.lang.Object,java.lang.Object> sshFlags,
java.lang.String sourceUrl,
java.lang.String target,
boolean createParentDir) |
int |
copyResource(java.util.Map sshFlags,
java.lang.String source,
java.lang.String target) |
int |
copyResource(java.io.Reader source,
java.lang.String target) |
int |
copyResource(java.lang.String resource,
java.lang.String target) |
int |
copyResource(java.lang.String resourceUrl,
java.lang.String target,
boolean createParentDir) |
void |
copyRuntimeResources()
Files and templates to be copied to the server after customisation.
|
int |
copyTemplate(java.io.File template,
java.lang.String target) |
int |
copyTemplate(java.lang.String template,
java.lang.String target) |
int |
copyTemplate(java.lang.String templateUrl,
java.lang.String target,
boolean createParent,
java.util.Map<java.lang.String,?> extraSubstitutions) |
abstract void |
customize()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
java.lang.String |
getArchiveNameFormat() |
EntityLocal |
getEntity()
The entity whose components we are controlling.
|
java.lang.String |
getExpandedInstallDir() |
java.lang.String |
getInstallDir() |
Location |
getLocation()
The location the entity is running in.
|
java.io.InputStream |
getResource(java.lang.String url) |
java.lang.String |
getResourceAsString(java.lang.String url) |
java.lang.String |
getRunDir() |
java.util.Map<java.lang.String,java.lang.String> |
getShellEnvironment()
The environment variables to be set when executing the commands (for install, run, check running, etc).
|
java.lang.String |
getVersion() |
abstract void |
install()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
void |
kill()
Kills the process, ungracefully and immediately where possible (e.g.
|
abstract void |
launch()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
void |
postLaunch()
Implement this method in child classes to add some post-launch behavior.
|
void |
preInstall()
Implement this method in child classes to add some pre-install behavior
|
void |
prepare()
Prepare the entity instance before running any commands.
|
java.lang.String |
processTemplate(java.io.File templateConfigFile) |
java.lang.String |
processTemplate(java.io.File templateConfigFile,
java.util.Map<java.lang.String,java.lang.Object> extraSubstitutions) |
java.lang.String |
processTemplate(java.lang.String templateConfigUrl)
Takes the contents of a template file from the given URL (often a classpath://com/myco/myprod/myfile.conf or .sh)
and replaces "${entity.xxx}" with the result of entity.getXxx() and similar for other driver, location;
as well as replacing config keys on the management context
|
java.lang.String |
processTemplate(java.lang.String templateConfigUrl,
java.util.Map<java.lang.String,? extends java.lang.Object> extraSubstitutions) |
java.lang.String |
processTemplateContents(java.lang.String templateContents) |
java.lang.String |
processTemplateContents(java.lang.String templateContents,
java.util.Map<java.lang.String,? extends java.lang.Object> extraSubstitutions) |
void |
rebind()
Rebinds the driver to a pre-existing software process.
|
void |
restart()
Performs software restart (or queues tasks to do this).
|
abstract void |
runPostCustomizeCommand()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
abstract void |
runPostInstallCommand()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
abstract void |
runPostLaunchCommand()
Only run if launch is run (if start is not skipped).
|
abstract void |
runPreCustomizeCommand()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
abstract void |
runPreInstallCommand()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
abstract void |
runPreLaunchCommand()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
void |
setExpandedInstallDir(java.lang.String val) |
abstract void |
setup()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
void |
start()
Start the entity.
|
abstract void |
stop()
Performs software stop (or queues tasks to do this)
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isRunning
public AbstractSoftwareProcessDriver(EntityLocal entity, Location location)
public void rebind()
SoftwareProcessDriver
rebind
in interface SoftwareProcessDriver
public void start()
This installs, configures and launches the application process. However,
users can also call the install()
, customize()
and
launch()
steps independently. The postLaunch()
will
be called after the launch()
metheod is executed, but the
process may not be completely initialised at this stage, so care is
required when implementing these stages.
The BrooklynConfigKeys.SKIP_ENTITY_START_IF_RUNNING
key can be set on the location
or the entity to skip the startup process if the entity is already running,
according to the SoftwareProcessDriver.isRunning()
method. To force the startup to be
skipped, BrooklynConfigKeys.SKIP_ENTITY_START
can be set on the entity.
The BrooklynConfigKeys.SKIP_ENTITY_INSTALLATION
key can also be used to
skip the setup()
, copyInstallResources()
and
install()
methods if set on the entity or location.
start
in interface SoftwareProcessDriver
stop()
public abstract void stop()
SoftwareProcessDriver
stop
in interface SoftwareProcessDriver
Startable.stop()
public void prepare()
start()
.public void preInstall()
public abstract void runPreInstallCommand()
public abstract void setup()
public abstract void install()
public abstract void runPostInstallCommand()
public abstract void runPreCustomizeCommand()
public abstract void customize()
public abstract void runPostCustomizeCommand()
public abstract void runPreLaunchCommand()
public abstract void launch()
public abstract void runPostLaunchCommand()
public void kill()
SoftwareProcessDriver
kill
in interface SoftwareProcessDriver
public void postLaunch()
public void restart()
SoftwareProcessDriver
restart
in interface SoftwareProcessDriver
Startable.restart()
public EntityLocal getEntity()
SoftwareProcessDriver
getEntity
in interface EntityDriver
getEntity
in interface SoftwareProcessDriver
public Location getLocation()
EntityDriver
getLocation
in interface EntityDriver
public java.io.InputStream getResource(java.lang.String url)
public void copyPreInstallResources()
preInstall()
process to have access to all required resources.
Will be prefixed with the entity's install directory
if relative.
public void copyInstallResources()
install()
process to have access to all required resources.
Will be prefixed with the entity's install directory
if relative.
public void copyCustomizeResources()
customize()
process to have access to all required resources.
Will be prefixed with the entity's install directory
if relative.
public void copyRuntimeResources()
customize()
process.
Will be prefixed with the entity's run directory
if relative.
public int copyTemplate(java.io.File template, java.lang.String target)
template
- File to template and copy.target
- Destination on server.public int copyTemplate(java.lang.String template, java.lang.String target)
template
- URI of file to template and copy, e.g. file://.., http://.., classpath://..target
- Destination on server.public int copyTemplate(java.lang.String templateUrl, java.lang.String target, boolean createParent, java.util.Map<java.lang.String,?> extraSubstitutions)
templateUrl
- URI of file to template and copy, e.g. file://.., http://.., classpath://..target
- Destination on server.extraSubstitutions
- Extra substitutions for the templater to use, for example
"foo" -> "bar", and in a template ${foo}.public abstract int copyResource(java.util.Map<java.lang.Object,java.lang.Object> sshFlags, java.lang.String sourceUrl, java.lang.String target, boolean createParentDir)
public abstract int copyResource(java.util.Map<java.lang.Object,java.lang.Object> sshFlags, java.io.InputStream source, java.lang.String target, boolean createParentDir)
public int copyResource(java.io.File file, java.lang.String target)
file
- File to copy.target
- Destination on server.public int copyResource(java.lang.String resource, java.lang.String target)
resource
- URI of file to copy, e.g. file://.., http://.., classpath://..target
- Destination on server.public int copyResource(java.lang.String resourceUrl, java.lang.String target, boolean createParentDir)
public int copyResource(java.util.Map sshFlags, java.lang.String source, java.lang.String target)
public int copyResource(java.io.Reader source, java.lang.String target)
public int copyResource(java.util.Map<java.lang.Object,java.lang.Object> sshFlags, java.io.Reader source, java.lang.String target, boolean createParent)
public int copyResource(java.io.InputStream source, java.lang.String target)
public java.lang.String getResourceAsString(java.lang.String url)
public java.lang.String processTemplate(java.io.File templateConfigFile, java.util.Map<java.lang.String,java.lang.Object> extraSubstitutions)
public java.lang.String processTemplate(java.io.File templateConfigFile)
public java.lang.String processTemplate(java.lang.String templateConfigUrl)
uses Freemarker templates under the covers
public java.lang.String processTemplate(java.lang.String templateConfigUrl, java.util.Map<java.lang.String,? extends java.lang.Object> extraSubstitutions)
public java.lang.String processTemplateContents(java.lang.String templateContents)
public java.lang.String processTemplateContents(java.lang.String templateContents, java.util.Map<java.lang.String,? extends java.lang.Object> extraSubstitutions)
public java.lang.String getArchiveNameFormat()
public java.lang.String getVersion()
public java.util.Map<java.lang.String,java.lang.String> getShellEnvironment()
SoftwareProcess.SHELL_ENVIRONMENT
public java.lang.String getInstallDir()
public java.lang.String getRunDir()
public void setExpandedInstallDir(java.lang.String val)
public java.lang.String getExpandedInstallDir()