ETL - Configuration

OrientDB manages configuration for the ETL module through a single JSON configuration file, called at execution.

Syntax

  1. {
  2. "config": {
  3. <name>: <value>
  4. },
  5. "begin": [
  6. { <block-name>: { <configuration> } }
  7. ],
  8. "source" : {
  9. { <source-name>: { <configuration> } }
  10. },
  11. "extractor" : {
  12. { <extractor-name>: { <configuration> } }
  13. },
  14. "transformers" : [
  15. { <transformer-name>: { <configuration> } }
  16. ],
  17. "loader" : { <loader-name>: { <configuration> } },
  18. "end": [
  19. { <block-name>: { <configuration> } }
  20. ]
  21. }
  • "config" Manages all settings and context variables used by any component of the process.
  • "source" Manages the source data to process.
  • "begin" Defines a list of blocks to execute in order when the process begins.
  • "extractor" Manages the extractor settings.
  • "transformers" Defines a list of transformers to execute in the pipeline.
  • "loader" Manages the loader settings.
  • "end" Defines a list of blocks to execute in order when the process finishes.

Example

  1. {
  2. "config": {
  3. "log": "debug",
  4. "fileDirectory": "/temp/databases/dbpedia_csv/",
  5. "fileName": "Person.csv.gz"
  6. },
  7. "begin": [
  8. { "let": { "name": "$filePath", "value": "$fileDirectory.append( $fileName )"} },
  9. { "let": { "name": "$className", "value": "$fileName.substring( 0, $fileName.indexOf(".") )"} }
  10. ],
  11. "source" : {
  12. "file": { "path": "$filePath", "lock" : true }
  13. },
  14. "extractor" : {
  15. "row": {}
  16. },
  17. "transformers" : [
  18. { "csv": { "separator": ",", "nullValue": "NULL", "skipFrom": 1, "skipTo": 3 } },
  19. { "merge": { "joinFieldName":"URI", "lookup":"V.URI" } },
  20. { "vertex": { "class": "$className"} }
  21. ],
  22. "loader" : {
  23. "orientdb": {
  24. "dbURL": "plocal:/temp/databases/dbpedia",
  25. "dbUser": "admin",
  26. "dbPassword": "admin",
  27. "dbAutoCreate": true,
  28. "tx": false,
  29. "batchCommit": 1000,
  30. "dbType": "graph",
  31. "indexes": [{"class":"V", "fields":["URI:string"], "type":"UNIQUE" }]
  32. }
  33. }
  34. }

General Rules

In developing a configuration file for ETL module processes, consider the following:

  • You can use context variables by prefixing them with the $ sign.
  • It assigns the $input context variable before each transformation.
  • You can execute an expression in OrientDB SQL with the ={<expression>} syntax. For instance,

    1. "field": ={EVAL('3 * 5)}

Conditional Execution

In conditional execution, OrientDB only runs executable blocks, such as transformers and blocks, when a condition is found true, such as with a WHERE clause.

For example,

  1. { "let": {
  2. "name": "path",
  3. "value": "C:/Temp",
  4. "if": "${os.name} = 'Windows'"
  5. }
  6. },
  7. { "let": {
  8. "name": "path",
  9. "value": "/tmp",
  10. "if": "${os.name}.indexOf('nux')"
  11. }
  12. }

Log setting

Most blocks, such transformers and blocks, support the "log" setting. Logs take one of the following logging levels, (which are case-insensitive),: NONE, ERROR, INFO, DEBUG. By default, it uses the INFO level.

Setting the log-level to DEBUG displays more information on execution. It also slows down execution, so use it only for development and debugging purposes.

  1. { "http": {
  2. "url": "http://ip.jsontest.com/",
  3. "method": "GET",
  4. "headers": {
  5. "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36"
  6. },
  7. "log": "DEBUG"
  8. }
  9. }

Configuration Variables

The ETL module binds all values declared in the "config" block to the execution context and are accessible to ETL processing. There are also some special variables used by the ETL process.

Variable Description Type Default value
"log" Defines the global logging level. The accepted levels are: NONE, ERROR, INFO, and DEBUG. This parameter is useful to debug a ETL process or single component. string INFO
"maxRetries" Defines the maximum number of retries allowed, in the event that the loader raises an ONeedRetryException, for concurrent modification of the same record. integer 10
"parallel" Defines whether the ETL module executes pipelines in parallel, using all available cores. boolean false
"haltOnError" Defines whether the ETL module halts the process when it encounters unmanageable errors. When set to false, the process continues in the event of errors. It reports the number of errors it encounters at the end of the import. This feature was introduced in version 2.0.9. boolean true

Split Configuration on Multiple Files

You can split the configuration into several files allowing for the composition of common parts such as paths, URL’s and database references.

For example, you might split the above configuration into two files: one with the input paths for Person.csv specifically, while the other would contain common configurations for the ETL module.

  1. $ cat personConfig.json
  2. {
  3. "config": {
  4. "log": "debug",
  5. "fileDirectory": "/temp/databases/dbpedia_csv/",
  6. "fileName": "Person.csv.gz"
  7. }
  8. }
  9.  
  10. $ cat commonConfig.json
  11. {
  12. "begin": [
  13. { "let": { "name": "$filePath", "value": "$fileDirectory.append( $fileName )"} },
  14. { "let": { "name": "$className", "value": "$fileName.substring( 0, $fileName.indexOf(".") )"} }
  15. ],
  16. "source" : {
  17. "file": { "path": "$filePath", "lock" : true }
  18. },
  19. "extractor" : {
  20. "row": {}
  21. },
  22. "transformers" : [
  23. { "csv": { "separator": ",", "nullValue": "NULL", "skipFrom": 1, "skipTo": 3 } },
  24. { "merge": { "joinFieldName":"URI", "lookup":"V.URI" } },
  25. { "vertex": { "class": "$className"} }
  26. ],
  27. "loader" : {
  28. "orientdb": {
  29. "dbURL": "plocal:/temp/databases/dbpedia",
  30. "dbUser": "admin",
  31. "dbPassword": "admin",
  32. "dbAutoCreate": true,
  33. "tx": false,
  34. "batchCommit": 1000,
  35. "dbType": "graph",
  36. "indexes": [{"class":"V", "fields":["URI:string"], "type":"UNIQUE" }]
  37. }
  38. }
  39. }

Then, when you can call both configuration files when you run the ETL module:

  1. $ $ORIENTDB_HOME/bin/oetl.sh commonConfig.json personConfig.json

Run-time configuration

In the configuration file for the ETL module, you can define variables that the module resolves at run-time by passing them as command-line options. Values passed in this manner override the values defined in the "config" section, even when you use multiple configuration files.

For instance, you might set the configuration variable in the file to ${databaseURL}, then define it through the command-line using:

  1. $ $ORIENTDB_HOME/bin/oetl.sh config-dbpedia.json \
  2. -databaseURL=plocal:/tmp/mydb

In this case, the databaseURL parameter is set in the "config" section to /tmp/mydb, overriding any value given the file.

  1. {
  2. "config": {
  3. "log": "debug",
  4. "fileDirectory": "/temp/databases/dbpedia_csv/",
  5. "fileName": "Person.csv.gz"
  6. "databaseUrl": "plocal:/temp/currentDb"
  7. },
  8. ...