[ 
https://issues.apache.org/jira/browse/NIFI-5830?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16691017#comment-16691017
 ] 

ASF GitHub Bot commented on NIFI-5830:
--------------------------------------

Github user javajefe commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/3176#discussion_r234459335
  
    --- Diff: 
nifi-nar-bundles/nifi-redis-bundle/nifi-redis-extensions/src/main/java/org/apache/nifi/redis/service/RedisDistributedMapCacheClientService.java
 ---
    @@ -188,7 +189,7 @@ public void onDisabled() {
         public <K, V> void put(final K key, final V value, final Serializer<K> 
keySerializer, final Serializer<V> valueSerializer) throws IOException {
             withConnection(redisConnection -> {
                 final Tuple<byte[],byte[]> kv = serialize(key, value, 
keySerializer, valueSerializer);
    -            redisConnection.set(kv.getKey(), kv.getValue(), 
Expiration.seconds(ttl), null);
    +            redisConnection.set(kv.getKey(), kv.getValue(), 
Expiration.seconds(ttl), RedisStringCommands.SetOption.UPSERT);
    --- End diff --
    
    You’re right, this solves NPE you ‘ll see disregarding to the rest of 
changes. But as the root cause of the issue is the same (migration to newer 
version of Spring Data Redis 2.x) and the result of RedisUtils fix is 
incomplete (you can’t use non-localhost standalone Redis) I’ve decided to fix 
it in the same  patch. 


> RedisConnectionPoolService does not work with Standalone Redis using 
> non-localhost deployment
> ---------------------------------------------------------------------------------------------
>
>                 Key: NIFI-5830
>                 URL: https://issues.apache.org/jira/browse/NIFI-5830
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Core Framework
>    Affects Versions: 1.8.0
>         Environment: Ubuntu 16 LTS, NiFi 1.8.0
>            Reporter: Alexander Bukarev
>            Priority: Major
>
> The controller service {{RedisConnectionPoolService}} does not work with 
> Standalone Redis which is deployed on a host other than {{localhost}} (or if 
> Redis uses the port other than {{6379}}). So the only way to use 
> {{RedisConnectionPoolService}} is to deploy Redis on {{localhost}} and run it 
> with default port {{6379}}.
> *Steps*:
> Let's assume our Redis is deployed on host *redis* (not {{localhost}}) and it 
> listens port 6379 (I use docker for that)
> # Create a {{PutDistributedMapCache}} processor
> # Configure the processor with {{RedisDistributedMapCacheClientService}} 
> # Create a new controller service: {{RedisConnectionPoolService}}
> #* Choose *Standalone* Redis Mode
> #* Use *redis:6379* as a Connection String
> # Connect some incoming flow to the {{PutDistributedMapCache}} processor 
> (I've used {{GetFile}} as a producer) and run the whole flow. Allow 
> {{GetFile}} to consume some file (if you use {{GetFile}} ro reproduce) and 
> wait some time till the {{PutDistributedMapCache}} will be schedulled.
> Result:
> The processor is failed to run. And we can see the error in logs:
> {panel}2018-11-17 06:06:47,572 WARN [Timer-Driven Process Thread-2] 
> o.a.n.controller.tasks.ConnectableTask Administratively Yielding PutDistribu
> tedMapCache[id=2041c81f-0167-1000-c82f-d7da2155dfb4] due to uncaught 
> Exception: org.springframework.data.redis.RedisConnectionFailureExce
> ption: Cannot get Jedis connection; nested exception is 
> redis.clients.jedis.exceptions.JedisConnectionException: Could not get a 
> resource
>  from the pool
> org.springframework.data.redis.RedisConnectionFailureException: Cannot get 
> Jedis connection; nested exception is 
> redis.clients.jedis.exceptions.JedisConnectionException: Could not get a 
> resource from the pool
>         at 
> org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector(JedisConnectionFactory.java:281)
>         at 
> org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection(JedisConnectionFactory.java:464)
>         at 
> org.apache.nifi.redis.service.RedisConnectionPoolService.getConnection(RedisConnectionPoolService.java:89)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:498)
>         at 
> org.apache.nifi.controller.service.StandardControllerServiceInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:84)
>         at com.sun.proxy.$Proxy128.getConnection(Unknown Source)
>         at 
> org.apache.nifi.redis.service.RedisDistributedMapCacheClientService.withConnection(RedisDistributedMapCacheClientService.java:343)
>         at 
> org.apache.nifi.redis.service.RedisDistributedMapCacheClientService.put(RedisDistributedMapCacheClientService.java:189)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:498)
>         at 
> org.apache.nifi.controller.service.StandardControllerServiceInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:84)
>         at com.sun.proxy.$Proxy124.put(Unknown Source)
>         at 
> org.apache.nifi.processors.standard.PutDistributedMapCache.onTrigger(PutDistributedMapCache.java:202){panel}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to