zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eribeiro <...@git.apache.org>
Subject [GitHub] zookeeper pull request #307: ZOOKEEPER-2770 ZooKeeper slow operation log
Date Sat, 21 Oct 2017 15:47:43 GMT
Github user eribeiro commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/307#discussion_r146108343
  
    --- Diff: src/java/main/org/apache/zookeeper/server/ServerStats.java ---
    @@ -21,17 +21,32 @@
     
     
     import org.apache.zookeeper.common.Time;
    +import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.util.Timer;
    +import java.util.TimerTask;
     
     /**
      * Basic Server Statistics
      */
     public class ServerStats {
    +    private static final Logger LOG = LoggerFactory.getLogger(ServerStats.class);
    +
         private long packetsSent;
         private long packetsReceived;
         private long maxLatency;
         private long minLatency = Long.MAX_VALUE;
         private long totalLatency = 0;
         private long count = 0;
    +    private long numRequestsAboveThresholdTime = 0;
    +
    +    final static long requestWarnThresholdMs = QuorumPeerConfig.getRequestWarnResponseThresholdMs();
    +    final static Timer timer = new Timer();
    +    volatile Boolean waitForLoggingWarnThresholdMsg = false;
    --- End diff --
    
    Oh, excuse me, I got it. It's because you are synchronizing on it, right? Well, it's not
recommended (anti-pattern) to synchronize on non-final fields. Didn't Findbugs raised a warning
about this?


---

Mime
View raw message