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

Add standard services API dependency to Scripting Processors

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.7.0, 0.6.1
    • 1.0.0
    • Extensions

    Description

      Scripting Processors cannot used Controller Services such as DistributedMapCacheClientService etc, as required dependencies are missing for ExecuteScript Nar. By adding following dependencies we can open new possibilities for Scripting Processors.

      Add this dependency to nifi/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-nar/pom.xml

      <dependency>
          <groupId>org.apache.nifi</groupId>
          <artifactId>nifi-standard-services-api-nar</artifactId>
          <type>nar</type>
      </dependency>
      

      Add this dependency to nifi/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/pom.xml

      <dependency>
          <groupId>org.apache.nifi</groupId>
          <artifactId>nifi-distributed-cache-client-service-api</artifactId>
      </dependency>
      

      Then we can create scripting processor like:

      import org.apache.nifi.controller.ControllerService
      import com.crossbusiness.nifi.processors.StringSerDe
      
      final StringSerDe stringSerDe = new StringSerDe();
      
      def lookup = context.controllerServiceLookup
      def cacheServiceName = DistributedMapCacheClientServiceName.value
      
      log.error  "cacheServiceName: ${cacheServiceName}"
      
      def cacheServiceId = lookup.getControllerServiceIdentifiers(ControllerService).find {
          cs -> lookup.getControllerServiceName(cs) == cacheServiceName
      }
      
      log.error  "cacheServiceId:  ${cacheServiceId}"
      
      def cache = lookup.getControllerService(cacheServiceId)
      log.error cache.get("aaa", stringSerDe, stringSerDe )
      

      Attachments

        Issue Links

          Activity

            People

              joewitt Joe Witt
              xmlking sumanth chinthagunta
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: