Chris, thank you very much for suggesting a few alternatives. I'll tune my
flow this morning and give these a try, too. I think the path suggested by
Lars is going to prove ideal for my situation, where I want to enter my
ExecuteScript with one flowFile and create multiple flowFiles from that in
a loop, as I work my way through a series of directories in a python loop,
pulling metadata from them. Since I'll be running my ES in "all node"
configuration, if I'm on a four-node cluster my created flowFiles can be on
any of the cluster nodes. I want to identify the host node for each of the
created flowFiles within my script, where I need to apply that knowledge.
Lars suggested leveraging python rather than trying to figure out how to do
this programmatically through nifi session and flowFile objects.
Cheers and thank very much once again,
Jim

On Mon, Jul 19, 2021 at 1:41 AM Chris Sampson <[email protected]>
wrote:

> If you're using GenerateFlowFile, you could add a dynamic property to set
> an attribute using the ${hostname} (or ip) on the created FlowFile.
>
> If you're only running Generate on a single node before load balancing the
> FlowFile (e.g. round-robin) and the expression needs to be calculated on
> the destination host, you could use an UpdateAttribute to create the
> attribute before ExecuteScript but after the load balancing.
>
> Of course, this doesn't answer your original question about evaluating EL
> within a script, but gives you a couple of alternate options.
>
> Cheers,
>
> Chris Sampson
>
> On Sun, 18 Jul 2021, 12:46 James McMahon, <[email protected]> wrote:
>
>> Lars, thank you so much. I was fixated on getting the host information
>> from the flowFile itself and overlooked the obvious. Your suggestion will
>> be ideal. Thank you once again!
>> Jim
>>
>> On Sun, Jul 18, 2021 at 12:59 AM Lars Winderling <
>> [email protected]> wrote:
>>
>>> James,
>>>
>>> maybe just use?
>>> Import socket
>>> socket.gethostname()
>>> It will give you rather the hostname, but that should also help for
>>> distinguishing between nodes.
>>>
>>> Best, Lars
>>>
>>> On 17 July 2021 22:25:47 CEST, James McMahon <[email protected]>
>>> wrote:
>>>>
>>>> Looking closely at the flowFiles I am creating,in the subsequent output
>>>> queue, I see they have a Node Address listed in FlowFile Details. It is not
>>>> listed in the flowfile attributes.
>>>> That is what I need to get at programmatically in my python script. How
>>>> can I access Node Address?
>>>>
>>>> On Sat, Jul 17, 2021 at 2:59 PM James McMahon <[email protected]>
>>>> wrote:
>>>>
>>>>> I have a single flowfile I generate on a periodic basis using a cron
>>>>> scheduled GenerateFlowFile. This then flows into an ExecuteScript, where I
>>>>> have a python script that will create multiple flowfiles from the one.
>>>>>
>>>>> My ExecuteScript is configured to run on all my cluster nodes. For
>>>>> each instance of flowfile I am creating, I need to determine which cluster
>>>>> node it associates with. There’s an expression language function called
>>>>> ip(). Can anyone tell me how to employ ${ip()} in my python to determine
>>>>> the cluster node the newly created flowFile is associated with?
>>>>>
>>>>> I’d be using this after I execute
>>>>> flowfile = session.create()
>>>>>
>>>>> Thanks in advance for your help.
>>>>>
>>>>

Reply via email to