APL Collection Strategy configurations are used on top of pre-defined collection strategies to customize how files are collected from the local file system.
Note | ||
---|---|---|
| ||
The APL function blocks that are described in this chapter are automatically invoked from the collection agent and cannot be called manually. |
The following functions blocks may be used in the APL Collection Strategy code:
Table of Contents | ||
---|---|---|
|
The initialize
, deinitialize
, begin
, commit
, and rollback
function blocks are equivalent to the corresponding APL function blocks described in Function Blocks.
The collection specific functions blocks are invoked in the following order:
prepareBaseDirList
accept
filterFiles
preFileCollection
postFileCollection
Note | ||
---|---|---|
| ||
During run-time, when each of the functions blocks are invoked, the workflow first runs the function blocks base part and then it executes your APL extension code. The following APL functions cannot be used within an APL Collection Strategy configuration.
In the following APL functions you cannot assign a persistent variable with a value. For information about persistent variables, see Variables and Variable Scope
|
initialize
The initialize
function block is used to prepare for the collection and set up an environment to be used in a later stage, when the batch workflow is executed.
Code Block |
---|
void initialize() |
deinitialize
The deinitialize
function block is used to clean-up and close resources.
Code Block |
---|
void deinitialize() |
prepareBaseDirList
The prepareBaseDirList
function block prepares for a list of base directories. A base directory is the directory that includes the files to be collected. This directory is defined when configuring an agent's Base Collection Strategy. Base directory paths can be added, removed, and modified.
The prepareBaseDirList
function block is invoked by the Collection agent right after the collection preparation activities that were initiated by the initialize
function.
Code Block |
---|
void prepareBaseDirList( list<string> dirList ) |
Parameter | Description |
---|---|
| This parameter is used to define one or more collection sources. The collection order of the files is defined using the The The |
In the following example, prepareBaseDirList
adds a subdirectory named sub
to the directory that is already on the base directories list. For example: If /home/in
is a directory that is on the directory list, the prepareBaseDirList
function adds /home/in/sub
to the directory list.
Info | ||
---|---|---|
| ||
|
accept
The collection agent processes the base directory and its included files and creates an internal file list including all files to be collected. The accept
function block is invoked by the collection agent each time a new file is about to be added to the list, and, based on each file's fileInfo object, either accepts or rejects the file.
Code Block |
---|
boolean accept ( FileInfo file ) |
Parameter | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| The file parameter includes the properties of the file to collect or a directory where files are stored. The FileInfo object includes:
| ||||||||||||
Returns | True if the file shall be added to the list of files that are about to be collected |
Info | ||
---|---|---|
| ||
In this example, only files that have a name that starts with "INFILE_ascii" are collected.
|
filterFiles
The filterFiles
function block is invoked by the collection agent right after the accept
function has been executed and when the list of files has been created. Files to collect can be removed, but not added or modified. Collection order can be modified by sorting the list.
Code Block |
---|
void filterFiles ( list<FileInfo> fileInfoList ) |
Parameter:
Parameter | Description |
---|---|
| The |
In the following example, file1
is not collected if there is another file with the same name that includes the prefix "ignore_" (ignore_file1
) in the collected directory.
Info | ||
---|---|---|
| ||
In this example,
|
preFileCollection
The preFileCollection
function block is invoked by the Collection agent right before a file is collected.
Code Block |
---|
void preFileCollection ( string fileName ) |
Parameter | Description |
---|---|
| The |
postFileCollection
The postFileCollection
function block is invoked by the Collection agent right after a file has been collected.
Code Block |
---|
void postFileCollection ( string fileName ) |
Parameter | Description |
---|---|
| The |
begin
The begin
function block is invoked by the Collection agent during the Begin Batch processing phase and marks a start point for the file based transaction handling. On severe errors, such as when a transaction fails, the APL command abort("reason")
should be invoked.
Code Block |
---|
void begin ( long transactionID ) |
Parameter | Description |
---|---|
| The |
commit
The commit
function block is invoked by the Collection agent right after the End Batch processing phase and marks the end of the file-based transaction handling. On severe errors, such as when a transaction fails, the APL command abort("reason")
should be invoked.
Code Block |
---|
void commit ( long transactionID , boolean isRecover ) |
Parameter | Description |
---|---|
| The |
| The |
rollback
The rollback
function block is invoked in case of a system failure, right after the End Batch processing phase. On severe errors, such as when a transaction fails, the APL abort("reason")
command should be invoked.
Code Block |
---|
void rollback ( long transactionID , boolean isRecover ) |
Parameter | Description |
---|---|
| The |
| The |