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

ASF GitHub Bot commented on STORM-1886:
---------------------------------------

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

    https://github.com/apache/storm/pull/1470#discussion_r68261764
  
    --- Diff: 
external/storm-redis/src/main/java/org/apache/storm/redis/state/RedisKeyValueState.java
 ---
    @@ -116,20 +123,30 @@ private void initPendingCommit() {
         @Override
         public void put(K key, V value) {
             LOG.debug("put key '{}', value '{}'", key, value);
    -        pendingPrepare.put(encode(keySerializer.serialize(key)),
    -                           encode(valueSerializer.serialize(value)));
    +        String redisKey = encode(keySerializer.serialize(key));
    +        synchronized (this) {
    +            pendingPrepare.put(redisKey,
    +                    encode(valueSerializer.serialize(value)));
    +            pendingDeletePrepare.remove(redisKey);
    +        }
         }
     
         @Override
         public V get(K key) {
             LOG.debug("get key '{}'", key);
             String redisKey = encode(keySerializer.serialize(key));
             String redisValue = null;
    -        if (pendingPrepare.containsKey(redisKey)) {
    -            redisValue = pendingPrepare.get(redisKey);
    -        } else if (pendingCommit.containsKey(redisKey)) {
    -            redisValue = pendingCommit.get(redisKey);
    -        } else {
    +        boolean found = false;
    +        synchronized (this) {
    +            if (pendingPrepare.containsKey(redisKey) || 
pendingDeletePrepare.contains(redisKey)) {
    --- End diff --
    
    if `pendingDeletePrepare` contains the key, then it was already removed 
from `pendingPrepare`, so it will return `null`


> Extend KeyValueState interface with delete method
> -------------------------------------------------
>
>                 Key: STORM-1886
>                 URL: https://issues.apache.org/jira/browse/STORM-1886
>             Project: Apache Storm
>          Issue Type: Improvement
>            Reporter: Balazs Kossovics
>
> Even if the implementation of checkpointing only uses the get/put methods of 
> the KeyValueState interface, the existance of a delete method could be really 
> useful in the general case.
> I made a first implementation, what do you think about?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to