public class DefaultCodeGen extends Object implements CodeGen, MergeHandler
| Modifier and Type | Field and Description |
|---|---|
static String |
FIELD_DEBEZIUM_CDC_OP |
CREATED_STATUS, EXECUTED_STATUS, PREPARED_STATUS| Constructor and Description |
|---|
DefaultCodeGen()
Instantiates a new default code generator.
|
| 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 |
onMerge(OnException onException,
Connection conn,
String sql,
String keyField,
long row)
Executed when default etl "insert into" action is failed and etl scenario
is configured to try update instead.
|
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.
|
String |
setCurrentCode(Driver driver,
String name,
int index)
Sets the current code.
|
void |
setTransactionMonitor(TransactionMonitor transactionMonitor)
Sets the transaction monitor.
|
void |
setUnit(EtlUnit unit)
Sets the current unit.
|
public static final String FIELD_DEBEZIUM_CDC_OP
public DefaultCodeGen()
public void setTransactionMonitor(TransactionMonitor transactionMonitor)
CodeGensetTransactionMonitor in interface CodeGentransactionMonitor - the new transaction monitorpublic void addScriptToCleanOnException(String script)
CodeGenaddScriptToCleanOnException in interface CodeGenscript - the scriptpublic void addScriptToCleanUpAfter(String script)
addScriptToCleanUpAfter in interface CodeGenscript - the scriptpublic void addScriptToCleanUpBefore(String script)
CodeGenaddScriptToCleanUpBefore in interface CodeGenscript - the scriptpublic void addScriptToCreate(Destination destination, String script)
CodeGenaddScriptToCreate in interface CodeGendestination - the destinationscript - the scriptpublic void addScriptToInit(Destination destination, String script, boolean cleanUpOnException, String type, boolean ignoreError)
CodeGenaddScriptToInit in interface CodeGendestination - the destinationscript - the scriptcleanUpOnException - the "clean up on exception" flagtype - the typeignoreError - if true ignore error when executing scriptpublic void assembleCode(EtlConfig config, Scenario scenario, Driver driver, int loadIndex, boolean silent) throws Exception
CodeGenprepare(...) 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.assembleCode in interface CodeGensilent - If true logging is disabled for everything but
exceptionsException - in case of any errorpublic void cleanUp(EtlConfig config, Scenario scenario, Driver driver, Connection conn) throws Exception
CodeGenpublic void cleanUpOnException(EtlConfig config, Scenario scenario, Driver driver, Connection cleanUpConn) throws Exception
CodeGencleanUpOnException in interface CodeGenconfig - the configscenario - the scenariodriver - the drivercleanUpConn - the clean up connectionException - the exceptionpublic void copy(CodeGen codeGen)
CodeGenpublic void execute(EtlConfig config, Scenario scenario, Driver driver, boolean silent, Connection conn, Connection cleanUpConn, Destination destination) throws Exception
CodeGenexecute in interface CodeGenconfig - 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 errorpublic List<String> getScriptsToCleanOnException()
CodeGengetScriptsToCleanOnException in interface CodeGenpublic int getStatus()
CodeGenpublic void onMerge(OnException onException, Connection conn, String sql, String keyField, long row) throws Exception
MergeHandleronMerge in interface MergeHandleronException - the OnException objectconn - the connectionsql - the sql (usually insert statement)keyField - the key fieldrow - the rowException - in case of any errorpublic void reorderColumns(Destination destination, DataSetConnector writer, DataSetConnectorParams writerParams)
CodeGenreorderColumns in interface CodeGendestination - the destinationpublic void prepare(EtlConfig config, Scenario scenario, Destination destination, boolean silent, boolean onlyInit, boolean isStreaming) throws Exception
CodeGenprepare in interface CodeGenconfig - 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 errorpublic void reset()
CodeGenpublic void runRemainingBatch(EtlConfig config, Scenario scenario, Connection conn, Destination destination) throws Exception
CodeGenrunRemainingBatch in interface CodeGenconfig - the ETL configscenario - the scenarioconn - the connectiondestination - the destinationException - in case of any errorpublic String setCurrentCode(Driver driver, String name, int index)
driver - the drivername - the nameindex - the indexCopyright © 2010-2020 Toolsverse. All Rights Reserved.