Executing Import Programmatically
Enabling data import in the distributed mode programmatically works similarly as in classical ImpEx.
// assuming we have an ImpExResource object that points to an import file on classpath final ImpExResource importFile; final ImportConfig config = new ImportConfig(); // enable Distributed ImpEx config.setDistributedImpexEnabled(true); config.setScript(importFile); // perform import final ImportResult importResult = importService.importData(config);
Since we use the ImportService and ImportConfig API, below we provide the meaning of some of the ImportConfig object flags. By default, the synchronous flag of ImportConfig is set to true. In classical ImpEx, this flag is used to inform the underlying CronJob to run as synchronous or asynchronous. Distributed ImpEx is an asynchronous process by its nature. It splits work into batches and uses TaskEngine to process them all on available nodes. Setting this flag to true instructs ImportService to try to wait for a process to finish and then return ImportResult. Because Distributed ImpEx was built to import large volumes of data, it is recommended to set this flag to false.
|
Flag |
Explanation |
|---|---|
|
distributedImpexEnabled |
Enables Distributed ImpEx. |
|
distributedImpexProcessCode |
Enables you to set a custom process code for execution. |
|
distributedImpexLogLevel |
Enables you to set Log Level for Distributed ImpEx. |
|
sldForData |
Enables you to set the Service Layer Direct mode for import. |
|
nodeGroup |
Enables you to set a cluster node group that handles the import process. |
|
removeOnSuccessForDistributedImpex |
Removes stale output items that have been created during a successful synchronous Distributed ImpEx process. |
|
Flag |
Explanation |
|---|---|
|
maxThreads |
Using this flag is pointless since TaskEngine processes all the work. |
|
removeOnSuccess |
Distributed ImpEx creates a CronJob instance but only as a container for logs and additional information such as status, so for the time being the CronJob isn't removed after the process has finished. |
|
hmcSavedValuesEnabled |
Not used. |
|
dumpingEnabled |
Not used. |
|
failOnError |
Using this flag is pointless here. Distributed ImpEx works on the whole cluster so having one batch that has failed doesn't affect the process of importing the remaining batches. |
|
legacyMode |
Distributed ImpEx only works in the Service Layer mode. |
|
mainScriptWithinArchive |
At the moment of writing this document, Distributed ImpEx doesn't allow you to use zip archives as input. |