Generation Data Groups(GDG)
Summer Batch allows emulation of main frames' generation data groups (GDG) using a specific resource loader, Summer.Batch.Extra.IO.GdgResourceLoader
. Resource loader is in charge of creating instances of IResource
when required and is used by ResourceInjectionValue
when injecting resources (see section New Injection Parameter Values). To use GDG, Unity loader must register GDG resource loader in the container:
Example 7.18. Registration of the GDG Resource Loader¶
protected override void LoadConfiguration(IUnityContainer container)
{
base.LoadConfiguration(container);
container.SingletonRegistration<ResourceLoader, GdgResourceLoader>().Register();
}
gdg://
” protocol as follows:
gdg://<path>(<number>)[.<extension>]
“<path>
” is the path to the file without extension or generation number, “<number>
” is the reference number of the file ,and “<extension>
” is an extension of the file (which is optional). The final file name will be computed by concatenating the path with generation number and extension if there is one. For instance, if the generation number of the GDG for the previous execution was 23, the reference “gdg://data/output(1).txt
” would result in the file name “data/outputG0024V00.txt
”.
Groups can be configured using a specific application setting (in “App.setting
”) named “gdg-options
”. It should contain a character string with options for groups used in the batch. Each group is identified by its path concatenated with “(*)” and its extension (e.g., “gdg://data/output(*).txt
”). The grammar for the options is the following:
<gdg-options> ::= <gdg-option> | <gdg-option> "," <gdg-options>
<gdg-option> ::= <group> | <group> "," <options>
<group> ::= <path> "(*)" | <path> "(*)." <extension>
<options> ::= <option> | <option> "," <options>
<option> ::= <limit> | <mode>
<limit> ::= "limit=" <integer>
<mode> ::= "mode=empty" | "mode=notempty"
“limit
” option sets number of file that should be kept in a group and “mode
” options specify how files are managed once this limit is reached: in “empty
” all files existing before the current execution are deleted while in “notempty
” the oldest files are deleted so that the final number of files is the limit. The default mode is “notempty
”.
Example 7.19. GDG Configuration¶
Assuming the working directory contains following files:
data/customer/reportG0003V00.txt
data/customer/reportG0004V00.txt
data/customer/reportG0005V00.txt
data/commands/summaryG0018V00.txt
data/commands/summaryG0019V00.txt
data/commands/summaryG0020V00.txt
that the “gdg-options
” setting contains “data/customer/report(*).txt,limit=3,data/commands/summary(*).txt,limit=3,mode=empty
” and that the current batch execution will write to “gdg://data/customer/report(1).txt
” and “gdg://data/commands/summary(1).txt
”, at the end of the batch execution the working directory will contain the following files:
data/customer/reportG0004V00.txt
data/customer/reportG0005V00.txt
data/customer/reportG0006V00.txt
data/commands/summaryG0021V00.txt
Referencing all files in a group. It is possible to reference all existing files in a generation data group by using the “*” wildcard instead of a reference number (e.g., “gdg://data/customer/report(*).txt
”).