Brooklyn

brooklyn.entity.basic
[Java] Class AbstractSoftwareProcessSshDriver

java.lang.Object
  brooklyn.entity.basic.AbstractSoftwareProcessDriver
      brooklyn.entity.basic.AbstractSoftwareProcessSshDriver
All Implemented Interfaces:
NaiveScriptRunner

public abstract class AbstractSoftwareProcessSshDriver
extends AbstractSoftwareProcessDriver

An abstract SSH implementation of the 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.


Field Summary
static java.lang.String CHECK_RUNNING

static java.lang.String CUSTOMIZING

static java.lang.String DEBUG

@see #newScript(Map, String)

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 INSTALLING

static java.lang.String INSTALL_INCOMPLETE

Permitted flags for newScript(Map, String).

static java.lang.String KILLING

static java.lang.String LAUNCHING

static java.lang.String NON_STANDARD_LAYOUT

Enable shell debugging output via set -x prepended to the command header.

static java.lang.String PID_FILENAME

static java.lang.String PROCESS_OWNER

static java.lang.String RESTARTING

static java.lang.String STOPPING

static java.lang.String USE_PID_FILE

Define the process owner if not the same as the brooklyn user.

static java.util.List VALID_FLAGS

static Logger log

static Logger logSsh

 
Fields inherited from class AbstractSoftwareProcessDriver
entity, location, resource
 
Constructor Summary
AbstractSoftwareProcessSshDriver(EntityLocal entity, SshMachineLocation machine)

 
Method Summary
int copyResource(java.io.File file, java.lang.String target)

@param file File to copy.

int copyResource(java.lang.String resource, java.lang.String target)

int copyResource(java.util.Map sshFlags, java.lang.String source, java.lang.String target)

void copyResources(java.util.Map resources)

Copies all resources in the given map to the driver's machine.

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 template, java.lang.String target, java.util.Map extraSubstitutions)

void copyTemplates(java.util.Map templates)

Templates all resources in the given map, then copies them to the driver's machine.

int execute(java.util.List script, java.lang.String summaryForLogging)

int execute(java.util.Map flags2, java.util.List script, java.lang.String summaryForLogging)

java.lang.String getAddress()

java.lang.String getDownloadFileSuffix()

Suffix to use when looking up the file in the local repo.

java.lang.String getDownloadFilename()

Name to be used in the local repo, when looking for the download file.

protected java.lang.String getEntityVersionLabel()

@deprecated since 0.5.0; instead rely on DownloadResolverManager to include local-repo, such as:

protected java.lang.String getEntityVersionLabel(java.lang.String separator)

@deprecated since 0.5.0; instead rely on DownloadResolverManager to include local-repo

java.lang.String getExpandedInstallDir()

java.lang.String getHostname()

java.lang.String getInstallDir()

protected java.lang.String getInstallLabelExtraSalt()

allows subclasses to return extra salt (ie unique hash) for cases where install dirs need to be distinct e.g. based on extra plugins being placed in the install dir; setInstallLabel() uses entity-type simple name and version already

SshMachineLocation getLocation()

returns location (tighten type, since we know it is an ssh machine location here)

SshMachineLocation getMachine()

java.util.Set getPortsUsed()

java.lang.String getRunDir()

java.util.Map getShellEnvironment()

The environment variables to be set when executing the commands (for install, run, check running, etc).

protected java.util.Map getSshFlags()

java.lang.String getVersion()

protected ScriptHelper newScript(java.lang.String phase)

protected ScriptHelper newScript(java.util.Map flags, java.lang.String phase)

void setExpandedInstallDir(java.lang.String val)

protected void setInstallDir(java.lang.String installDir)

protected void setInstallLabel()

protected void setRunDir(java.lang.String runDir)

 
Methods inherited from class AbstractSoftwareProcessDriver
customize, doFullStartOnRestart, getEntity, getLocation, getResource, getResourceAsString, install, kill, launch, postLaunch, processTemplate, processTemplate, processTemplate, processTemplate, processTemplateContents, processTemplateContents, rebind, restart, start, stop, waitForConfigKey
 

Field Detail

CHECK_RUNNING

public static final java.lang.String CHECK_RUNNING


CUSTOMIZING

public static final java.lang.String CUSTOMIZING


DEBUG

public static final java.lang.String DEBUG
See Also:
newScript(Map, String)


IGNORE_ENTITY_SSH_FLAGS

public static final 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)


INSTALLING

public static final java.lang.String INSTALLING


INSTALL_INCOMPLETE

public static final java.lang.String INSTALL_INCOMPLETE
Permitted flags for newScript(Map, String).


KILLING

public static final java.lang.String KILLING


LAUNCHING

public static final java.lang.String LAUNCHING


NON_STANDARD_LAYOUT

public static final java.lang.String NON_STANDARD_LAYOUT
Enable shell debugging output via set -x prepended to the command header.


PID_FILENAME

public static final java.lang.String PID_FILENAME


PROCESS_OWNER

public static final java.lang.String PROCESS_OWNER


RESTARTING

public static final java.lang.String RESTARTING


STOPPING

public static final java.lang.String STOPPING


USE_PID_FILE

public static final java.lang.String USE_PID_FILE
Define the process owner if not the same as the brooklyn user. Both stopping and killing will sudo to this user before issuing the kill command. Only valid if USE_PID_FILE is also set.


VALID_FLAGS

public static final java.util.List VALID_FLAGS


log

public static final Logger log


logSsh

public static final Logger logSsh


 
Constructor Detail

AbstractSoftwareProcessSshDriver

public AbstractSoftwareProcessSshDriver(EntityLocal entity, SshMachineLocation machine)


 
Method Detail

copyResource

public int copyResource(java.io.File file, java.lang.String target)
Parameters:
file - File to copy.
target - Destination on server. Will be prefixed with the entity's run directory if relative.
Returns:
The exit code the SSH command run.


copyResource

public int copyResource(java.lang.String resource, java.lang.String target)


copyResource

@java.lang.SuppressWarningsFile file = new File(target);
public int copyResource(java.util.Map sshFlags, java.lang.String source, java.lang.String target)


copyResources

public void copyResources(java.util.Map resources)
Copies all resources in the given map to the driver's machine.
Parameters:
resources - A mapping of resource URI to server destination.
See Also:
copyResource(String, String)


copyTemplate

public int copyTemplate(java.io.File template, java.lang.String target)


copyTemplate

public int copyTemplate(java.lang.String template, java.lang.String target)


copyTemplate

public int copyTemplate(java.lang.String template, java.lang.String target, java.util.Map extraSubstitutions)


copyTemplates

public void copyTemplates(java.util.Map templates)
Templates all resources in the given map, then copies them to the driver's machine.
Parameters:
templates - A mapping of resource URI to server destination.
See Also:
copyTemplate(String, String)


execute

public int execute(java.util.List script, java.lang.String summaryForLogging)


execute

@java.lang.SuppressWarningsif (!flags.containsKey("logPrefix")) flags.put("logPrefix", ""+entity.getId()+"@"+getLocation().getDisplayName());
@java.lang.Overridereturn getMachine().execScript(flags, summaryForLogging, script, environment);
public int execute(java.util.Map flags2, java.util.List script, java.lang.String summaryForLogging)


getAddress

public java.lang.String getAddress()


getDownloadFileSuffix

public java.lang.String getDownloadFileSuffix()
Suffix to use when looking up the file in the local repo. Ignored if getDownloadFilename() returns non-null.


getDownloadFilename

public java.lang.String getDownloadFilename()
Name to be used in the local repo, when looking for the download file.


getEntityVersionLabel

protected java.lang.String getEntityVersionLabel()
deprecated:
since 0.5.0; instead rely on DownloadResolverManager to include local-repo, such as:
 DownloadResolver resolver = Entities.newDownloader(this);
 List<String> urls = resolver.getTargets();
 
 


getEntityVersionLabel

protected java.lang.String getEntityVersionLabel(java.lang.String separator)
deprecated:
since 0.5.0; instead rely on DownloadResolverManager to include local-repo


getExpandedInstallDir

public java.lang.String getExpandedInstallDir()


getHostname

public java.lang.String getHostname()


getInstallDir

public java.lang.String getInstallDir()


getInstallLabelExtraSalt

protected java.lang.String getInstallLabelExtraSalt()
allows subclasses to return extra salt (ie unique hash) for cases where install dirs need to be distinct e.g. based on extra plugins being placed in the install dir; setInstallLabel() uses entity-type simple name and version already


getLocation

public SshMachineLocation getLocation()
returns location (tighten type, since we know it is an ssh machine location here)


getMachine

public SshMachineLocation getMachine()


getPortsUsed

public java.util.Set getPortsUsed()


getRunDir

public java.lang.String getRunDir()


getShellEnvironment

public java.util.Map getShellEnvironment()
The environment variables to be set when executing the commands (for install, run, check running, etc).
See Also:
SoftwareProcess#SHELL_ENVIRONMENT#SHELL_ENVIRONMENT


getSshFlags

protected java.util.Map getSshFlags()


getVersion

public java.lang.String getVersion()


newScript

protected ScriptHelper newScript(java.lang.String phase)


newScript

protected ScriptHelper newScript(java.util.Map flags, java.lang.String phase)


setExpandedInstallDir

public void setExpandedInstallDir(java.lang.String val)


setInstallDir

protected void setInstallDir(java.lang.String installDir)


setInstallLabel

protected void setInstallLabel()


setRunDir

protected void setRunDir(java.lang.String runDir)


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.