scriptella.execution
Class EtlExecutor

java.lang.Object
  extended by scriptella.execution.EtlExecutor
All Implemented Interfaces:
java.lang.Runnable, java.util.concurrent.Callable<ExecutionStatistics>

public class EtlExecutor
extends java.lang.Object
implements java.lang.Runnable, java.util.concurrent.Callable<ExecutionStatistics>

Executor for ETL files.

Use ConfigurationFactory to parse script files and to configure the executor.

The usage scenario of this class may be described using the following steps:

Additionally simplified helper methods are declared in this class:

ETL Cancellation

Scriptella execution model relies on a standard Java Thread.interrupt() mechanism.

To interrupt the ETL execution invoke Thread.interrupt() on a thread which started ETL operation. As a part of interruption process the engine tries to roll back all changes made during the ETL operation.

ExecutorService and Future can also be used to control ETL execution.

Integration with third-party systems

For convenience EtlExecutor implements Runnable and Callable. This feature simplifies integration of Scriptella executors with Executors or other systems like Spring/Quartz etc. It also minimizes application code dependency on Scriptella.

Version:
1.0
Author:
Fyodor Kupolov

Constructor Summary
EtlExecutor()
          Creates ETL executor.
EtlExecutor(ConfigurationEl configuration)
          Creates an ETL executor for specified configuration file.
 
Method Summary
 ExecutionStatistics call()
          A synonym for execute().
 ExecutionStatistics execute()
          Executes ETL based on a specified configuration.
 ExecutionStatistics execute(ProgressIndicator indicator)
          Executes ETL based on a specified configuration.
 ConfigurationEl getConfiguration()
          Returns ETL configuration for this executor.
 boolean isJmxEnabled()
          Returns true if monitoring/management via JMX is enabled.
 boolean isSuppressStatistics()
          Getter for suppressStatistics property.
static EtlExecutor newExecutor(java.io.File scriptFile)
          Converts file to URL and invokes newExecutor(java.net.URL).
static EtlExecutor newExecutor(java.net.URL scriptFileUrl)
          Helper method to create a new ScriptExecutor for specified script URL.
static EtlExecutor newExecutor(java.net.URL scriptFileUrl, java.util.Map<java.lang.String,?> externalProperties)
          Helper method to create a new ScriptExecutor for specified script URL.
protected  EtlContext prepare(ProgressIndicator indicator)
          Prepares the scripts context.
 void run()
          A runnable adapter for execute() method.
 void setConfiguration(ConfigurationEl configuration)
          Sets ETL configuration.
 void setJmxEnabled(boolean jmxEnabled)
          Enables or disables ETL monitoring/management via JMX.
 void setSuppressStatistics(boolean suppressStatistics)
          Enables or disables collecting of statistics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EtlExecutor

public EtlExecutor()
Creates ETL executor.


EtlExecutor

public EtlExecutor(ConfigurationEl configuration)
Creates an ETL executor for specified configuration file.

Parameters:
configuration - ETL configuration.
Method Detail

getConfiguration

public ConfigurationEl getConfiguration()
Returns ETL configuration for this executor.

Returns:
ETL configuration.

setConfiguration

public void setConfiguration(ConfigurationEl configuration)
Sets ETL configuration.

Parameters:
configuration - ETL configuration.

isJmxEnabled

public boolean isJmxEnabled()
Returns true if monitoring/management via JMX is enabled.

If jmxEnabled=true the executor registers MBeans for executed ETL files. The object names of the mbeans have the following form: scriptella: type=etl,url="ETL_FILE_URL"

Returns:
true if monitoring/management via JMX is enabled.

setJmxEnabled

public void setJmxEnabled(boolean jmxEnabled)
Enables or disables ETL monitoring/management via JMX.

If jmxEnabled=true the executor registers MBeans for executed ETL files. The object names of the mbeans have the following form: scriptella: type=etl,url="ETL_FILE_URL"

Parameters:
jmxEnabled - true if monitoring/management via JMX is enabled.
See Also:
JmxEtlManagerMBean

isSuppressStatistics

public boolean isSuppressStatistics()
Getter for suppressStatistics property.

Returns:
true if statistics collection is disabled. Default value is false.

setSuppressStatistics

public void setSuppressStatistics(boolean suppressStatistics)
Enables or disables collecting of statistics. Default value is false, which means statistics is collected.

Setting this option to true may improve performance in some cases.

Parameters:
suppressStatistics - true if statistics collection should be disabled.

execute

public ExecutionStatistics execute()
                            throws EtlExecutorException
Executes ETL based on a specified configuration.

Returns:
execution statistics for ETL execution.
Throws:
EtlExecutorException - if ETL fails.
See Also:
execute(scriptella.interactive.ProgressIndicator)

execute

public ExecutionStatistics execute(ProgressIndicator indicator)
                            throws EtlExecutorException
Executes ETL based on a specified configuration.

Parameters:
indicator - progress indicator to use.
Returns:
execution statistics for ETL execution.
Throws:
EtlExecutorException - if ETL fails.

prepare

protected EtlContext prepare(ProgressIndicator indicator)
Prepares the scripts context.

Parameters:
indicator - progress indicator to use.
Returns:
prepared scripts context.

newExecutor

public static EtlExecutor newExecutor(java.io.File scriptFile)
Converts file to URL and invokes newExecutor(java.net.URL).

Parameters:
scriptFile - ETL file.
Returns:
configured instance of script executor.
See Also:
newExecutor(java.net.URL)

newExecutor

public static EtlExecutor newExecutor(java.net.URL scriptFileUrl)
Helper method to create a new ScriptExecutor for specified script URL.

Calls newExecutor(java.net.URL, java.util.Map) and passes System properties as external properties.

Parameters:
scriptFileUrl - URL of script file.
Returns:
configured instance of script executor.

newExecutor

public static EtlExecutor newExecutor(java.net.URL scriptFileUrl,
                                      java.util.Map<java.lang.String,?> externalProperties)
Helper method to create a new ScriptExecutor for specified script URL.

Parameters:
scriptFileUrl - URL of script file.
externalProperties - see ConfigurationFactory.setExternalParameters(java.util.Map)
Returns:
configured instance of script executor.
See Also:
ConfigurationFactory

run

public void run()
         throws SystemException
A runnable adapter for execute() method.

Please note that due to a checked exceptions limitation a SystemException is thrown instead of the EtlExecutorException.

Specified by:
run in interface java.lang.Runnable
Throws:
SystemException - a wrapped EtlExecutorException.
See Also:
execute()

call

public ExecutionStatistics call()
                         throws EtlExecutorException
A synonym for execute().

Specified by:
call in interface java.util.concurrent.Callable<ExecutionStatistics>
Throws:
EtlExecutorException


Copyright © Copyright 2006-2009 The Scriptella Project Team.