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 |
copyInstallResources()
Files and templates to be copied to the server before installation.
|
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)
Runs a script and returns the result code
|
int |
execute(java.util.Map flags2,
java.util.List<java.lang.String> script,
java.lang.String summaryForLogging)
Runs a script and returns the result code, supporting flags including:
out, err as output/error streams;
logPrefix, prefix string to put in log output;
env, map of environment vars to pass to shell environment
|
int |
execute(java.lang.String command,
java.lang.String summaryForLogging) |
java.lang.String |
getAddress() |
java.lang.String |
getExpandedInstallDir() |
java.lang.String |
getHostname() |
java.lang.String |
getInstallDir() |
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 |
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 |
getSubnetAddress() |
java.lang.String |
getSubnetHostname() |
void |
runPostInstallCommand(java.lang.String command) |
void |
runPostLaunchCommand(java.lang.String command) |
void |
runPreInstallCommand(java.lang.String command) |
void |
runPreLaunchCommand(java.lang.String command) |
void |
setExpandedInstallDir(java.lang.String val) |
void |
setup() |
copyPreInstallResources, copyResource, copyResource, copyResource, copyResource, copyResource, copyResource, copyResource, copyRuntimeResources, copyTemplate, copyTemplate, copyTemplate, customize, getEntity, getResource, getResourceAsString, getVersion, install, kill, launch, postLaunch, preInstall, processTemplate, processTemplate, processTemplate, processTemplate, processTemplateContents, processTemplateContents, rebind, restart, start, stop
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isRunning
public 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 SshMachineLocation getLocation()
getLocation
in interface EntityDriver
getLocation
in class AbstractSoftwareProcessDriver
public java.lang.String getInstallDir()
getInstallDir
in class AbstractSoftwareProcessDriver
public java.lang.String getRunDir()
getRunDir
in class AbstractSoftwareProcessDriver
public void setExpandedInstallDir(java.lang.String val)
public java.lang.String getExpandedInstallDir()
public SshMachineLocation getMachine()
public java.lang.String getHostname()
public java.lang.String getAddress()
public java.lang.String getSubnetHostname()
public java.lang.String getSubnetAddress()
public int execute(java.lang.String command, java.lang.String summaryForLogging)
public int execute(java.util.List<java.lang.String> script, java.lang.String summaryForLogging)
NaiveScriptRunner
execute
in interface NaiveScriptRunner
public int execute(java.util.Map flags2, java.util.List<java.lang.String> script, java.lang.String summaryForLogging)
NaiveScriptRunner
execute
in interface NaiveScriptRunner
public void copyInstallResources()
AbstractSoftwareProcessDriver
AbstractSoftwareProcessDriver.install()
process to have access to all required resources.
Will be prefixed with the entity's install directory
if relative.
public void runPreInstallCommand(java.lang.String command)
runPreInstallCommand
in class AbstractSoftwareProcessDriver
public void runPostInstallCommand(java.lang.String command)
runPostInstallCommand
in class AbstractSoftwareProcessDriver
public void runPreLaunchCommand(java.lang.String command)
runPreLaunchCommand
in class AbstractSoftwareProcessDriver
public void runPostLaunchCommand(java.lang.String command)
runPostLaunchCommand
in class AbstractSoftwareProcessDriver
public java.util.Map<java.lang.String,java.lang.String> getShellEnvironment()
SoftwareProcess.SHELL_ENVIRONMENT
public 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 AbstractSoftwareProcessDriver
sshFlags
- 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 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 AbstractSoftwareProcessDriver
for parameter descriptions.
public void checkNoHostnameBug()
public java.util.Set<java.lang.Integer> getPortsUsed()
public void setup()
setup
in class AbstractSoftwareProcessDriver