|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrooklyn.entity.basic.lifecycle.ScriptHelper
public class ScriptHelper
Field Summary | |
---|---|
ScriptPart |
body
|
protected Predicate |
executionCheck
|
protected java.util.Map |
flags
|
ScriptPart |
footer
|
protected boolean |
gatherOutput
|
ScriptPart |
header
|
protected boolean |
isTransient
|
static Logger |
log
|
protected java.lang.Runnable |
mutexAcquire
|
protected java.lang.Runnable |
mutexRelease
|
protected Predicate |
resultCodeCheck
|
protected NaiveScriptRunner |
runner
|
protected java.io.ByteArrayOutputStream |
stderr
|
protected java.io.ByteArrayOutputStream |
stdout
|
java.lang.String |
summary
|
protected Task |
task
|
Constructor Summary | |
ScriptHelper(NaiveScriptRunner runner, java.lang.String summary)
|
Method Summary | |
---|---|
ScriptHelper
|
environmentVariablesReset()
ensures the script runs with no environment variables; by default they will be inherited |
ScriptHelper
|
environmentVariablesReset(java.util.Map envVarsToSet)
overrides the default environment variables to use the given set; by default they will be inherited. |
int
|
execute()
|
ScriptHelper
|
executeIf(groovy.lang.Closure c)
Takes a closure which accepts this ScriptHelper and returns true or false as to whether the script needs to run (or can throw error if desired) |
ScriptHelper
|
executeIf(Predicate c)
|
int
|
executeInternal()
|
ScriptHelper
|
failIfBodyEmpty()
|
ScriptHelper
|
failOnNonZeroResultCode(boolean val)
|
ScriptHelper
|
failOnNonZeroResultCode()
|
ScriptHelper
|
failOnNonZeroResultCodeWithoutUpdatingTask()
|
ScriptHelper
|
gatherOutput()
|
ScriptHelper
|
gatherOutput(boolean gather)
|
java.util.Map
|
getFlags()
|
java.util.List
|
getLines()
|
java.lang.String
|
getResultStderr()
|
java.lang.String
|
getResultStdout()
|
protected java.lang.RuntimeException
|
logWithDetailsAndThrow(java.lang.String message, java.lang.Throwable optionalCause)
|
Task
|
newTask()
creates a task which will execute this script; note this can only be run once per instance of this class |
Task
|
peekTask()
returns the task, if it has been constructed, or null; use newTask() to build (if it is null and you need a task) |
Task
|
queue()
queues the task for execution if we are in a TaskQueueingContext (e.g. |
ScriptHelper
|
requireResultCode(groovy.lang.Closure integerFilter)
Convenience for error-checking the result. |
ScriptHelper
|
requireResultCode(Predicate integerFilter)
|
ScriptHelper
|
setFlag(java.lang.String flag, java.lang.Object value)
|
ScriptHelper
|
setFlag(ConfigKey flag, java.lang.Object value)
|
void
|
setTransient()
indicates explicitly that the task can be safely forgotten about after it runs; useful for things like check_running which run repeatedly |
ScriptHelper
|
skipIfBodyEmpty()
|
ScriptHelper
|
updateTaskAndFailOnNonZeroResultCode()
|
ScriptHelper
|
useMutex(WithMutexes mutexSupport, java.lang.String mutexId, java.lang.String description)
indicates that the script should acquire the given mutexId on the given mutexSupport and maintain it for the duration of script execution; typically used to prevent parallel scripts from conflicting in access to a resource (e.g. a folder, or a config file used by a process) |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
public final ScriptPart body
protected Predicate executionCheck
protected final java.util.Map flags
public final ScriptPart footer
protected boolean gatherOutput
public final ScriptPart header
protected boolean isTransient
public static final Logger log
protected java.lang.Runnable mutexAcquire
protected java.lang.Runnable mutexRelease
protected Predicate resultCodeCheck
protected final NaiveScriptRunner runner
protected java.io.ByteArrayOutputStream stderr
protected java.io.ByteArrayOutputStream stdout
public final java.lang.String summary
protected Task task
Constructor Detail |
---|
public ScriptHelper(NaiveScriptRunner runner, java.lang.String summary)
Method Detail |
---|
public ScriptHelper environmentVariablesReset()
public ScriptHelper environmentVariablesReset(java.util.Map envVarsToSet)
public int execute()
public ScriptHelper executeIf(groovy.lang.Closure c)
public ScriptHelper executeIf(Predicate c)
public int executeInternal()
public ScriptHelper failIfBodyEmpty()
public ScriptHelper failOnNonZeroResultCode(boolean val)
public ScriptHelper failOnNonZeroResultCode()
public ScriptHelper failOnNonZeroResultCodeWithoutUpdatingTask()
public ScriptHelper gatherOutput()
public ScriptHelper gatherOutput(boolean gather)
public java.util.Map getFlags()
public java.util.List getLines()
public java.lang.String getResultStderr()
public java.lang.String getResultStdout()
protected java.lang.RuntimeException logWithDetailsAndThrow(java.lang.String message, java.lang.Throwable optionalCause)
public Task newTask()
public Task peekTask()
public Taskqueue() { public Task queue()
public ScriptHelper requireResultCode(groovy.lang.Closure integerFilter)
public ScriptHelper requireResultCode(Predicate integerFilter)
public ScriptHelper setFlag(java.lang.String flag, java.lang.Object value)
public ScriptHelper setFlag(ConfigKey flag, java.lang.Object value)
public void setTransient()
public ScriptHelper skipIfBodyEmpty()
public ScriptHelper updateTaskAndFailOnNonZeroResultCode()
public ScriptHelper useMutex(WithMutexes mutexSupport, java.lang.String mutexId, java.lang.String description)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.