Running the Java code on the conductor node (DataStage)
The Java™ Integration stage supports the execution of Java code on the conductor node during initialization and termination of stages.
setIsRunOnConductor method of the Capabilities class.
During the initialization of the stage, the Processor class
calls the following methods: getCapabilities()validateConfiguration()initialize()
Processor class are called in the following
scenarios:- If the
validateConfigurationmethod returns false, thegetConfigurationErrorsmethod is called. - If runtime column propagation is enabled on one output link and
the
getBeanForOutputmethod is implemented to return the JavaBean object, then the following methods of theProcessorclass are called during initialization:getCapabilities()validateConfiguration()getBeanForOutput()getAdditionalOutputColumns()
- If the capability that runs of your Java code
on the conductor node and runtime column propagation are both enabled
on at least one output link associated with the JavaBean object, then
the following methods of the
Processorclass are called in the specified order during initialization. ThevalidateConfigurationmethod is called twice on the conductor node.getCapabilities()validateConfiguration()getBeanForOutput()getAdditionalOutputColumns()validateConfiguration()initialize()
During the termination of a stage, the terminate() method
of the Processor class is called.
The following
example Java code is used to
set the capability to run the methods of the Processor class
on the conductor node for initialization and termination of stage.
public Capabilities getCapabilities()
{
Capabilities capabilities = new Capabilities();
capabilities.setIsRunOnConductor(true);
return capabilities;
}
The Java code
checks the return value of the getNodeNumber method
of the Configuration class to identify whether the
method is called on the conductor node or player nodes. If the return
value is -1 the method runs on the conductor
node. If the return value is any other number, for example 0 or 1,
the method is invoked on player nodes.
In the following example, the Processor class
completes initialization and termination processes on the conductor
node and player nodes.
private int m_nodeID = -1;
public boolean validateConfiguration(Configuration configuration, boolean isRuntime) throws Exception
{
...
m_nodeID = configuration.getNodeNumber();
...
return true;
}
public void initialize() throws Exception
{
if (m_nodeID == -1) // On Conductor
{
// Perform any initialization process on the conductor node
}
else
{
// Perform any initialization process on each player node
}
}
public void terminate(boolean isAborted) throws Exception
{
if (m_nodeID == -1) // On Conductor
{
// Perform any termination process on the connector node
}
else
{
// Perform any termination process on each player node
}
}