In the last article I explained the history of Parameters and Parameter Contexts and how to use them most effectively in your flows. But did you know you can actually swap out Controller Service instances using their UUIDs as parameter values? I will explain why this is valuable as an example:
I have a DBConnectionPool (in Apache NiFi) or a PostgreSQLConnectionPool (in Cloudera Flow Management) that points to a PostgreSQL database, and I'm parameterizing all the connection properties using the strategy laid out in part 1 of this series. That's all well and good but what if the folks on the destination side say "we decided to switch to Impala on Cloudera Data Platform because we don't want the cost of managing our PostgreSQL cluster, plus it's integrated with our lakehouse". You can't just change the parameters used in the connection pool because you need an entirely different ControllerService.
In Part 1 we were able to swap out configurations for a particular Controller Service, but what if we need to swap out those particular Controller Services? CFM and NiFi provide such a way by being able to refer to a Controller Service ID in a processor (for example). Here's how it's done:
First, we create the two DBCPConnectionPool instances. In my example I'll use PostgreSQL and MySQL. I've configured them so they are valid and will work on their own:
Note the UUIDs. Then I configure my UpdateDatabaseTable to refer to the Database Connection Pool and Database Type parameters:
At first I'm using MySQL so I will set those parameter values (the UUID of the MySQL Connection Pool and the Database Type to MySQL):
The UpdateDatabaseTable is valid and can be started and will connect to the MySQL database:
Now let's say I want to connect to PostgreSQL instead. I simply change the parameter values for the PostgreSQL Connection Pool and the Database Type of PostgreSQL:
Note that I didn't stop UpdateDatabaseTable. Applying these changes will stop the UpdateDatabaseTable processor, set the new values, and restart the processor:
That's all there is to it! In this post I illustrated how to swap out Controller Service instances on-the-fly by using Parameters. In the next post I will dive into how to use Parameter Providers to auto-fill parameters and their values from external sources.