DBDev
DBDev

Reputation: 1

What is the code to get the Processor Name and Processor Group Name

Is there a way in Groovy Code to get the Processor Group Name the ExecuteScript Processor is in and Processor Name of the ExecuteScript Processor the Groovy Code is in. If so what would the code be. Any help would be greatly appreciated.

Upvotes: 0

Views: 2232

Answers (2)

Munish Chouhan
Munish Chouhan

Reputation: 318

to get the name of all the processors and process groups name, you can use the following code.

final EventAccess access = context.getEventAccess();
final ProcessGroupStatus procGroupStatus = access.getControllerStatus();
procGroupStatus.getProcessGroupStatus();
final ProcessorStatus processorstatus = procGroupStatus.getProcessorStatus()

ProcessorStatus class contains getName method, which can be used to get the name other processor.

Below is the source code of the same class for your reference.

https://github.com/apache/nifi/blob/master/nifi-api/src/main/java/org/apache/nifi/controller/status/ProcessorStatus.java

Upvotes: 1

Andy
Andy

Reputation: 14194

To get the processor name, use ProcessContext#getName(). The ProcessContext class is referenceable from ExecuteScript via the provided variable context, so the code would be String processorName = context.getName().

To get the process group name, I am not aware of an easy way through the framework code. You can, of course, use the Apache NiFi REST API to request the list of process groups and iterate through, checking to see if the process group contains a processor with the identifier of the current processor.

Upvotes: 1

Related Questions