Skip to content

Commit fd094da

Browse files
committed
Docs updates
1 parent f7ffdd1 commit fd094da

File tree

7 files changed

+76
-36
lines changed

7 files changed

+76
-36
lines changed

Direct_Framework/Stored Procedures/omd.ModuleEvaluation.sql

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ BEGIN TRY
189189
GOTO ModuleFailure
190190
END
191191

192-
SET @LogMessage = 'Start of Batch / Module relationship evalation step.'
192+
SET @LogMessage = 'Start of Batch / Module relationship evalation.'
193193
SET @MessageLog = [omd].[AddLogMessage](DEFAULT, DEFAULT, N'Status Update', @LogMessage, @MessageLog)
194194

195195
IF @BatchId = 0 -- The Module was run stand-alone (not from a Batch).
@@ -212,15 +212,14 @@ BEGIN TRY
212212
SET @LogMessage = 'The Batch / Module inactive flag value is ' + @BatchModuleActiveIndicator
213213
SET @MessageLog = [omd].[AddLogMessage](DEFAULT, DEFAULT, N'Status Update', @LogMessage, @MessageLog)
214214

215-
IF (@BatchModuleActiveIndicator = 'N') -- Skip
215+
-- If the active indicator at Batch/Module level is set to 'N' the process is disabled in the framework.
216+
-- In this case, the Module must be cancelled (was attempted to be run, but not allowed to).
217+
IF (@BatchModuleActiveIndicator = 'N') -- Cancel
216218
BEGIN
217-
SET @LogMessage = 'The Module Instance will be skipped / cancelled'
219+
SET @LogMessage = 'The Module Instance will be cancelled'
218220
SET @MessageLog = [omd].[AddLogMessage](DEFAULT, DEFAULT, N'Status Update', @LogMessage, @MessageLog)
219221

220-
-- If the inactive indicator at Batch/Module level is set to 'Y' the process is disabled in the framework.
221-
-- In this case, the Module must be skipped / cancelled (was attempted to be run, but not allowed).
222-
223-
-- Call the Cancel (skip) event.
222+
-- Update the Module Instance to set the Internal Status Processing Code to 'Cancel'.
224223
EXEC [omd].[UpdateModuleInstance]
225224
@ModuleInstanceId = @ModuleInstanceId,
226225
@EventCode = N'Cancel',
@@ -232,15 +231,14 @@ BEGIN TRY
232231
GOTO EndOfProcedure
233232
END
234233

234+
-- If the inactive indicator at Batch/Module level is NULL or unknwon then there is an error in the framework registration / setup.
235+
-- In this case, the Module must be aborted. The module was attempted to be run form a Batch it is not registered for).
235236
IF (@BatchModuleActiveIndicator = 'U') -- Abort
236237
BEGIN
237238
SET @LogMessage = 'The Module Instance will be aborted.'
238239
SET @MessageLog = [omd].[AddLogMessage](DEFAULT, DEFAULT, N'Status Update', @LogMessage, @MessageLog)
239240

240-
-- If the inactive indicator at Batch/Module level is NULL then there is an error in the framework registration / setup.
241-
-- In this case, the Module must be aborted. The module was attempted to be run form a Batch it is not registered for).
242-
243-
-- Call the Abort event.
241+
-- Update the Module Instance to set the Internal Status Processing Code to 'Abort'.
244242
EXEC [omd].[UpdateModuleInstance]
245243
@ModuleInstanceId = @ModuleInstanceId,
246244
@EventCode = N'Abort',

Documentation/Documentation.md

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ If a failure is detected at any time during this process the Execution Status Co
303303

304304
### Module integration
305305

306+
The Module execution process is as follows:
307+
308+
![Run Module](Images/RunModule.png "Run Module")
309+
306310
#### Create new Module Instance
307311

308312
The CreateModuleInstance event will retrieve the Module details using the Module Code as input. This includes the `MODULE_ID` but also other relevant properties such as `AREA_CODE`, `TARGET_DATA_OBJECT`, and `FREQUENCY_CODE`.
@@ -329,37 +333,29 @@ The ModuleEvaluation event performs the sanity checks and housekeeping for the f
329333

330334
The process is as follows:
331335

332-
1. Check for multiple running instances; if there are more running instances for the same Module only the first one is allowed to continue, the other active Instances must be aborted. This means that the current in-progress Module Instance for which the check is done needs to query if it itself is in the earliest (MIN) of the set of active Instances for the same Module. If this is true the Instance can continue, otherwise it will be flagged to be aborted (Internal Processing Status Code `Abort`)
333-
334-
1. This value in of the Internal Processing Status Code will trigger an update of the MODULE_INSTANCE table to set the Execution Status Code to `Aborted` for the current Instance and avoid executing of the regular ETL logic
336+
![Module Evaluation](Images/ModuleEvaluation.png "Module Evaluation")
335337

336-
1. Validate Batch Execution. DIRECT will query the Batch information to validate if the Module was registered properly (i.e. contains an entry in the Batch/Module relationship table) when instantiated from a Batch. This check also takes into account the value of the `ACTIVE_INDICATOR` on Batch/Module level
338+
1. If there are more running instances for the same Module only the first one is allowed to continue, the other active Instances must be aborted. This means that the current in-progress Module Instance for which the check is done needs to query if it itself is in the earliest (MIN) of the set of active Instances for the Module. If this is true, the Instance can continue. Otherwise it will be flagged to be aborted (Internal Processing Status Code `Abort`).This will trigger an update of the `MODULE_INSTANCE` table to set the Execution Status Code to `Aborted` for the current Instance and avoid executing of the regular Module logic
337339

338-
1. If this value is set to `N` the current Instance will be skipped as this indicates the Module is disabled for the particular Batch
340+
1. DIRECT will assess if the Module is enabled, either individually or when called from a Batch by checking the `ACTIVE_INDICATOR` value. If either the Module or Batch/Module equivalent value is set to `N`, the current Instance will be skipped as this indicates the Module is disabled for the particular Batch
339341

340-
1. Retrieve Previous Instance details. If allowed to continue the Module Evaluation then checks if the previous run(s) have failed or not. It will select the Next Run Status value from the previous Module Instance to direct the internal processing. If a failure is detected (the status of the previous instance Next Run Status is `Rollback`) this step will create an array of all Module Instances from the last logged successful run to the most recent (failed) run
341-
342-
1. This effectively selects multiple failed runs for rollback from the point where the run was last successful. This array of (failed) Module Instances will ultimately be used as the 'IN' clause of the Rollback SQL
342+
1. Details of earlier instances will be retrieved to determine a rollback is required. It will select the Next Run Status value from the previous Module Instance to direct the internal processing. If a failure is detected (the status of the previous instance Next Run Status is `Rollback`) this step will create an array of all Module Instances from the last logged successful run to the most recent (failed) run This effectively selects multiple failed runs for rollback from the point where the run was last successful. This array of (failed) Module Instances will ultimately be used as the 'IN' clause of the Rollback SQL
343343

344344
1. Based on the result of this check the following scenarios are possible:
345345

346-
* If the previous (Module) Next Run Status is `Cancel` the run will be finished before the actual ETL starts. This can happen if:
347-
* The system administrator has labelled this Module to be disabled for this run by manually setting the Next Run Status value to `Cancel` in the Module Instance.
348-
* The previous Batch failed but the specific Module (Instance) was run successfully in that particular Batch and is skipped when the Batch is run again (rollback on Batch level)
349-
346+
* If the previous (Module) Next Run Status is `Cancel` the run will be finished before the actual Module execution starts. This can happen if:
347+
* The system administrator has labelled this Module to be disabled for this run by manually setting the Next Run Status value to `Cancel` in the Module Instance.
348+
* The previous Batch failed but the specific Module (Instance) was run successfully in that particular Batch and is skipped when the Batch is run again (rollback on Batch level)
350349
* If the previous Module Next Run Status is `Rollback` (rollback) the rollback process is started (see Rollback section). The Rollback process uses the Area Code and Table Name to create dynamic SQL statements. After the rollback SQL has been executed correctly the Internal Processing Status Code is set to `Proceed` and processing will continue as usual.
351350

352-
1. The Module Evaluation effectively returns the Internal Processing Status Code for the current Module Instance. The next step for the processing is to interpret this indicator for the current Module Instance to either stop or continue the processing
351+
#### Update the Module Instance
353352

354-
1. After the Module Evaluation is complete and the Internal Processing Status Code equal `Proceed` the regular ETL process can be executed. In other words, no regular processing is allowed unless this indicator is `Proceed`. This is the safety catch for the Module to start.
353+
The Module Evaluation returns the Internal Processing Status Code for the current Module Instance. The next step for the processing is to interpret this indicator for the current Module Instance, to either stop or continue the processing
355354

356-
* If at this point the (Module) Internal Processing Status Code is `Cancel` the Module Instance record is updated to set the final Execution Status Code to `Cancel` and the End Date/Time to the current date/time value (sysdate, getdate or equivalent).
357-
* If at this point the (Module) Internal Processing Status Code is `Abort` the Module Instance record is updated to set the final Execution Status Code to `Aborted` and the End Date/Time to the current date/time value (sysdate, getdate or equivalent).
358-
* As mentioned, if the Internal Processing Status Code is `Proceed` the real ETL logic will be executed. No Modules are allowed to start unless this indicator equals `Proceed`
355+
After the evaluation has completed without any issues, the Internal Processing Status Code of the Module Instance is checked.
359356

360-
#### Update the Module Instance
357+
If the Internal Processing Status Code equals `Proceed` the regular process can be executed. In other words, no regular processing is allowed _unless_ this indicator is `Proceed`. This is the safety catch for the Module to start.
361358

362-
After the execution has completed without any issues, the Internal Processing Status Code of the Module Instance is checked.
363359

364360
If the Internal Processing Status Code is `Cancel`, the Module Instance is updated with:
365361

@@ -373,7 +369,7 @@ If the Internal Processing Status Code is `Abort`, the Module Instance is update
373369
* The Next Run Status as `Proceed` and
374370
* End Date/Time as the current timestamp
375371

376-
If the Internal Processing Status Code is `Proceed` and the ETL runs without issues the Module Instance is updated to set the Execution Status Code to `Succesful`, the Next Run Status as `Proceed` and the current date/time as the End Date/Time.
372+
If the Internal Processing Status Code is `Proceed` and the Module runs without issues the Module Instance is updated to set the Execution Status Code to `Succesful`, the Next Run Status as `Proceed` and the current date/time as the End Date/Time.
377373

378374
As a separate step the record counts are updated in the `MODULE_INSTANCE` table.
379375

@@ -403,8 +399,8 @@ The Module registration is done by adding a record in the MODULE table with the
403399

404400
* `MODULE_ID`, this is a system generated ID that is used to unique identify a Module
405401
* `AREA_CODE`, the Area as part of the Outline Architecture where the Module is part of. This identifies the type, template and purpose of the Module
406-
* `MODULE_CODE`, this is the name of the Module (mapping name, child package; depending on the ETL software used)
407-
* `MODULE_TYPE_CODE`, the type of Module (script, specific ETL job, etc.)
402+
* `MODULE_CODE`, this is the name of the Module
403+
* `MODULE_TYPE_CODE`, the type of Module (script, specific data processing job, etc.)
408404
* `MODULE_DESCRIPTION`, the descriptive information of the Module
409405
* `ACTIVE_INDICATOR`, indicate whether a Module is inactive and should be skipped during process execution
410406

@@ -481,6 +477,4 @@ If a rollback impacts a table associated with the source control logging table i
481477

482478
```sql
483479
DELETE FROM SOURCE_CONTROL WHERE MODULE_INSTANCE_ID IN (<Instance array>)
484-
```
485-
486-
In other approaches, an option is to retain the load window until all related (Batch) processes have been successfully completed.
480+
```
259 KB
Loading

Documentation/Images/RunModule.png

251 KB
Loading
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
flowchart TD
2+
%% Nodes
3+
4+
subgraph BatchEvaluation["Batch Evaluation"]
5+
Start("Start of the process"):::Main
6+
CheckMultiple("Check for multiple running Batch Instances")
7+
IsMultipleInstances{"Are multiple instances running?"}
8+
SetAbort("Update the Internal Processing Status Code to 'Abort'")
9+
IsActive{"Is the Batch enabled?"}
10+
SetCancel("Update the Internal Processing Status Code to 'Cancel'")
11+
IsRollback{"Is the rollback required?"}
12+
Rollback("Perform Rollback")
13+
End("End of the process"):::Main
14+
end
15+
16+
%% Edges
17+
Start --> CheckMultiple --> IsMultipleInstances
18+
IsMultipleInstances -- Yes --> SetAbort
19+
IsMultipleInstances -- No --> IsActive
20+
IsActive -- No --> SetCancel
21+
IsActive -- Yes --> IsRollback
22+
IsRollback -- Yes --> Rollback
23+
Rollback ----> End
24+
IsRollback -- No --> End
25+
26+
%% Styling
27+
classDef Main fill:#BBDEFB,stroke:#1976D2,stroke-width:2px
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
flowchart TD
2+
%% Nodes
3+
4+
subgraph ModuleInstance["Module Instance"]
5+
Start("Start of the process"):::Main
6+
CreateModuleInstance
7+
ModuleEvaluation{"ModuleEvaluation"}
8+
RunModule("Execute Module logic")
9+
UpdateModuleInstance
10+
End("End of the process"):::Main
11+
end
12+
13+
%% Edges
14+
Start --> CreateModuleInstance --> ModuleEvaluation
15+
ModuleEvaluation -- Internal Processing Status Code is not 'Abort' or 'Cancel' --> RunModule
16+
ModuleEvaluation -- Internal Processing Status Code is either 'Abort' or 'Cancel' --> End
17+
RunModule --> UpdateModuleInstance
18+
UpdateModuleInstance --> End
19+
20+
%% Styling
21+
classDef Main fill:#BBDEFB,stroke:#1976D2,stroke-width:2px

0 commit comments

Comments
 (0)