public class ExecTool extends java.lang.Object implements CLITool, IDispatchedScript, CLILoggerParams
dispatch
command line tool. This command will dispatch the command either locally or
remotely.Modifier and Type | Class and Description |
---|---|
static interface |
ExecTool.NodeFormatter |
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.cli.CommandLine |
cli
Reference to command line params
|
static java.lang.String |
DEFAULT_LOG_FORMAT |
protected java.io.PrintStream |
err |
protected ExecTool.NodeFormatter |
nodeFormatter |
static int |
NODESET_EMPTY_EXIT_CODE
Exit code for a Nodeset Empty failure exception
|
protected static org.apache.commons.cli.Options |
options
reference to the command line
Options instance. |
protected java.io.PrintStream |
out |
Constructor and Description |
---|
ExecTool(DispatcherConfig config)
Create a new ExecTool with the given framework instance.
|
Modifier and Type | Method and Description |
---|---|
protected NodeSet |
createFilterNodeSelector()
Crete a NodeSet using the parsed argument values
|
protected NodeSet |
createNodeSet(java.util.Map includeMap,
java.util.Map excludeMap)
Create a NodeSet using the included maps, where exclusion has precedence
|
protected static NodeSet |
createNodeSet(java.util.Map includeMap,
java.util.Map excludeMap,
boolean excludePrecedence,
java.lang.Integer threadCount,
boolean keepgoing,
java.io.File failedNodesfile)
Create a NodeSet using the included maps, and boolean exclude value
|
void |
debug(java.lang.String message)
Logs debug message via implementation specific log facility
|
void |
debug(java.lang.String message,
java.util.Map<java.lang.String,java.lang.String> context) |
void |
error(java.lang.String message)
Logs error message via implementation specific log facility
|
void |
error(java.lang.String message,
java.util.Map<java.lang.String,java.lang.String> context) |
void |
exit(int exitcode)
Calls the exit method
|
java.lang.String |
generateExecLine(java.util.Map<java.lang.String,java.lang.String> filterArgs)
Generates the commandline execution string used.
|
int |
getAntLoglevel()
Return the Ant loglevel equivalent to the input flags (verbose,debug,quiet).
|
java.lang.String |
getArgFrameworkProject() |
java.lang.String[] |
getArgs()
Get the argument line definition
|
java.lang.String[] |
getArgsDeferred() |
CentralDispatcher |
getCentralDispatcher() |
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getDataContext()
Return data context set
|
java.lang.String |
getFrameworkProject()
Get the framework project name
|
java.lang.String |
getInlineScriptContent() |
int |
getLoglevel()
Return the loglevel value, using the Ant equivalents: DEBUG=1,
|
java.lang.Boolean |
getNodeExcludePrecedence()
boolean value specifying that exclusion node filters have precedence over inclusion filters
|
java.lang.String |
getNodeFilter() |
java.lang.String |
getNodeRankAttribute() |
NodeSet |
getNodeSet() |
int |
getNodeThreadcount() |
java.lang.String |
getScript()
Get the full script
|
java.io.InputStream |
getScriptAsStream()
Get an InputStream that can provide the full script
|
java.lang.String |
getScriptpath() |
java.lang.String |
getScriptURLString()
Get the script URL
|
java.lang.String |
getServerScriptFilePath()
Get the server-local script path
|
int |
getThreadCount() |
void |
help()
Writes help message to implementation specific output channel.
|
boolean |
isDebug()
Return true if debug logging is on
|
boolean |
isInlineScript() |
java.lang.Boolean |
isKeepgoing() |
boolean |
isNodeRankOrderAscending() |
boolean |
isQuiet()
Return true if quiet logging is on
|
boolean |
isVerbose()
Return true for verbose logging
|
void |
log(java.lang.String message)
Logs message via implementation specific log facility
|
void |
log(java.lang.String message,
java.util.Map<java.lang.String,java.lang.String> context) |
static void |
main(java.lang.String[] args)
Creates an instance and executes
run(String[]) . |
org.apache.commons.cli.CommandLine |
parseArgs(java.lang.String[] args)
Reads the argument vector and constructs a
CommandLine object containing params |
protected java.util.Map |
parseExcludeArgs(java.lang.String[] keys)
Parse the value of the -X option
|
protected static java.util.Map<java.lang.String,java.lang.String> |
parseFilterArgs(java.lang.String[] keys,
org.apache.commons.cli.CommandLine cli,
java.lang.String opt) |
protected java.util.Map |
parseIncludeArgs(java.lang.String[] keys)
Parse the value of the -X option.
|
protected static java.util.Map<java.lang.String,java.lang.String> |
parseMultiNodeArgs(java.lang.String[] keys,
java.lang.String[] values)
Parse the values as key=value pairs, using the set of allowed keys.
|
void |
run(java.lang.String[] args)
The run method carries out the lifecycle of the tool, parsing args, handling exceptions, and exiting with a
suitable exit code.
|
void |
setCentralDispatcher(CentralDispatcher centralDispatcher) |
void |
setNodeExcludePrecedence(boolean nodeExcludePrecedence) |
void |
setNodeFilter(java.lang.String nodeFilter) |
void |
setNodeThreadcount(java.lang.Integer nodeThreadcount) |
void |
setScriptAsStream(java.io.InputStream scriptAsStream) |
void |
verbose(java.lang.String message)
Logs verbose message via implementation specific log facility
|
void |
verbose(java.lang.String message,
java.util.Map<java.lang.String,java.lang.String> context) |
void |
warn(java.lang.String message)
Logs warning message via implementation specific log facility
|
void |
warn(java.lang.String message,
java.util.Map<java.lang.String,java.lang.String> context) |
protected java.io.PrintStream err
protected java.io.PrintStream out
protected org.apache.commons.cli.CommandLine cli
protected static final org.apache.commons.cli.Options options
Options
instance.protected ExecTool.NodeFormatter nodeFormatter
public static final int NODESET_EMPTY_EXIT_CODE
public static final java.lang.String DEFAULT_LOG_FORMAT
public ExecTool(DispatcherConfig config)
public org.apache.commons.cli.CommandLine parseArgs(java.lang.String[] args)
CommandLine
object containing paramspublic java.lang.String generateExecLine(java.util.Map<java.lang.String,java.lang.String> filterArgs)
filterArgs
- set of filter commandline arguments to insertprotected java.util.Map parseExcludeArgs(java.lang.String[] keys)
keys
- keysprotected java.util.Map parseIncludeArgs(java.lang.String[] keys)
keys
- keyspublic void run(java.lang.String[] args)
protected NodeSet createFilterNodeSelector()
protected NodeSet createNodeSet(java.util.Map includeMap, java.util.Map excludeMap)
includeMap
- include mapexcludeMap
- exclude mapprotected static NodeSet createNodeSet(java.util.Map includeMap, java.util.Map excludeMap, boolean excludePrecedence, java.lang.Integer threadCount, boolean keepgoing, java.io.File failedNodesfile)
includeMap
- include mapexcludeMap
- exclude mapexcludePrecedence
- if true, exclusion has precedencethreadCount
- the threadcountkeepgoing
- keepgoing booleanfailedNodesfile
- file indicating list of failed nodespublic static void main(java.lang.String[] args) throws java.lang.Exception
run(String[])
.args
- argsjava.lang.Exception
- on errorpublic void exit(int exitcode)
public void help()
public void log(java.lang.String message)
log
in interface BaseLogger
message
- message to logpublic void warn(java.lang.String message)
warn
in interface BaseLogger
message
- message to logpublic void error(java.lang.String message)
error
in interface BaseLogger
message
- message to logpublic void debug(java.lang.String message)
BaseLogger
debug
in interface BaseLogger
message
- message to logpublic void verbose(java.lang.String message)
verbose
in interface BaseLogger
message
- message to logpublic java.lang.String getArgFrameworkProject()
public java.lang.String[] getArgsDeferred()
public java.lang.String getScriptpath()
public boolean isInlineScript()
public java.lang.String getInlineScriptContent()
public int getThreadCount()
public java.lang.String getNodeRankAttribute()
public boolean isNodeRankOrderAscending()
public java.lang.Boolean isKeepgoing()
isKeepgoing
in interface IDispatchedExecution
public java.lang.String getFrameworkProject()
IDispatchedScript
getFrameworkProject
in interface IDispatchedScript
public java.lang.String getScript()
IDispatchedScript
getScript
in interface IDispatchedScript
public java.io.InputStream getScriptAsStream()
IDispatchedScript
getScriptAsStream
in interface IDispatchedScript
public void setScriptAsStream(java.io.InputStream scriptAsStream)
public java.lang.String getServerScriptFilePath()
IDispatchedScript
getServerScriptFilePath
in interface IDispatchedScript
public NodeSet getNodeSet()
public java.lang.String[] getArgs()
IDispatchedExecution
getArgs
in interface IDispatchedExecution
public int getLoglevel()
IDispatchedExecution
getLoglevel
in interface IDispatchedExecution
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getDataContext()
IDispatchedExecution
getDataContext
in interface IDispatchedExecution
protected static java.util.Map<java.lang.String,java.lang.String> parseMultiNodeArgs(java.lang.String[] keys, java.lang.String[] values)
keys
- allowed keys for the key=value strings, the first key is used as the default keyvalues
- array of key=value strings, or merely 1 value string if the array is size 1protected static java.util.Map<java.lang.String,java.lang.String> parseFilterArgs(java.lang.String[] keys, org.apache.commons.cli.CommandLine cli, java.lang.String opt)
public java.lang.String getScriptURLString()
IDispatchedScript
getScriptURLString
in interface IDispatchedScript
public java.lang.String getNodeFilter()
getNodeFilter
in interface IDispatchedExecution
public void setNodeFilter(java.lang.String nodeFilter)
public java.lang.Boolean getNodeExcludePrecedence()
getNodeExcludePrecedence
in interface IDispatchedExecution
public void setNodeExcludePrecedence(boolean nodeExcludePrecedence)
public int getNodeThreadcount()
getNodeThreadcount
in interface IDispatchedExecution
public void setNodeThreadcount(java.lang.Integer nodeThreadcount)
public CentralDispatcher getCentralDispatcher()
public void setCentralDispatcher(CentralDispatcher centralDispatcher)
public int getAntLoglevel()
public boolean isDebug()
CLILoggerParams
isDebug
in interface CLILoggerParams
public boolean isVerbose()
CLILoggerParams
isVerbose
in interface CLILoggerParams
public boolean isQuiet()
CLILoggerParams
isQuiet
in interface CLILoggerParams
public void log(java.lang.String message, java.util.Map<java.lang.String,java.lang.String> context)
public void error(java.lang.String message, java.util.Map<java.lang.String,java.lang.String> context)
public void warn(java.lang.String message, java.util.Map<java.lang.String,java.lang.String> context)
public void verbose(java.lang.String message, java.util.Map<java.lang.String,java.lang.String> context)
public void debug(java.lang.String message, java.util.Map<java.lang.String,java.lang.String> context)