@KFStep(name="ExecuteProcess", category="Tools", toolTipText="Execute either static or dynamic processes. Dynamic processes can have commands, arguments and working directories specified in the values of incoming string/nominal attributes in data-based or environment connections.", iconPath="weka/gui/knowledgeflow/icons/ExecuteProcess.gif") public class ExecuteProcess extends BaseStep
| Modifier and Type | Field and Description |
|---|---|
protected int |
m_argsFieldIndex
Resolved attribute index of dynamic arguments
|
protected int |
m_cmdFieldIndex
Resolved attribute index of dynamic command
|
protected java.lang.String |
m_fieldArgs
Name of attribute that will hold optional arguments for dynamic command
|
protected java.lang.String |
m_fieldCmd
Name of attribute that will hold dynamic command to be executed
|
protected java.lang.String |
m_fieldWorkingDir
Name of attribute that will hold optional working directory for dynamic
command
|
protected Instances |
m_instanceOutHeader
Structure of output for outgoing instance connections
|
protected boolean |
m_raiseAnExceptionOnCommandFailure
Whether to raise an exception when a command fails completely (i.e. doesn't
exist or something) vs the case of a non-zero exit status.
|
protected java.lang.Process |
m_runningProcess
The process that is used to execute the user's command(s)
|
protected java.lang.String |
m_staticArgs
Arguments (if necessary) for single static command
|
protected java.lang.String |
m_staticExecCmd
Single static command (may use env vars)
|
protected java.lang.String |
m_staticWorkingDir
Optional working directory for single static command
|
protected java.lang.StringBuffer |
m_stdErrBuffer
Std err from process
|
protected java.lang.StringBuffer |
m_stdOutbuffer
Std out from process
|
protected boolean |
m_structureCheckComplete
True if the structure has been checked
|
protected boolean |
m_useDynamic
True to execute commands specified in incoming instance fields
|
protected int |
m_workingDirFieldIndex
Resolved attribute index of dynamic working directory
|
m_stepIsResourceIntensive, m_stepManager, m_stepName| Constructor and Description |
|---|
ExecuteProcess() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAuxToData(Data data,
java.util.Map<java.lang.String,java.lang.String> varsToSet,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> propsToSet,
java.util.Map<java.lang.String,java.util.LinkedHashSet<Data>> results)
Adds auxilliary information to a Data object
|
protected void |
checkStructure(Instances structure)
Check the incoming instance structure with respect to the attribute names
specified by the user for the command, args and working directory.
|
protected static void |
copy(java.io.InputStream input,
java.io.Writer out)
Copy an input stream to a writer
|
java.lang.String |
getCustomEditorForStep()
Get the name of the editor dialog for this step
|
java.lang.String |
getDynamicArgsField()
Get the name of the attribute in the incoming instance structure that
contains the arguments to the command to execute
|
java.lang.String |
getDynamicCmdField()
Get the name of the attribute in the incoming instance structure that
contains the command to execute
|
java.lang.String |
getDynamicWorkingDirField()
Get the name of the attribute in the incoming instance structure that
containst the working directory for the command to execute
|
java.util.List<java.lang.String> |
getIncomingConnectionTypes()
Get the acceptable incoming connection types at this point in time
|
java.util.List<java.lang.String> |
getOutgoingConnectionTypes()
Get a list of possible outgoing connection types at this point in time
|
boolean |
getRaiseExceptionOnCommandFailure()
Get to raise an exception when a command fails completely (i.e. doesn't
exist or something) vs the case of a non-zero exit status.
|
java.lang.String |
getStaticArgs()
Get the arguments for the static command
|
java.lang.String |
getStaticCmd()
Get the static command to be executed
|
java.lang.String |
getStaticWorkingDir()
Get the working directory for the static command
|
boolean |
getUseDynamic()
Get whether to execute dynamic commands
|
protected void |
handleOutputFailure(int returnCode,
java.util.Map<java.lang.String,java.lang.String> varsToSet,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> propsToSet,
java.util.Map<java.lang.String,java.util.LinkedHashSet<Data>> results,
java.lang.String command)
Output data relating to an unsuccessful execution of a command
|
protected void |
handleOutputSuccess(java.util.Map<java.lang.String,java.lang.String> varsToSet,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> propsToSet,
java.util.Map<java.lang.String,java.util.LinkedHashSet<Data>> results,
java.lang.String command)
Output data relating to successful execution of a command
|
protected java.lang.ProcessBuilder |
makeDynamicProcess(Instance incoming)
Construct a ProcessBuilder instance for executing a dynamic command
|
protected java.lang.ProcessBuilder |
makeStaticProcess()
Construct a ProcessBuilder instance for executing a static command
|
Instances |
outputStructureForConnectionType(java.lang.String connectionName)
Get, if possible, the outgoing instance structure for the supplied incoming
connection type
|
void |
processIncoming(Data data)
Process an incoming Data object
|
protected void |
runProcess(java.lang.ProcessBuilder builder,
java.util.Map<java.lang.String,java.lang.String> varsToSet,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> propsToSet,
java.util.Map<java.lang.String,java.util.LinkedHashSet<Data>> results)
Execute a configured process
|
void |
setDynamicArgsField(java.lang.String argsField)
Set the name of the attribute in the incoming instance structure that
contains the arguments to the command to execute
|
void |
setDynamicCmdField(java.lang.String cmdField)
Set the name of the attribute in the incoming instance structure that
contains the command to execute
|
void |
setDynamicWorkingDirField(java.lang.String workingDirField)
Set the name of the attribute in the incoming instance structure that
containst the working directory for the command to execute
|
void |
setRaiseExceptionOnCommandFailure(boolean raiseExceptionOnCommandFailure)
Set to raise an exception when a command fails completely (i.e. doesn't
exist or something) vs the case of a non-zero exit status.
|
void |
setStaticArgs(java.lang.String args)
Set the arguments for the static command
|
void |
setStaticCmd(java.lang.String cmd)
Set the static command to be executed
|
void |
setStaticWorkingDir(java.lang.String workingDir)
Set the working directory for the static command
|
void |
setUseDynamic(boolean useDynamic)
Set whether to execute dynamic commands
|
void |
start()
Start processing if operating as a start point in a flow
|
void |
stepInit()
Initialize the step
|
environmentSubstitute, getDefaultSettings, getInteractiveViewers, getInteractiveViewersImpls, getName, getStepManager, globalInfo, isResourceIntensive, isStopRequested, setName, setStepIsResourceIntensive, setStepManager, setStepMustRunSingleThreaded, stepMustRunSingleThreaded, stopprotected java.lang.Process m_runningProcess
protected java.lang.String m_staticExecCmd
protected java.lang.String m_staticArgs
protected java.lang.String m_staticWorkingDir
protected boolean m_useDynamic
protected boolean m_raiseAnExceptionOnCommandFailure
protected java.lang.String m_fieldCmd
protected java.lang.String m_fieldArgs
protected java.lang.String m_fieldWorkingDir
protected int m_cmdFieldIndex
protected int m_argsFieldIndex
protected int m_workingDirFieldIndex
protected java.lang.StringBuffer m_stdOutbuffer
protected java.lang.StringBuffer m_stdErrBuffer
protected Instances m_instanceOutHeader
protected boolean m_structureCheckComplete
public boolean getRaiseExceptionOnCommandFailure()
public void setRaiseExceptionOnCommandFailure(boolean raiseExceptionOnCommandFailure)
raiseExceptionOnCommandFailure - if an exception is to be generated on
catastrophic command failurepublic boolean getUseDynamic()
public void setUseDynamic(boolean useDynamic)
useDynamic - true if dynamic commands are to be executedpublic java.lang.String getStaticCmd()
public void setStaticCmd(java.lang.String cmd)
cmd - the static command to be executedpublic java.lang.String getStaticArgs()
public void setStaticArgs(java.lang.String args)
args - the arguments for the static commandpublic java.lang.String getStaticWorkingDir()
public void setStaticWorkingDir(java.lang.String workingDir)
workingDir - the working directory for the static commandpublic java.lang.String getDynamicCmdField()
public void setDynamicCmdField(java.lang.String cmdField)
cmdField - the name of the attribute containing the command to executepublic java.lang.String getDynamicArgsField()
public void setDynamicArgsField(java.lang.String argsField)
argsField - the name of the attribute containing the command's
argumentspublic java.lang.String getDynamicWorkingDirField()
public void setDynamicWorkingDirField(java.lang.String workingDirField)
workingDirField - the name of the attribute containing the command's
working directorypublic void stepInit()
throws WekaException
WekaException - if a problem occurspublic void start()
throws WekaException
start in interface BaseStepExtenderstart in interface Stepstart in class BaseStepWekaException - if a problem occursprotected java.lang.ProcessBuilder makeStaticProcess()
throws java.lang.Exception
java.lang.Exception - if a problem occursprotected java.lang.ProcessBuilder makeDynamicProcess(Instance incoming) throws java.lang.Exception
incoming - the incoming instance containing the command detailsjava.lang.Exception - if a problem occursprotected void runProcess(java.lang.ProcessBuilder builder,
java.util.Map<java.lang.String,java.lang.String> varsToSet,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> propsToSet,
java.util.Map<java.lang.String,java.util.LinkedHashSet<Data>> results)
throws java.io.IOException,
java.lang.InterruptedException,
WekaException
builder - the ProcessBuilder to executevarsToSet - environment variables to pass on to the ProcessBuilderpropsToSet - properties to pass on downstreamresults - results to pass on downstreamjava.io.IOException - if a problem occursjava.lang.InterruptedException - if a problem occursWekaException - if a problem occursprotected void handleOutputSuccess(java.util.Map<java.lang.String,java.lang.String> varsToSet,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> propsToSet,
java.util.Map<java.lang.String,java.util.LinkedHashSet<Data>> results,
java.lang.String command)
throws WekaException
varsToSet - environment variables to pass on downstreampropsToSet - properties to pass on downstreamresults - results to pass on downstreamcommand - the actual command that was executedWekaException - if a problem occursprotected void handleOutputFailure(int returnCode,
java.util.Map<java.lang.String,java.lang.String> varsToSet,
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> propsToSet,
java.util.Map<java.lang.String,java.util.LinkedHashSet<Data>> results,
java.lang.String command)
throws WekaException
returnCode - the return code generated by the processvarsToSet - environment variables to pass on downstreampropsToSet - properties to pass on downstreamresults - results to pass on downstreamcommand - the command that was executedWekaException - if a problem occursprotected void addAuxToData(Data data, java.util.Map<java.lang.String,java.lang.String> varsToSet, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> propsToSet, java.util.Map<java.lang.String,java.util.LinkedHashSet<Data>> results)
data - the Data object to add tovarsToSet - environment variables to addpropsToSet - properties to addresults - results to addpublic void processIncoming(Data data) throws WekaException
processIncoming in interface BaseStepExtenderprocessIncoming in interface StepprocessIncoming in class BaseStepdata - the payload to processWekaException - if a problem occursprotected void checkStructure(Instances structure) throws WekaException
structure - the incoming instance structureWekaException - if a problem occurspublic java.util.List<java.lang.String> getIncomingConnectionTypes()
public java.util.List<java.lang.String> getOutgoingConnectionTypes()
public Instances outputStructureForConnectionType(java.lang.String connectionName) throws WekaException
outputStructureForConnectionType in interface StepoutputStructureForConnectionType in class BaseStepconnectionName - the name of the connection type to get the output
structure forWekaException - if a problem occurspublic java.lang.String getCustomEditorForStep()
getCustomEditorForStep in interface StepgetCustomEditorForStep in class BaseStepprotected static void copy(java.io.InputStream input,
java.io.Writer out)
throws java.io.IOException
input - the input stream to copy fromout - the writer to write tojava.io.IOException - if a problem occurs