Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-6503

Cleanup code around Controller Service management

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Core Framework
    • None

    Description

      In reviewing code for the Controller Services, I see a lot of overlapping code that is not very clean. `StandardControllerServiceProvider` maintains a cache of all Controller Services. `StandardFlowManager` also keeps a cache of the Controller Services that exist at the 'root' or 'controller' level. There's no need to be caching these services twice. `StandardFlowManager` should be simply delegating calls to `StandardControllerServiceProvider` or vice-versa.

      When a Controller Service is removed from the `StandardControllerServiceProvider`, it first gets the Process Group of the service. If there is none, it's a root-level controller service so the class delegates to `StandardFlowManager` to handle the cleanup of the removed Controller Service. If there is a Process Group, it delegates the cleanup to the associated Process Group. Both of those pieces of code are nearly identical. This code should be removed from both places and instead relocated to the `StandardControllerServiceProvider` to handle.

      `ComponentNode` should probably have a method along the lines of `List<ControllerServiceNode> getReferencedControllerServices(ControllerServiceProvider provider)` so that places that need to iterate over the referenced services can do so much more easily. Depending on the actions taken against this List, it may make more sense to instead return a `ControllerServiceReferences` type of object that is capable of performing those actions instead of requiring the caller iterate over each of them. For example, a `removeReference(ComponentNode referencingComponent)` method to remove references from all services. This would more easily facilitate logging, etc. Also note that this is denoted as a `List`, not a `Set` because if a Processor references a Controller Service multiple times, it's important to evaluate things like `removeReference` multiples times. A convenience method of `ControllerServiceReferences distinct()` could be useful here as well.

      Attachments

        Issue Links

          Activity

            People

              markap14 Mark Payne
              markap14 Mark Payne
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: