Hi,
I'm still trying to get this to work:
I have versions NiFi 2.0.0 and 2.2.0 at my disposal, and have tried to get simple examples working that I can then implement in my flow. I'm having difficulties as all the examples I find are with older versions of NiFi.
First, Distributed Server and Client Services have been renamed:
DistributedMapCacheServer has been renamed to MapCacheServer
DistributedSetCacheServer has been renamed to SetCacheServer
DistributedMapCacheClientService has been renamed to MapCacheClientService
DistributedSetCacheClientService has been renamed to SetCacheClientService
I've mostly gotten PutDistributedMapCache and FetchDistributedMapCache working as per the older example here:
and
In the Controller Settings under Management Controller Services, I create a MapCacheServer and a MapCacheClientService set to use "localhost" as the Server Hostname.
One thing I've noticed is that it's not possible to select the MapCacheClientService I created. In PutDistributedMapCache and FetchDistributedMapCache I have to create new MapCacheClientServices for each.

Is this how it's supposed to work?
Next I tried to recreate the ExecuteScript example, "Recipe: Get the value of a property stored in a DistributedMapCacheServer" here:
The Groovy code is
import org.apache.nifi.distributed.cache.client.DistributedMapCacheClient
import org.apache.nifi.distributed.cache.client.Serializer
import org.apache.nifi.distributed.cache.client.Deserializer
import java.nio.charset.StandardCharsets
def StringSerializer = {value, out -> out.write(value.getBytes(StandardCharsets.UTF_8))} as Serializer<String>
def StringDeserializer = { bytes -> new String(bytes) } as Deserializer<String>
def myDistClient = clientServiceId.asControllerService(DistributedMapCacheClient)
def result = myDistClient.get('a', StringSerializer, StringDeserializer)
log.info("Result = $result")
I received the error:
ERROR
ExecuteScript[id=587556de-0195-1000-c86f-dca652b949c6] Error Occured,java.lang.NullPointerException: Cannot invoke method get() on null object: {}
I did create a new property in the ExecuteScript processor and use the Id from the MapCacheClientService in Controler Settings as per the directions.

Then I replaced DistributedMapCacheClient in the code with MapCacheClientService and I received the following error:
ERROR
ExecuteScript[id=587556de-0195-1000-c86f-dca652b949c6] Processing failed: org.apache.nifi.processor.exception.ProcessException: javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script4.groovy: 13: unable to resolve class org.apache.nifi.distributed.cache.client.MapCacheClientService
@ line 13, column 1.
import org.apache.nifi.distributed.cache.client.MapCacheClientService
^
I found the nifi-distributed-cache-client-service-2.2.0.jar, and org.apache.nifi.distributed.cache.client.MapCacheClientService is a class within it, but I receive further errors when I placed the jar file in the Nifi lib directory.
Is there a way to get the code in ExecuteScript-Cookbook-part-3 working? PutDistributedMapCache and FetchDistributedMapCache alone are not enough for my needs.
Thanks for you help!