@PublicAPI public abstract class JavaExecutable extends Object
Modifier and Type | Field and Description |
---|---|
protected JavaStandaloneExecutableInitializer |
execInitializer |
Constructor and Description |
---|
JavaExecutable() |
Modifier and Type | Method and Description |
---|---|
abstract Serializable |
execute(TaskResult... results)
The content of this method will be executed once after being scheduled.
This may generate a result as an Object . |
protected PrintStream |
getErr()
When using non forked Java tasks, you should use this PrintStream instead of System.err.
|
String |
getGlobalSpace() |
String |
getInputSpace() |
int |
getIterationIndex()
When iteration occurs due to a
FlowActionType.LOOP FlowAction,
each new iterated instance of a task is assigned an iteration index so
that it can be uniquely identified. |
String |
getLocalSpace() |
Map<String,String> |
getMetadata()
Return the result metadata map
|
List<String> |
getNodesURL()
Use this method for a multi-node task.
|
protected PrintStream |
getOut()
When using non forked Java tasks, you should use this PrintStream instead of System.out.
|
String |
getOutputSpace() |
int |
getProgress()
Return the current progress value for this executable, ranged between 0 and 100.
|
int |
getReplicationIndex()
When replication occurs due to a
FlowActionType.REPLICATE FlowAction,
each new replicated instance of a task is assigned a replication index so
that it can be uniquely identified. |
Map<String,Serializable> |
getResultMap() |
Synchronization |
getSynchronizationAPI() |
protected String |
getThirdPartyCredential(String key)
Third-party credentials are specific to each Scheduler user and stored on the server side.
|
String |
getUserSpace() |
Map<String,Serializable> |
getVariables() |
void |
init(Map<String,Serializable> args)
Initialization default method for a java task.
|
void |
initAPIs(ScriptContext sc) |
void |
initDataSpaces(ScriptContext sc)
Initialization of the dataSpaces.
|
void |
initMetadata(ScriptContext sc)
Initialization of the metadata.
|
void |
initResultMap(ScriptContext sc)
Initialization of the resultMap.
|
void |
internalInit(JavaStandaloneExecutableInitializer execInitializer,
ScriptContext sc)
Initialize the executable using the given executable Initializer.
|
protected int |
setProgress(int newValue)
Set the progress value for this Executable.
|
void |
setVariables(Map<String,Serializable> propagatedVariables) |
protected JavaStandaloneExecutableInitializer execInitializer
public void internalInit(JavaStandaloneExecutableInitializer execInitializer, ScriptContext sc) throws Exception
execInitializer
- the executable Initializer used to init the executable itselfException
- an exception if something goes wrong during executable initialization.public void init(Map<String,Serializable> args) throws Exception
By default, this method does automatic assignment between the value given in the arguments map
and the fields contained in your executable.
If the field type and the argument type are different and if the argument type is String
(i.e. for all jobs defined with XML descriptors), then a automatic mapping is tried.
Managed types are byte, short, int, long, boolean and the corresponding classes, other type
must be handle by user by overriding this method.
For example, if you set as argument the key="var", value="12" in the XML descriptor
just add an int (or Integer, long, Long) field named "var" in your executable.
The default init(java.util.Map)
method will store your arguments into the integer class field.
args
- a map containing the different parameter names and values given by the user task.Exception
public void initDataSpaces(ScriptContext sc)
sc
- the ScriptContext including as bindings the dataSpaces locations.public void initAPIs(ScriptContext sc)
public void initMetadata(ScriptContext sc)
sc
- the ScriptContext including as bindings the metadata map.public void initResultMap(ScriptContext sc)
sc
- the ScriptContext including as bindings the resultMap map.public List<String> getNodesURL()
public final int getIterationIndex()
FlowActionType.LOOP
FlowAction,
each new iterated instance of a task is assigned an iteration index so
that it can be uniquely identified.
This is a convenience method to retrieve the Iteration Index that was exported as a Java Property by the TaskLauncher.
public final int getReplicationIndex()
FlowActionType.REPLICATE
FlowAction,
each new replicated instance of a task is assigned a replication index so
that it can be uniquely identified.
This is a convenience method to retrieve the Replication Index that was exported as a Java Property by the TaskLauncher.
protected String getThirdPartyCredential(String key)
key
- the credential's key whose associated value is to be returnedprotected PrintStream getOut()
protected PrintStream getErr()
public abstract Serializable execute(TaskResult... results) throws Throwable
Object
. It can be whatever you want.results
- the results (as a taskResult) from parent tasks.Throwable
- any exception thrown by the user's codeprotected final int setProgress(int newValue) throws IllegalArgumentException
newValue
- the new progress valueIllegalArgumentException
- if the value is not ranged between 0 and 100.public int getProgress()
public Map<String,Serializable> getVariables()
public Map<String,Serializable> getResultMap()
public Map<String,String> getMetadata()
public void setVariables(Map<String,Serializable> propagatedVariables)
public String getInputSpace()
public String getOutputSpace()
public String getGlobalSpace()
public String getLocalSpace()
public String getUserSpace()
public Synchronization getSynchronizationAPI()