Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

NiFi Custom Controller Service Implementation Setup

Highlighted

NiFi Custom Controller Service Implementation Setup

New Contributor

I am trying to write an alternate implementation of the AtomicDistributedMapCacheClient<R> service. Specifically this is so that the "DistributedMapCacheLookupService" can use my implementation.

So far I have the class implementing the interface like so:

public class CustomDistributedMapCacheClientService extends AbstractControllerService implements AtomicDistributedMapCacheClient<Long> {
...
}

And I have a pom that generates the service-nar that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.company</groupId>
    <artifactId>nifi.service.custom.nar</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>nar</packaging>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.javadoc.skip>true</maven.javadoc.skip>
        <source.skip>true</source.skip>
        <nifi.version>1.7.0</nifi.version>
    </properties>


    <dependencies>
	<!-- My Custom Java Code -->
        <dependency>
            <groupId>org.company</groupId>
            <artifactId>nifi.service.custom</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
	<!-- Add dependency to service api nar to make my implementation available on the classloaders. -->
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-standard-services-api-nar</artifactId>
            <version>${nifi.version}</version>
            <type>nar</type>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.nifi</groupId>
                <artifactId>nifi-nar-maven-plugin</artifactId>
                <version>1.2.0</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>


    <repositories>
        <repository>
            <id>maven_central</id>
            <url>http://central.maven.org/maven2/</url>
        </repository>
    </repositories>
</project>


I set nifi-standard-services-api-nar as a dependency so that the classloaders will be configured properly. This lets me select my custom service in the DistributedMapCacheLookupService. However, it is showing this error in the UI:

... nifi.service.custom.nar is not compatible with DistributedMapCacheClient ...

I traced this message to this function: https://github.com/apache/nifi/blob/99bcd1f88dc826f857ae4ab33e842110bfc6ce21/nifi-nar-bundles/nifi-f... which returns false. Probably due to the classloading not being setup due to a problem with my pom.xml dependencies. Or I'm implementing the wrong class.

Is it possible to generate a custom service nar that adds an alternative implementation of the DistributedMapCacheClient service to be used by the DistributedMapCacheLookupService? Is there a template project I can refer to in order to set this up properly?

I have read through the Developer Guide on this a couple times: https://nifi.apache.org/docs/nifi-docs/html/developer-guide.html#nars but unfortunately am still confused as to how this works (an example project would help me a lot).

Thanks,

Alex

2 REPLIES 2
Highlighted

Re: NiFi Custom Controller Service Implementation Setup

New Contributor

Did you ever find a solution to this? I have the exact same problem.

Re: NiFi Custom Controller Service Implementation Setup

Community Manager

@chubbs As this thread is older, you would likely be better served by creating a new thread. This would also provide an opportunity to provide further details on your situation, steps taken so far and any errors encountered. 



Cy Jervis, Community Manager

Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.

Learn more about the Cloudera Community:
Community Guidelines
How to use the forum
Don't have an account?
Coming from Hortonworks? Activate your account here