Created 10-12-2018 10:01 PM
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
Created 01-24-2020 08:04 AM
Did you ever find a solution to this? I have the exact same problem.
Created 01-24-2020 01:49 PM
@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.