Brooklyn

brooklyn.entity.basic.lifecycle
[Java] Class ScriptHelper

java.lang.Object
  brooklyn.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

static Logger log

protected java.lang.Runnable mutexAcquire

protected java.lang.Runnable mutexRelease

protected Predicate resultCodeCheck

protected ScriptRunner runner

protected java.io.ByteArrayOutputStream stderr

protected java.io.ByteArrayOutputStream stdout

java.lang.String summary

 
Constructor Summary
ScriptHelper(ScriptRunner runner, java.lang.String summary)

 
Method Summary
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)

ScriptHelper failIfBodyEmpty()

ScriptHelper failOnNonZeroResultCode(boolean val)

ScriptHelper failOnNonZeroResultCode()

ScriptHelper gatherOutput()

ScriptHelper gatherOutput(boolean gather)

java.util.Map getFlags()

java.util.List getLines()

java.lang.String getResultStderr()

java.lang.String getResultStdout()

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 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

body

public final ScriptPart body


executionCheck

protected Predicate executionCheck


flags

protected final java.util.Map flags


footer

public final ScriptPart footer


gatherOutput

protected boolean gatherOutput


header

public final ScriptPart header


log

public static final Logger log


mutexAcquire

protected java.lang.Runnable mutexAcquire


mutexRelease

protected java.lang.Runnable mutexRelease


resultCodeCheck

protected Predicate resultCodeCheck


runner

protected final ScriptRunner runner


stderr

protected java.io.ByteArrayOutputStream stderr


stdout

protected java.io.ByteArrayOutputStream stdout


summary

public final java.lang.String summary


 
Constructor Detail

ScriptHelper

public ScriptHelper(ScriptRunner runner, java.lang.String summary)


 
Method Detail

execute

public int execute()


executeIf

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


executeIf

public ScriptHelper executeIf(Predicate c)


failIfBodyEmpty

public ScriptHelper failIfBodyEmpty()


failOnNonZeroResultCode

public ScriptHelper failOnNonZeroResultCode(boolean val)


failOnNonZeroResultCode

public ScriptHelper failOnNonZeroResultCode()


gatherOutput

public ScriptHelper gatherOutput()


gatherOutput

public ScriptHelper gatherOutput(boolean gather)


getFlags

public java.util.Map getFlags()


getLines

public java.util.List getLines()


getResultStderr

public java.lang.String getResultStderr()


getResultStdout

public java.lang.String getResultStdout()


requireResultCode

public ScriptHelper requireResultCode(groovy.lang.Closure integerFilter)
Convenience for error-checking the result.

Takes closure which accepts bash exit code (integer), and returns false if it is invalid. Default is that this resultCodeCheck closure always returns true (and the exit code is made available to the caller if they care)


requireResultCode

public ScriptHelper requireResultCode(Predicate integerFilter)


setFlag

public ScriptHelper setFlag(java.lang.String flag, java.lang.Object value)


skipIfBodyEmpty

public ScriptHelper skipIfBodyEmpty()


updateTaskAndFailOnNonZeroResultCode

public ScriptHelper updateTaskAndFailOnNonZeroResultCode()


useMutex

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


 

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