public abstract class DistributedJob
extends java.lang.Object
implements weka.core.EnvironmentHandler, java.io.Serializable, weka.core.CommandlineRunnable
| Modifier and Type | Class and Description |
|---|---|
static class |
DistributedJob.JobStatus
Enum of job status states
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
WEKA_ADDITIONAL_PACKAGES_KEY
Property key for specifying weka packages to use in the job
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
environmentSubstitute(java.lang.String orig)
Substitute environment variables in the supplied string.
|
java.util.List<java.lang.String> |
getAdditionalWekaPackageNames(DistributedJobConfig config)
Get a list of weka packages to use from the supplied config
|
java.lang.String |
getJobName()
Get the job name
|
DistributedJob.JobStatus |
getJobStatus()
Get the status of the current job
|
weka.gui.Logger |
getLog()
Get the log in use
|
void |
logMessage(java.lang.String message)
Log a message
|
void |
logMessage(java.lang.String message,
java.lang.Throwable ex)
Log a message with a stack trace from an exception
|
void |
logMessage(java.lang.Throwable ex)
Log a stack trace from an exception
|
static java.lang.String |
makeOptionsStr(java.lang.Object obj)
Utility method to make a "help" options string for the supplied object (if
it is an OptionHandler)
|
static weka.core.Instance |
objectRowToInstance(java.lang.Object[] row,
CSVToARFFHeaderMapTask rowHelper,
weka.core.Instances headerNoSummary,
boolean setStringVals,
boolean sparse)
Utility method to convert a row of values into an Instance
|
static weka.core.Instance |
parseInstance(java.lang.String row,
CSVToARFFHeaderMapTask rowHelper,
weka.core.Instances headerNoSummary,
boolean setStringVals)
Utility method to parse an Instance out of a row of CSV data.
|
void |
postExecution()
Perform any teardown stuff that might need to happen after execution.
|
void |
preExecution()
Perform any setup stuff that might need to happen before commandline
execution.
|
void |
run(java.lang.Object toRun,
java.lang.String[] options)
Execute the supplied object.
|
abstract boolean |
runJob()
Run the job.
|
void |
setEnvironment(weka.core.Environment env) |
void |
setJobDescription(java.lang.String jobDescription)
Set the job description
|
void |
setJobName(java.lang.String jobName)
Set the job name
|
void |
setJobStatus(DistributedJob.JobStatus status)
Set the status of the current job
|
void |
setLog(weka.gui.Logger log)
Set the log to use
|
void |
setStatusMessagePrefix(java.lang.String prefix)
Set the prefix to use for log status messages (primarily for use in the
Knowledge Flow's status area)
|
static java.lang.String |
stackTraceToString(java.lang.Throwable throwable)
Convert a stack trace from a Throwable to a string
|
void |
statusMessage(java.lang.String message)
Send a message to the status
|
void |
stopJob()
Signal that the job should abort (if it is currently running)
|
public static final java.lang.String WEKA_ADDITIONAL_PACKAGES_KEY
public static java.lang.String makeOptionsStr(java.lang.Object obj)
obj - the object to create an options description forpublic static weka.core.Instance parseInstance(java.lang.String row,
CSVToARFFHeaderMapTask rowHelper,
weka.core.Instances headerNoSummary,
boolean setStringVals)
throws java.io.IOException
row - the row of data to convert to an InstancerowHelper - the CSVToARFFHeaderMap task to use for parsing purposesheaderNoSummary - the header of the data (sans summary attributes)
that contains attribute information for the instancesetStringVals - true if the values of string attributes are to be set
on the header (rather than accumulate in the header).java.io.IOException - if a problem occurspublic static weka.core.Instance objectRowToInstance(java.lang.Object[] row,
CSVToARFFHeaderMapTask rowHelper,
weka.core.Instances headerNoSummary,
boolean setStringVals,
boolean sparse)
throws java.io.IOException
row - the row of data to convert to an InstancerowHelper - the configured CSVToARFFHeaderMap task to use for getting
default nominal values fromheaderNoSummary - the header of the data (sans summary attributes)
that contains attribute information for the instancesetStringVals - true if the values of string attributes are to be set
on the header (rather than accumulate in the header).sparse - true if a sparse instance should be created instead of a
dense onejava.io.IOException - if a problem occurspublic static java.lang.String stackTraceToString(java.lang.Throwable throwable)
throwable - the Throwable to get the stack trace frompublic java.util.List<java.lang.String> getAdditionalWekaPackageNames(DistributedJobConfig config)
config - the job config to extract weka package names frompublic java.lang.String environmentSubstitute(java.lang.String orig)
orig - the string to modifypublic java.lang.String getJobName()
@ProgrammaticProperty public void setJobName(java.lang.String jobName)
jobName - the name to usepublic void setJobDescription(java.lang.String jobDescription)
jobDescription - the description to usepublic void setStatusMessagePrefix(java.lang.String prefix)
prefix - the prefix to usepublic DistributedJob.JobStatus getJobStatus()
@ProgrammaticProperty public void setJobStatus(DistributedJob.JobStatus status)
status - the status of the jobpublic weka.gui.Logger getLog()
public void setLog(weka.gui.Logger log)
log - the log to usepublic void setEnvironment(weka.core.Environment env)
setEnvironment in interface weka.core.EnvironmentHandlerpublic void logMessage(java.lang.String message)
message - the message to logpublic void statusMessage(java.lang.String message)
message - the message to statuspublic void logMessage(java.lang.Throwable ex)
ex - the exception to extract the stack trace frompublic void logMessage(java.lang.String message,
java.lang.Throwable ex)
message - the message to logex - the Exception to extract the stack trace frompublic abstract boolean runJob()
throws DistributedWekaException
DistributedWekaException - if a problem occurspublic void stopJob()
public void preExecution()
throws java.lang.Exception
preExecution in interface weka.core.CommandlineRunnablejava.lang.Exception - if a problem occurs during setuppublic void run(java.lang.Object toRun,
java.lang.String[] options)
run in interface weka.core.CommandlineRunnabletoRun - the object to executeoptions - any options to pass to the objectjava.lang.IllegalArgumentException - if the object is not of the expected type.public void postExecution()
throws java.lang.Exception
postExecution in interface weka.core.CommandlineRunnablejava.lang.Exception - if a problem occurs during teardown