vamyip
vamyip

Reputation: 1171

Apache Nifi - Make Flow Definitions Portable by using relative paths

I want to make Flow Definitions portable by replacing absolute file paths to relative in below items

  1. Script Path Property of all ExecuteScript Processors
  2. Database Driver Location(s) property of DBCPConnectionPool Controller Services
  3. Keystore Filename & Truststore Filename properties of StandardRestrictedSSLContextService Controller Services

Questions:

  1. Is it possible to use Relative Paths in above items?
  2. Where does the root of relative path point to - nifi installation directory?
  3. What are best practices for managing paths in flow defitions?
  4. Any other best practices for making flow definitions portable

EDIT: We're using parameters in Flow Definitions to make it easier to configure per environment. Currently we have a param to indicate Nifi root path. Te motive behind this question is to check if this param can eliminated entirely by using relative paths.

Upvotes: 0

Views: 231

Answers (2)

Bryan Bende
Bryan Bende

Reputation: 18660

Starting with Apache NiFi 1.10.0, there is a feature called parameters, and all properties of all components support parameters. Parameters use a different syntax to denote the difference from EL, so a parameter is #{my.param}. You should be parameterizing all of your process groups so that any flows saved to NiFi Registry, or downloaded from right-clicking on the PG, can be given new parameters when imported to another environment.

Upvotes: 1

yaprak
yaprak

Reputation: 547

You can use relative paths if the property supports expression language. In your case script path, database driver locations support; however, keystore and truststore paths do not.

For example, I am using relative script path for my ExecuteScripts to run them on macos , windows as well as linux with the same path

Suppose your Nifi root is opt/nifi/nifi-current and you have groovy folder in the root and a FlowHandler.groovyin it. So your script path would be like below

${user.dir}${file.separator}groovy${file.separator}FlowHandler.groovy

Apart from that, I strongly recommend that prepare your own docker image (from base Nifi) and put all constant staffs in it to distribute, so that you can keep your file paths mostly stable across all platforms

Upvotes: 2

Related Questions