public interface CodeGen
CodeGen
is an interface for code generators. ETL framework
generates and executes code for the etl scenario. Code is a usually vendor
specific SQL such as Oracle PL/SQL, Microsoft Transact SQL, etc. The call
sequence for the typical scenario is the following:
prepare(...) is called
for each destination. The resulting code saved internally, assembleCode(...) assembles final
code by concatenating code for all destinations with added declarations, etc so it can be be executed in the
designated database, execute(...)
executes it.
Modifier and Type | Field and Description |
---|---|
static int |
CREATED_STATUS
The code generator created .
|
static int |
EXECUTED_STATUS
The code is executed .
|
static int |
PREPARED_STATUS
The code is prepared .
|
Modifier and Type | Method and Description |
---|---|
void |
addScriptToCleanOnException(String script)
Adds the script to clean on exception.
|
void |
addScriptToCleanUpAfter(String script)
Adds the script to clean up after.
|
void |
addScriptToCleanUpBefore(String script)
Adds the script to clean up before.
|
void |
addScriptToCreate(Destination destination,
String script)
Adds the script to create.
|
void |
addScriptToInit(Destination destination,
String script,
boolean cleanUpOnException,
String type,
boolean ignoreError)
Adds the script to init.
|
void |
assembleCode(EtlConfig config,
Scenario scenario,
Driver driver,
int loadIndex,
boolean silent)
Assembles prepared code.
|
void |
cleanUp(EtlConfig config,
Scenario scenario,
Driver driver,
Connection conn)
Clean up after last block of code is executed.
|
void |
cleanUpOnException(EtlConfig config,
Scenario scenario,
Driver driver,
Connection cleanUpConn)
Clean up database objects on exception.
|
void |
copy(CodeGen codeGen)
Copy parameters from other code generator.
|
void |
execute(EtlConfig config,
Scenario scenario,
Driver driver,
boolean silent,
Connection conn,
Connection cleanUpConn,
Destination destination)
Executes code.
|
List<String> |
getScriptsToCleanOnException()
Gets the list of scripts which should be executed to clean up database
object on exception.
|
int |
getStatus()
Gets the status of the code generator.
|
EtlUnit |
getUnit()
Gets the current unit.
|
void |
prepare(EtlConfig config,
Scenario scenario,
Destination destination,
boolean silent,
boolean onlyInit,
boolean isStreaming)
Prepares code for the destination using given config and scenario.
|
void |
reorderColumns(Destination destination,
DataSetConnector writer,
DataSetConnectorParams writerParams)
Reorder columns.
|
void |
reset()
Resets the status.
|
void |
runRemainingBatch(EtlConfig config,
Scenario scenario,
Connection conn,
Destination destination)
Run remaining batch statements.
|
void |
setTransactionMonitor(TransactionMonitor transactionMonitor)
Sets the transaction monitor.
|
void |
setUnit(EtlUnit unit)
Sets the current unit.
|
static final int CREATED_STATUS
static final int PREPARED_STATUS
static final int EXECUTED_STATUS
void setTransactionMonitor(TransactionMonitor transactionMonitor)
transactionMonitor
- the new transaction monitorvoid assembleCode(EtlConfig config, Scenario scenario, Driver driver, int loadIndex, boolean silent) throws Exception
prepare(...) is called
for each destination. The resulting code saved internally. assembleCode(...) assembles final
code by concatenating code for all destinations with added declarations, etc so it can be be executed in the
designated database. Also it splits code on chunks if necessary. For example Oracle limits size of the PL\SQL block
to approximately 3000 lines.
@param config
The config
@param scenario
The scenario
@param driver
The driver
@param loadIndex
If equals to 0
this chunk will be executed first.
silent
- If true
logging is disabled for everything but
exceptionsException
- in case of any errorvoid cleanUp(EtlConfig config, Scenario scenario, Driver driver, Connection conn) throws Exception
config
- the configscenario
- the scenariodriver
- the driverconn
- the connectionException
- the exception in case of any errorvoid cleanUpOnException(EtlConfig config, Scenario scenario, Driver driver, Connection cleanUpConn) throws Exception
config
- the configscenario
- the scenariodriver
- the drivercleanUpConn
- the clean up connectionException
- the exceptionvoid copy(CodeGen codeGen)
codeGen
- the code generatorvoid execute(EtlConfig config, Scenario scenario, Driver driver, boolean silent, Connection conn, Connection cleanUpConn, Destination destination) throws Exception
config
- The etl configscenario
- The scenariodriver
- The driversilent
- If true
logging is disabled for everything but
exceptionsconn
- The JDBC connectioncleanUpConn
- the clean up connectiondestination
- the destinationException
- in case of any errorList<String> getScriptsToCleanOnException()
int getStatus()
void prepare(EtlConfig config, Scenario scenario, Destination destination, boolean silent, boolean onlyInit, boolean isStreaming) throws Exception
config
- The etl configscenario
- The scenariodestination
- The destinationsilent
- If true
logging is disabled for everything but
exceptionsonlyInit
- the only initisStreaming
- true if is streamingException
- in case of any errorvoid reset()
void runRemainingBatch(EtlConfig config, Scenario scenario, Connection conn, Destination destination) throws Exception
config
- the ETL configscenario
- the scenarioconn
- the connectiondestination
- the destinationException
- in case of any errorvoid setUnit(EtlUnit unit)
unit
- the new unitEtlUnit
void addScriptToCleanOnException(String script)
script
- the scriptvoid addScriptToCleanUpAfter(String script)
script
- the scriptvoid addScriptToCleanUpBefore(String script)
script
- the scriptvoid addScriptToCreate(Destination destination, String script)
destination
- the destinationscript
- the scriptvoid addScriptToInit(Destination destination, String script, boolean cleanUpOnException, String type, boolean ignoreError)
destination
- the destinationscript
- the scriptcleanUpOnException
- the "clean up on exception" flagtype
- the typeignoreError
- if true ignore error when executing scriptvoid reorderColumns(Destination destination, DataSetConnector writer, DataSetConnectorParams writerParams)
destination
- the destinationCopyright © 2010-2020 Toolsverse. All Rights Reserved.