This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new e3d47ae  Removed ServerStats since it was not used anymore
e3d47ae is described below

commit e3d47ae14a0140b10a6303ecfddbcba66ce90933
Author: Matteo Merli <mme...@apache.org>
AuthorDate: Fri Mar 9 17:04:16 2018 -0800

    Removed ServerStats since it was not used anymore
    
    ServerStats class was previously used to expose stats through JMX but it's
    not being used anymore and it's just causing lock contention in Bookie IO 
threads
    when using v2 protocol.
    
    Author: Matteo Merli <mme...@apache.org>
    
    Reviewers: Sijie Guo <si...@apache.org>
    
    This closes #1243 from merlimat/remove-server-stats
---
 .../bookkeeper/proto/BookieProtoEncoding.java      |   3 -
 .../org/apache/bookkeeper/proto/ServerStats.java   | 104 ---------------------
 .../org/apache/bookkeeper/test/ZooKeeperUtil.java  |   2 -
 3 files changed, 109 deletions(-)

diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtoEncoding.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtoEncoding.java
index a5b2141..bca878b 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtoEncoding.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtoEncoding.java
@@ -158,8 +158,6 @@ public class BookieProtoEncoding {
             long ledgerId = -1;
             long entryId = BookieProtocol.INVALID_ENTRY_ID;
 
-            ServerStats.getInstance().incrementPacketsReceived();
-
             switch (opCode) {
             case BookieProtocol.ADDENTRY: {
                 byte[] masterKey = readMasterKey(packet);
@@ -241,7 +239,6 @@ public class BookieProtoEncoding {
             ByteBuf buf = allocator.buffer(24);
             buf.writeInt(PacketHeader.toInt(r.getProtocolVersion(), 
r.getOpCode(), (short) 0));
 
-            ServerStats.getInstance().incrementPacketsSent();
             try {
                 if (msg instanceof BookieProtocol.ReadResponse) {
                     buf.writeInt(r.getErrorCode());
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ServerStats.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ServerStats.java
deleted file mode 100644
index b8fc8b1..0000000
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ServerStats.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.bookkeeper.proto;
-
-import org.apache.bookkeeper.util.MathUtils;
-
-/**
- * A class to hold server statistics.
- */
-public class ServerStats {
-    private static ServerStats instance = new ServerStats();
-    private long packetsSent;
-    private long packetsReceived;
-    private long maxLatency;
-    private long minLatency = Long.MAX_VALUE;
-    private long totalLatency = 0;
-    private long count = 0;
-
-    public static ServerStats getInstance() {
-        return instance;
-    }
-
-    protected ServerStats() {
-    }
-
-    // getters
-    public synchronized long getMinLatency() {
-        return (minLatency == Long.MAX_VALUE) ? 0 : minLatency;
-    }
-
-    public synchronized long getAvgLatency() {
-        if (count != 0) {
-            return totalLatency / count;
-        }
-        return 0;
-    }
-
-    public synchronized long getMaxLatency() {
-        return maxLatency;
-    }
-
-    public synchronized long getPacketsReceived() {
-        return packetsReceived;
-    }
-
-    public synchronized long getPacketsSent() {
-        return packetsSent;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("Latency min/avg/max: " + getMinLatency() + "/" + 
getAvgLatency() + "/" + getMaxLatency() + "\n");
-        sb.append("Received: " + getPacketsReceived() + "\n");
-        sb.append("Sent: " + getPacketsSent() + "\n");
-        return sb.toString();
-    }
-
-    synchronized void updateLatency(long requestCreateTime) {
-        long latency = MathUtils.now() - requestCreateTime;
-        totalLatency += latency;
-        count++;
-        if (latency < minLatency) {
-            minLatency = latency;
-        }
-        if (latency > maxLatency) {
-            maxLatency = latency;
-        }
-    }
-
-    public synchronized void resetLatency() {
-        totalLatency = count = maxLatency = 0;
-        minLatency = Long.MAX_VALUE;
-    }
-
-    public synchronized void resetMaxLatency() {
-        maxLatency = getMinLatency();
-    }
-
-    public synchronized void incrementPacketsReceived() {
-        packetsReceived++;
-    }
-
-    public synchronized void incrementPacketsSent() {
-        packetsSent++;
-    }
-
-    public synchronized void resetRequestCounters() {
-        packetsReceived = packetsSent = 0;
-    }
-
-}
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ZooKeeperUtil.java 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ZooKeeperUtil.java
index 4df0dcc..a13bace 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ZooKeeperUtil.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ZooKeeperUtil.java
@@ -86,7 +86,6 @@ public class ZooKeeperUtil {
     public void startServer() throws Exception {
         // create a ZooKeeper server(dataDir, dataLogDir, port)
         LOG.debug("Running ZK server");
-        // ServerStats.registerAsConcrete();
         ClientBase.setupTestEnv();
         zkTmpDir = IOUtils.createTempDir("zookeeper", "test");
 
@@ -189,7 +188,6 @@ public class ZooKeeperUtil {
 
     public void killServer() throws Exception {
         stopServer();
-        // ServerStats.unregister();
         FileUtils.deleteDirectory(zkTmpDir);
     }
 }

-- 
To stop receiving notification emails like this one, please contact
si...@apache.org.

Reply via email to