You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/03/10 01:04:26 UTC

[GitHub] sijie closed pull request #1243: Removed ServerStats since it was not used anymore

sijie closed pull request #1243: Removed ServerStats since it was not used anymore
URL: https://github.com/apache/bookkeeper/pull/1243
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 a5b2141b3..bca878b1f 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 Object decode(ByteBuf packet)
             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 Object encode(Object msg, ByteBufAllocator allocator)
             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 b8fc8b170..000000000
--- 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 4df0dcca9..a13bace7f 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 String getZooKeeperConnectString() {
     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 void stopServer() throws Exception {
 
     public void killServer() throws Exception {
         stopServer();
-        // ServerStats.unregister();
         FileUtils.deleteDirectory(zkTmpDir);
     }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services