|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Objectorg.linkedin.glu.agent.impl.capabilities.ShellImpl
class ShellImpl
contains the utility methods for the shell
Field Summary | |
---|---|
static java.lang.String |
MODULE
|
static Logger |
log
|
Property Summary | |
---|---|
AgentProperties |
agentProperties
|
java.lang.Object |
charset
The charset to use for reading/writing files |
Clock |
clock
|
java.io.FileSystem |
fileSystem
|
Method Summary | |
---|---|
java.lang.Object
|
ant(groovy.lang.Closure closure)
Exporting ant access to the shell |
java.lang.String
|
cat(java.lang.Object location)
Returns the content of the location as a |
Resource
|
chmod(java.lang.Object file, java.lang.Object perm)
Change the permission of the file |
Resource
|
chmodPlusX(java.lang.Object file)
Shortcut/More efficient implementation of the more generic {@link #chmod(Object, Object) call |
Resource
|
chmodRecursive(java.lang.Object dir, java.lang.Object perm)
|
java.lang.Object
|
demultiplexExecStream(java.io.InputStream execStream, java.io.OutputStream stdout, java.io.OutputStream stderr)
@{inheritDoc} |
java.lang.String
|
exec(java.lang.Object executable, java.lang.Object executableArgs)
Executes a shell command... the command will be delegated straight to shell and the output of the shell command is returned. |
java.lang.String
|
exec(java.lang.Object executable, java.lang.Object... executableArgs)
Executes a shell command... the command will be delegated straight to shell and the output of the shell command is returned. |
java.lang.String
|
exec(java.lang.String command)
Executes a shell command... the command will be delegated straight to shell and the output of the shell command is returned. |
java.lang.String
|
exec(java.util.Collection command)
Executes a shell command... the command will be delegated straight to shell and the output of the shell command is returned. |
java.lang.Object
|
exec(java.util.Map args)
@{inheritDoc} |
void
|
fail(java.lang.Object message)
Calling this method will force a script failure |
Resource
|
fetch(java.lang.Object location)
Fetches the file pointed to by the location. |
Resource
|
fetch(java.lang.Object location, java.lang.Object destination)
Fetches the file pointed to by the location. |
java.lang.String
|
fetchContent(java.lang.Object location)
Fetches the content of the location and returns it as a |
java.util.Map
|
getEnv()
|
java.util.Collection
|
getMimeTypes(java.lang.Object file)
|
Submitter
|
getSubmitter()
|
java.util.Collection
|
grep(java.lang.Object location, java.lang.Object pattern)
Similarly to the unix grep command, checks the location one line at a time and returns all the lines which matches the pattern. |
java.lang.Object
|
grep(java.lang.Object location, java.lang.Object pattern, java.lang.Object options)
Similarly to the unix grep command, checks the location one line at a time and returns all the lines which matches the pattern |
Resource
|
gunzip(java.lang.Object file)
Uncompresses the provided file |
Resource
|
gunzip(java.lang.Object file, java.lang.Object toFile)
Uncompresses the provided file (if compressed) into a new file |
Resource
|
gzip(java.lang.Object file)
Compresses the provided file (first make sure that the file is compressed) |
Resource
|
gzip(java.lang.Object file, java.lang.Object toFile)
Compresses the provided file (first make sure that the file is compressed) |
java.util.Map
|
gzipFileOrFolder(java.lang.Object fileOrFolder, boolean recurse)
Compresses each file in a folder |
java.util.Map
|
httpHead(java.lang.Object location)
Issue a 'HEAD' request. |
java.util.Map
|
httpPost(java.lang.Object location, java.util.Map parameters)
Issue a 'POST' request. |
boolean
|
listening(java.lang.Object server, java.lang.Object port)
@return |
Shell
|
newShell(java.lang.Object fileSystem)
|
java.lang.Object
|
noException(groovy.lang.Closure closure)
Runs the closure in a protected block that will not throw an exception but will return
|
java.lang.String
|
replaceTokens(java.lang.String input, java.util.Map tokens)
Replaces the tokens provided in the map in the input. |
Resource
|
replaceTokens(java.lang.Object from, java.lang.Object to, java.util.Map tokens)
Processes |
Resource
|
saveContent(java.lang.Object file, java.lang.String content, java.util.Map tokens)
Processes the content to the token replacement method. |
void
|
setSubmitter(Submitter submitter)
|
java.io.InputStream
|
tail(java.lang.Object location, long maxLine)
Tail the location |
java.io.InputStream
|
tail(java.lang.Object args)
Tail the location |
protected java.io.InputStream
|
toInputStream(java.lang.Object stream)
|
protected java.lang.String
|
toStringCommandLine(java.lang.Object commandLine)
Make sure that the command line is a string. |
protected java.lang.Object
|
toStringOutput(byte[] output)
Converts the output into a string. |
Resource
|
untar(java.lang.Object file)
|
Resource
|
untar(java.lang.Object file, java.lang.Object toDir)
|
Resource
|
untarAndDecrypt(java.lang.Object file, java.lang.Object toDir, java.lang.Object encryptionKeys)
|
Resource
|
unzip(java.lang.Object file)
|
Resource
|
unzip(java.lang.Object file, java.lang.Object toDir)
|
boolean
|
waitFor(java.lang.Object args, groovy.lang.Closure condition)
Waits for the condition to be |
boolean
|
waitFor(groovy.lang.Closure condition)
Waits for the condition to be |
java.lang.Object
|
withMBeanServerConnection(java.lang.Object pid, groovy.lang.Closure closure)
Invokes the closure with an |
java.lang.Object
|
withReader(java.lang.Object file, groovy.lang.Closure closure)
Same as |
java.lang.Object
|
withWriter(java.lang.Object file, groovy.lang.Closure closure)
Same as |
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 static final java.lang.String MODULE
public static final Logger log
Property Detail |
---|
AgentProperties agentProperties
java.lang.Object charset
Clock clock
@Delegate java.io.FileSystem fileSystem
Method Detail |
---|
java.lang.Object ant(groovy.lang.Closure closure)
java.lang.String cat(java.lang.Object location)
String
or
null
if the location is not reachable
Resource chmod(java.lang.Object file, java.lang.Object perm)
Resource chmodPlusX(java.lang.Object file)
Resource chmodRecursive(java.lang.Object dir, java.lang.Object perm)
java.lang.Object demultiplexExecStream(java.io.InputStream execStream, java.io.OutputStream stdout, java.io.OutputStream stderr)
java.lang.String exec(java.lang.Object executable, java.lang.Object executableArgs)
java.lang.String exec(java.lang.Object executable, java.lang.Object... executableArgs)
java.lang.String exec(java.lang.String command)
java.lang.String exec(java.util.Collection command)
java.lang.Object exec(java.util.Map args)
void fail(java.lang.Object message)
Resource fetch(java.lang.Object location)
File
,
a String
or URI
and must contain a scheme. Example of locations:
http://locahost:8080/file.txt'
, file:/tmp/file.txt
,
ivy:/org.linkedin/util-core/1.0.0
.
Resource fetch(java.lang.Object location, java.lang.Object destination)
File
,
a String
or URI
and must contain a scheme. Example of locations:
http://locahost:8080/file.txt'
, file:/tmp/file.txt
,
ivy:/org.linkedin/util-core/1.0.0
. The difference with the other fetch method
is that it fetches the file in the provided destination rather than in the tmp space.
java.lang.String fetchContent(java.lang.Object location)
String
or
null
if the location is not reachable
java.util.Map getEnv()
java.util.Collection getMimeTypes(java.lang.Object file)
Submitter getSubmitter()
java.util.Collection grep(java.lang.Object location, java.lang.Object pattern)
java.lang.Object grep(java.lang.Object location, java.lang.Object pattern, java.lang.Object options)
options
- options to the command:
out
: an object to output the lines which match (default to [])
count
: returns the count only (does not use out)
maxCount
: stop reading after maxCount
matches
Resource gunzip(java.lang.Object file)
Resource gunzip(java.lang.Object file, java.lang.Object toFile)
Resource gzip(java.lang.Object file)
Resource gzip(java.lang.Object file, java.lang.Object toFile)
java.util.Map gzipFileOrFolder(java.lang.Object fileOrFolder, boolean recurse)
fileOrFolder
- a file (behaves like gzip(Object)) or a folderrecurse
- if true
then recursively process all folders
java.util.Map httpHead(java.lang.Object location)
java.util.Map httpPost(java.lang.Object location, java.util.Map parameters)
application/x-www-form-urlencoded
content type.
parameters
- the parameters of the post as map of key value pairs (value can be a single
value or a collection of values)
boolean listening(java.lang.Object server, java.lang.Object port)
true
if there is a socket open on the server/port combination
Shell newShell(java.lang.Object fileSystem)
java.lang.Object noException(groovy.lang.Closure closure)
null
in the case one happens
java.lang.String replaceTokens(java.lang.String input, java.util.Map tokens)
input = "abcd @myToken@" assert "abcd foo" == replaceTokens(input, [myToken: 'foo'])
Resource replaceTokens(java.lang.Object from, java.lang.Object to, java.util.Map tokens)
from
through the replacement token mechanism and writes the result to
to
from
- anything that can be provided to java.io.FileSystem#toResource(java.lang.Object)to
- anything that can be provided to java.io.FileSystem#toResource(java.lang.Object)tokens
- a map of tokento
as a Resource
Resource saveContent(java.lang.Object file, java.lang.String content, java.util.Map tokens)
void setSubmitter(Submitter submitter)
java.io.InputStream tail(java.lang.Object location, long maxLine)
java.io.InputStream tail(java.lang.Object args)
protected java.io.InputStream toInputStream(java.lang.Object stream)
protected java.lang.String toStringCommandLine(java.lang.Object commandLine)
protected java.lang.Object toStringOutput(byte[] output)
Resource untar(java.lang.Object file)
Resource untar(java.lang.Object file, java.lang.Object toDir)
Resource untarAndDecrypt(java.lang.Object file, java.lang.Object toDir, java.lang.Object encryptionKeys)
Resource unzip(java.lang.Object file)
Resource unzip(java.lang.Object file, java.lang.Object toDir)
boolean waitFor(java.lang.Object args, groovy.lang.Closure condition)
true
no longer than the timeout. true
is returned if the condition was satisfied, false
otherwise (if you specify
noException)
args.timeout
- how long max to waitargs.heartbeat
- how long to wait between calling the conditionargs.noException
- to get false
instead of an exception
boolean waitFor(groovy.lang.Closure condition)
true
no longer than the timeout. true
is returned if the condition was satisfied, false
otherwise
java.lang.Object withMBeanServerConnection(java.lang.Object pid, groovy.lang.Closure closure)
MBeanServerConnection
to the jmx control running
on the vm started with the provided pid. The closure will be invoked with null
if cannot determine the process.
java.lang.Object withReader(java.lang.Object file, groovy.lang.Closure closure)
withInputStream
but wraps in a reader using the charset
file
- anything that can be provided to java.io.FileSystem#toResource(java.lang.Object)
java.lang.Object withWriter(java.lang.Object file, groovy.lang.Closure closure)
withOutputStream
but wraps in a writer using the charset
file
- anything that can be provided to java.io.FileSystem#toResource(java.lang.Object)
Groovy Documentation