Brooklyn

brooklyn.entity.basic.lifecycle.legacy
[Groovy] Class SshBasedAppSetup

java.lang.Object
  brooklyn.entity.basic.AbstractSoftwareProcessDriver
      brooklyn.entity.basic.AbstractSoftwareProcessSshDriver
          brooklyn.entity.basic.lifecycle.legacy.SshBasedAppSetup
All Implemented Interfaces:
ScriptRunner

@Deprecated
abstract class SshBasedAppSetup
extends AbstractSoftwareProcessSshDriver

Application installation, configuration and startup using ssh. TODO complete documentation

deprecated:
will be deleted in 0.5. Use StartStopSshDriver, with SoftwareProcessEntity
See Also:
SshjTool
SshMachineLocation


Field Summary
protected static Logger log

 
Fields inherited from class AbstractSoftwareProcessSshDriver
BROOKLYN_HOME_DIR, CHECK_RUNNING, CUSTOMIZING, DEFAULT_INSTALL_BASEDIR, DEFAULT_RUN_BASEDIR, INSTALLING, KILLING, LAUNCHING, NO_VERSION_INFO, PID_FILENAME, RESTARTING, STOPPING, log, logSsh
 
Fields inherited from class AbstractSoftwareProcessDriver
entity
 
Property Summary
java.lang.String deployDir

java.lang.String manualInstallDir

 
Constructor Summary
SshBasedAppSetup(EntityLocal entity, SshMachineLocation machine)

 
Method Summary
void config()

Configure the application on this machine, or no-op if no config-script defined.

java.io.File copy(java.io.File file)

Copy a file to the runDir on the server.

void customize()

void deploy(java.io.File local, java.io.File remote = null)

Copies a file to the server and invokes getDeployScript(String) for further processing.

protected int exec(java.util.List script, java.lang.String summaryForLogging = "execute for", boolean terminateOnExit)

java.util.List getCheckRunningScript()

The script to run to on a remote machine to determine whether the application is running.

java.util.List getConfigScript()

The script to run to on a remote machine to configure the application.

protected java.lang.String getDefaultVersion()

java.util.List getDeployScript(java.io.File server, java.io.File target = null)

Deploy the file found at the specified location on the server.

java.lang.String getInstallDir()

java.util.List getInstallScript()

The script to run to on a remote machine to install the application.

java.util.List getRestartScript()

The script to run to on a remote machine to restart the application.

java.util.List getRunScript()

The script to run to on a remote machine to run the application.

java.util.List getShutdownScript()

The script to run to on a remote machine to shutdown the application.

void install()

Installs the application on this machine, or no-op if no install-script defined.

boolean isRunning()

Test whether the application is running.

void kill()

void launch()

protected java.util.List makeCheckPortOpenScript(int port)

protected java.util.List makeCheckRunningScript(java.lang.String service = null, java.lang.String pidFile = "pid.txt")

Default commands for getCheckRunningScript().

protected java.util.List makeInstallScript(java.util.List lines)

Add generic commands to an application specific installation script.

protected java.util.List makeRestartScript(java.lang.String service = null, java.lang.String pidFile = "pid.txt")

@see SshBasedJavaSetup#getRestartScript()

protected java.util.List makeShutdownScript(java.lang.String service = null, java.lang.String pidFile = "pid.txt")

@see SshBasedJavaSetup#getShutdownScript()

protected ScriptHelper newScript(java.util.Map flags = [:], java.lang.String phase)

protected int obtainPort(int suggested, int defaultPort, boolean canIncrement)

Reserves a port.

protected int obtainPort(int suggested, boolean canIncrement)

deprecated:
will be deleted in 0.5.

protected void postShutdown()

Called when stopping the application, if the shutdown step completes without an exception.

void restart()

Restart the application.

void runApp()

Run the application on this machine.

protected void setEntityAttributes()

protected java.lang.String setInstallDir(java.lang.String val)

void setRunDir(java.lang.String s)

void setVersion(java.lang.String s)

void shutdown()

Shut down the application process.

void stop()

Stop the application.

static PortRange toDesiredPortRange(java.lang.Integer desired, java.lang.Integer defaultFirst = desired)

Generates a valid range of possible ports.

 
Methods inherited from class AbstractSoftwareProcessSshDriver
copyFile, copyFile, execute, execute, getDefaultVersion, getEntityVersionLabel, getEntityVersionLabel, getHostname, getInstallDir, getLocation, getMachine, getPortsUsed, getRunDir, getShellEnvironment, getVersion, newScript, newScript
 
Methods inherited from class AbstractSoftwareProcessDriver
customize, getEntity, getLocation, getResource, install, kill, launch, postLaunch, restart, start, stop, waitForConfigKey
 

Field Detail

log

protected static final Logger log


 
Property Detail

deployDir

java.lang.String deployDir


manualInstallDir

java.lang.String manualInstallDir


 
Constructor Detail

SshBasedAppSetup

SshBasedAppSetup(EntityLocal entity, SshMachineLocation machine)


 
Method Detail

config

void config()
Configure the application on this machine, or no-op if no config-script defined.
See Also:
getConfigScript()


copy

java.io.File copy(java.io.File file)
Copy a file to the runDir on the server.
Returns:
The location of the file on the server


customize

void customize()


deploy

void deploy(java.io.File local, java.io.File remote = null)
Copies a file to the server and invokes getDeployScript(String) for further processing.


exec

protected int exec(java.util.List script, java.lang.String summaryForLogging = "execute for", boolean terminateOnExit)


getCheckRunningScript

java.util.List getCheckRunningScript()
The script to run to on a remote machine to determine whether the application is running. The script should exit with status 0 if healthy, 1 if stopped, any other code if not healthy.
Returns:
a java.util.List of shell commands
See Also:
isRunning()
makeCheckRunningScript(String, String)


getConfigScript

java.util.List getConfigScript()
The script to run to on a remote machine to configure the application. The default is a no-op.
Returns:
a java.util.List of shell commands


getDefaultVersion

protected java.lang.String getDefaultVersion()


getDeployScript

java.util.List getDeployScript(java.io.File server, java.io.File target = null)
Deploy the file found at the specified location on the server. Checks that the file exists, and fails if not accessible, otherwise copies it to the configured deploy directory. This is required because exit status from the Jsch scp command is not reliable.


getInstallDir

@Override
java.lang.String getInstallDir()


getInstallScript

java.util.List getInstallScript()
The script to run to on a remote machine to install the application. The default is a no-op. The shell variable INSTALL is exported with the path to the installation directory for the application.
Returns:
a java.util.List of shell commands


getRestartScript

java.util.List getRestartScript()
The script to run to on a remote machine to restart the application.
Returns:
a java.util.List of shell commands


getRunScript

java.util.List getRunScript()
The script to run to on a remote machine to run the application. The getShellEnvironment() should be used to set any environment variables required.
Returns:
a java.util.List of shell commands
See Also:
getShellEnvironment()


getShutdownScript

java.util.List getShutdownScript()
The script to run to on a remote machine to shutdown the application.
Returns:
a java.util.List of shell commands


install

void install()
Installs the application on this machine, or no-op if no install-script defined.
See Also:
getInstallScript()


isRunning

boolean isRunning()
Test whether the application is running.
See Also:
getCheckRunningScript()


kill

@Override
void kill()


launch

void launch()


makeCheckPortOpenScript

protected java.util.List makeCheckPortOpenScript(int port)


makeCheckRunningScript

protected java.util.List makeCheckRunningScript(java.lang.String service = null, java.lang.String pidFile = "pid.txt")
Default commands for getCheckRunningScript(). This method will generate script commands to check for the presence of a PID file with a given name and a process matching the PID with the correct service name or entity id (if the service is not given). This script also forms the basis of the generated restart and shutdown scripts.
See Also:
getCheckRunningScript()
makeRestartScript(String)
makeShutdownScript(String)


makeInstallScript

protected java.util.List makeInstallScript(java.util.List lines)
Add generic commands to an application specific installation script. The script will check for a BROOKLYN file, and skip the installation if it exists, otherwise it executes the commands to install the applications and creates the file with the current date and time.

The script will exit with status 0 on success and 1 on failure.

See Also:
getInstallScript()


makeRestartScript

protected java.util.List makeRestartScript(java.lang.String service = null, java.lang.String pidFile = "pid.txt")
See Also:
SshBasedJavaSetup#getRestartScript()#getRestartScript()


makeShutdownScript

protected java.util.List makeShutdownScript(java.lang.String service = null, java.lang.String pidFile = "pid.txt")
See Also:
SshBasedJavaSetup#getShutdownScript()#getShutdownScript()


newScript

protected ScriptHelper newScript(java.util.Map flags = [:], java.lang.String phase)


obtainPort

@Deprecated
protected int obtainPort(int suggested, int defaultPort, boolean canIncrement)
Reserves a port. Uses the suggested port if greater than 0; if 0 then uses any high port; if less than 0 then uses defaultPort. If canIncrement is true, will reserve a port in the range between the suggested value and 65535. TODO support a flag for privileged ports less than 1024
deprecated:
will be deleted in 0.5.
Returns:
the reserved port number
See Also:
obtainPort(int, boolean)
SshMachineLocation#obtainPort(PortRange)#obtainPort(PortRange)


obtainPort

@Deprecated
protected int obtainPort(int suggested, boolean canIncrement)
deprecated:
will be deleted in 0.5.
See Also:
obtainPort(int, int, boolean)


postShutdown

protected void postShutdown()
Called when stopping the application, if the shutdown step completes without an exception. To be overridden; default is a no-op.
See Also:
stop()
shutdown()


restart

void restart()
Restart the application. If getRestartScript() is empty, this will simply stop and then start the service, otherwise the script will be run.
See Also:
start()
stop()


runApp

void runApp()
Run the application on this machine. The SHELL_ENVIRONMENT env property a java.util.Map of environment variables and their values which will be set before executing the commands in getRunScript().
See Also:
start()
getRunScript()


setEntityAttributes

protected void setEntityAttributes()


setInstallDir

protected java.lang.String setInstallDir(java.lang.String val)


setRunDir

void setRunDir(java.lang.String s)


setVersion

void setVersion(java.lang.String s)


shutdown

void shutdown()
Shut down the application process.


stop

@Override
void stop()
Stop the application. May also use the explicit shutdown() step, however this call also executes the postShutdown() method if successful.
See Also:
start()


toDesiredPortRange

@Deprecated
static PortRange toDesiredPortRange(java.lang.Integer desired, java.lang.Integer defaultFirst = desired)
Generates a valid range of possible ports. If desired is specified, then try to use exactly that. Otherwise, use the range from defaultFirst to 65535.
deprecated:
will be deleted in 0.5.


 

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