Tian, I would create an independent method which calls out to your remote REST service to retrieve the possible values and stores them in a local cache with either a time-based or “number of calls”-based expiration strategy. That way when getSupportedPropertyDescriptors() is invoked multiple times, it will retrieve the values from the local cache and not incur the cost of the remote call every time. If these values can change frequently, you may have to repopulate the PropertyDescriptor object with allowableValues, and this is not a recommended best practice. Perhaps in this case it would make more sense to make the property field open-ended text entry, and provide good help text and a strict validator.
In response to your direct questions, > 1) When will the method getSupportedPropertyDescriptors() be called? I > thought it was in the lifecycle init(), but seems not. Is it time-driven > which is already defined in the NIFI? This is called from a number of places, but probably the one that is giving you trouble is that it is called any time getPropertyDescriptor() is invoked, which can be quite frequently. > 2) When will the method getSupportedDynamicPropertyDescriptor() be called? There is no guarantee as to when this method is called. As noted in the Javadoc for AbstractConfigurableComponent: This method should be side effect free in the subclasses in terms of how * often it is called for a given property name because there is [no guarantee] * how often it will be called for a given property name. > 3) Do you have good suggestions for the dynamic property values? There is a > method getSupportedDynamicPropertyDescriptor(). But the allowed values are > not updated on time although rest call got the correct values. As I suggested above, I would use a local cache to provide consistently timed responses to this request. Populate the cache once during the init() method of your custom processor, and then retrieve them in an asynchronous (i.e. not blocking getPropertyDescriptor()) way at your pre-determined interval. Andy LoPresto [email protected] [email protected] PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 > On Jun 26, 2017, at 2:01 AM, Lou Tian <[email protected]> wrote: > > Hi All, > > I have some questions for customized processor, especially the method > getSupportedPropertyDescriptors(). > > Senario: > In the customized processor, I added a new property. The values for the this > property is fetched remotely by a rest call which will show a popup list. > > Implementation > To define the property, the getSupportedPropertyDescriptors() is override. > And inside the method, the rest call is used to fetch the allowedvalues. But > I found that the method getSupportedPropertyDescriptors() was called so > frequent, like every second(or 20 calls/s, cause we have more customized > processors). The rest service has too much pressure. > > My questions: > 1) When will the method getSupportedPropertyDescriptors() be called? I > thought it was in the lifecycle init(), but seems not. Is it time-driven > which is already defined in the NIFI? > > 2) When will the method getSupportedDynamicPropertyDescriptor() be called? > > 2) Do you have good suggestions for the dynamic property values? There is a > method getSupportedDynamicPropertyDescriptor(). But the allowed values are > not updated on time although rest call got the correct values. > > Thanks for your reply in advance. > > Kind Regards, > > Tian Lou
signature.asc
Description: Message signed with OpenPGP using GPGMail
