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

    https://github.com/apache/storm/pull/2338#discussion_r140340286
  
    --- Diff: 
storm-client/src/jvm/org/apache/storm/cluster/StormClusterStateImpl.java ---
    @@ -459,14 +463,15 @@ public boolean topologyBackpressure(String stormId, 
Runnable callback) {
                 backPressureCallback.put(stormId, callback);
             }
             String path = ClusterUtils.backpressureStormRoot(stormId);
    -        List<String> childrens = null;
    +        long mostRecentTimestamp = 0;
             if(stateStorage.node_exists(path, false)) {
    -            childrens = stateStorage.get_children(path, callback != null);
    -        } else {
    -            childrens = new ArrayList<>();
    +            List<String> children = stateStorage.get_children(path, 
callback != null);
    +            mostRecentTimestamp = children.stream().map(childPath -> 
stateStorage.get_data(ClusterUtils.backpressurePath(stormId, childPath), false))
    +                    .filter(data -> data != null).mapToLong(data -> 
ByteBuffer.wrap(data).getLong()).max().orElse(0);
             }
    -        return childrens.size() > 0;
    -
    +        boolean ret =  ((System.currentTimeMillis() - mostRecentTimestamp) 
< 30000);
    --- End diff --
    
    I agree with @govind-menon, it would be good to make some constants (or 
config if necessary) for these.


---

Reply via email to