public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareProcessDriver implements NaiveScriptRunner
AbstractSoftwareProcessDriver.
This provides conveniences for clients implementing the install/customize/launch/isRunning/stop lifecycle
over SSH. These conveniences include checking whether software is already installed,
creating/using a PID file for some operations, and reading ssh-specific config from the entity
to override/augment ssh flags on the session.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CHECK_RUNNING |
static java.lang.String |
CUSTOMIZING |
static java.lang.String |
DEBUG
Enable shell debugging output via
set -x prepended to the command header. |
static java.lang.String |
IGNORE_ENTITY_SSH_FLAGS
include this flag in newScript creation to prevent entity-level flags from being included;
any SSH-specific flags passed to newScript override flags from the entity,
and flags from the entity override flags on the location
(where there aren't conflicts, flags from all three are used however)
|
static java.lang.String |
INSTALL_INCOMPLETE
Prevents creation of the
$INSTALL_DIR/BROOKLYN marker file after installing
phase finishes, to allow further installation phases to execute. |
static java.lang.String |
INSTALLING |
static java.lang.String |
KILLING |
static java.lang.String |
LAUNCHING |
static org.slf4j.Logger |
log |
static org.slf4j.Logger |
logSsh |
static java.lang.String |
NON_STANDARD_LAYOUT
Marks the script as having a customised setup, to prevent the default headers and footers being
added to the list of commands.
|
static java.lang.String |
PID_FILENAME |
static java.lang.String |
PROCESS_OWNER
Define the process owner if not the same as the brooklyn user.
|
static java.lang.String |
RESTARTING |
static java.lang.String |
STOPPING |
static java.lang.String |
USE_PID_FILE
Use a PID file, created by launching, and reading it for check-running,
stopping and killing.
|
static java.util.List<java.lang.String> |
VALID_FLAGS
Permitted flags for
newScript(Map, String). |
| Constructor and Description |
|---|
AbstractSoftwareProcessSshDriver(EntityLocal entity,
SshMachineLocation machine) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkNoHostnameBug() |
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.util.Map<java.lang.Object,java.lang.Object> sshFlags,
java.io.InputStream source,
java.lang.String target,
boolean createParentDir)
Input stream will be closed automatically.
|
int |
copyResource(java.util.Map<java.lang.Object,java.lang.Object> sshFlags,
java.lang.String source,
java.lang.String target,
boolean createParentDir) |
int |
execute(java.util.List<java.lang.String> script,
java.lang.String summaryForLogging)
Deprecated.
since 0.10.0 This method will become private in a future release.
|
int |
execute(java.util.Map flags2,
java.util.List<java.lang.String> script,
java.lang.String summaryForLogging)
Deprecated.
since 0.10.0 This method will become private in a future release.
|
int |
execute(java.lang.String command,
java.lang.String summaryForLogging)
Deprecated.
since 0.10.0 This method will become private in a future release.
|
java.lang.String |
getAddress() |
java.lang.String |
getHostname() |
SshMachineLocation |
getLocation()
returns location (tighten type, since we know it is an ssh machine location here)
|
SshMachineLocation |
getMachine() |
java.util.Set<java.lang.Integer> |
getPortsUsed() |
java.lang.String |
getSubnetAddress() |
java.lang.String |
getSubnetHostname() |
void |
prepare()
Prepare the entity instance before running any commands.
|
void |
runPostCustomizeCommand()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
void |
runPostInstallCommand()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
void |
runPostLaunchCommand()
Only run if launch is run (if start is not skipped).
|
void |
runPreCustomizeCommand()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
void |
runPreInstallCommand()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
void |
runPreLaunchCommand()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
void |
setup()
Implementations should fail if the return code is non-zero, by throwing some appropriate exception.
|
copyResource, copyResource, copyResource, copyResource, copyResource, copyResource, copyResource, copyRuntimeResources, copyTemplate, copyTemplate, copyTemplate, customize, getArchiveNameFormat, getEntity, getExpandedInstallDir, getInstallDir, getResource, getResourceAsString, getRunDir, getShellEnvironment, getVersion, install, kill, launch, postLaunch, preInstall, processTemplate, processTemplate, processTemplate, processTemplate, processTemplateContents, processTemplateContents, rebind, restart, setExpandedInstallDir, start, stopequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisRunningpublic static final org.slf4j.Logger log
public static final org.slf4j.Logger logSsh
public static final java.lang.String IGNORE_ENTITY_SSH_FLAGS
public static final java.lang.String INSTALLING
public static final java.lang.String CUSTOMIZING
public static final java.lang.String LAUNCHING
public static final java.lang.String CHECK_RUNNING
public static final java.lang.String STOPPING
public static final java.lang.String KILLING
public static final java.lang.String RESTARTING
public static final java.lang.String PID_FILENAME
public static final java.lang.String USE_PID_FILE
public static final java.lang.String PROCESS_OWNER
kill command. Only valid
if USE_PID_FILE is also set.public static final java.lang.String NON_STANDARD_LAYOUT
public static final java.lang.String INSTALL_INCOMPLETE
$INSTALL_DIR/BROOKLYN marker file after installing
phase finishes, to allow further installation phases to execute.public static final java.lang.String DEBUG
set -x prepended to the command header.public static final java.util.List<java.lang.String> VALID_FLAGS
newScript(Map, String).public AbstractSoftwareProcessSshDriver(EntityLocal entity, SshMachineLocation machine)
public void prepare()
AbstractSoftwareProcessDriverAbstractSoftwareProcessDriver.start().prepare in class AbstractSoftwareProcessDriverpublic SshMachineLocation getLocation()
getLocation in interface EntityDrivergetLocation in class AbstractSoftwareProcessDriverpublic SshMachineLocation getMachine()
public java.lang.String getHostname()
public java.lang.String getAddress()
public java.lang.String getSubnetHostname()
public java.lang.String getSubnetAddress()
@Deprecated
public int execute(java.lang.String command,
java.lang.String summaryForLogging)
@Deprecated
public int execute(java.util.List<java.lang.String> script,
java.lang.String summaryForLogging)
NaiveScriptRunnerexecute in interface NaiveScriptRunner@Deprecated
public int execute(java.util.Map flags2,
java.util.List<java.lang.String> script,
java.lang.String summaryForLogging)
NaiveScriptRunnerexecute in interface NaiveScriptRunnerpublic void copyPreInstallResources()
AbstractSoftwareProcessDriverAbstractSoftwareProcessDriver.preInstall()
process to have access to all required resources.
Will be prefixed with the entity's install directory if relative.
public void copyInstallResources()
AbstractSoftwareProcessDriverAbstractSoftwareProcessDriver.install()
process to have access to all required resources.
Will be prefixed with the entity's install directory if relative.
public void copyCustomizeResources()
AbstractSoftwareProcessDriverAbstractSoftwareProcessDriver.customize()
process to have access to all required resources.
Will be prefixed with the entity's install directory if relative.
public void runPreInstallCommand()
AbstractSoftwareProcessDriverrunPreInstallCommand in class AbstractSoftwareProcessDriverpublic void runPostInstallCommand()
AbstractSoftwareProcessDriverrunPostInstallCommand in class AbstractSoftwareProcessDriverpublic void runPreCustomizeCommand()
AbstractSoftwareProcessDriverrunPreCustomizeCommand in class AbstractSoftwareProcessDriverpublic void runPostCustomizeCommand()
AbstractSoftwareProcessDriverrunPostCustomizeCommand in class AbstractSoftwareProcessDriverpublic void runPreLaunchCommand()
AbstractSoftwareProcessDriverrunPreLaunchCommand in class AbstractSoftwareProcessDriverpublic void runPostLaunchCommand()
AbstractSoftwareProcessDriverrunPostLaunchCommand in class AbstractSoftwareProcessDriverpublic int copyResource(java.util.Map<java.lang.Object,java.lang.Object> sshFlags,
java.lang.String source,
java.lang.String target,
boolean createParentDir)
copyResource in class AbstractSoftwareProcessDriversshFlags - Extra flags to be used when making an SSH connection to the entity's machine.
If the map contains the key IGNORE_ENTITY_SSH_FLAGS then only the
given flags are used. Otherwise, the given flags are combined with (and take
precendence over) the flags returned by getSshFlags().source - URI of file to copy, e.g. file://.., http://.., classpath://..target - Destination on server, relative to AbstractSoftwareProcessDriver.getRunDir() if not absolute pathcreateParentDir - Whether to create the parent target directory, if it doesn't already existpublic int copyResource(java.util.Map<java.lang.Object,java.lang.Object> sshFlags,
java.io.InputStream source,
java.lang.String target,
boolean createParentDir)
If using SshjTool usage, consider using KnownSizeInputStream to avoid having
to write out stream once to find its size!
copyResource in class AbstractSoftwareProcessDriverfor parameter descriptions.public void checkNoHostnameBug()
public java.util.Set<java.lang.Integer> getPortsUsed()
public void setup()
AbstractSoftwareProcessDriversetup in class AbstractSoftwareProcessDriver