nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Bende <bbe...@gmail.com>
Subject Re: Custom Controller Service
Date Thu, 26 Apr 2018 16:56:24 GMT
In case it helps, Matt B was nice enough to quickly put up a PR for
the API change discussed yesterday:

https://github.com/apache/nifi/pull/2658

Once this is tested and merged it make it would make it easier to
implement Charlie's approach without needing a new interface.


On Thu, Apr 26, 2018 at 12:36 PM, Charlie Meyer
<charlie.meyer@civitaslearning.com> wrote:
> Hello,
>
> I'm working to see what we can share, but for a start, here is how we
> handle the delegating controller service:
>
> package com.civitaslearning.nifi.service.impl;
>
>
> import org.apache.nifi.components.PropertyDescriptor;
> import org.apache.nifi.controller.AbstractControllerService;
> import org.apache.nifi.dbcp.DBCPService;
>
> import java.util.Collections;
> import java.util.List;
> import java.util.UUID;
>
> public class DelegatingDBCPServiceImpl extends
> AbstractControllerService implements DelegatingDBCPService {
>
>   private static final List<PropertyDescriptor> properties =
> Collections.emptyList();
>
>   @Override
>   public DBCPService getDBCPService(UUID uuid) {
>     DBCPService dbcpService =
>         (DBCPService)
> getControllerServiceLookup().getControllerService(uuid.toString());
>
>     if (dbcpService == null) {
>       throw new NullPointerException("Couldn't find DBCP service with
> ID " + uuid);
>     }
>
>     return dbcpService;
>   }
>
>   @Override
>   public List<PropertyDescriptor> getSupportedPropertyDescriptors() {
>     return properties;
>   }
> }
>
>
> From there, we took existing nifi processor code such as ExecuteSQL and
> modified it to require a reference to a delegating service rather than a
> DBCP service and added another property to specify which flow file
> attribute has the id of the dbcp service that should be used, similar to:
>
> final DelegatingDBCPService delegatingDBCPService =
> context.getProperty(DELEGATING_DBCP_SERVICE).asControllerService(DelegatingDBCPService.class);
> final UUID dbcpServiceId =
> UUID.fromString(context.getProperty(DBCP_SERVICE_ATTRIBUTE).evaluateAttributeExpressions(fileToProcess).getValue());
> final DBCPService dbcpService =
> delegatingDBCPService.getDBCPService(dbcpServiceId);
>
> thanks
>
> On Thu, Apr 26, 2018 at 4:07 AM, RP <rishabprasad005@gmail.com> wrote:
>
>> Hi Charlie,
>>
>> Thanks for the reply. It seems that you already have a solution to my
>> problem. If possible, can you please share you code for the custom
>> controller service and the custom processor?
>>
>>
>>
>> -----
>> RP
>> --
>> Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/
>>

Mime
View raw message