hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chia7...@apache.org
Subject hbase git commit: HBASE-12444 Total number of requests overflow because it's int
Date Thu, 07 Dec 2017 10:44:54 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-2 f8e232332 -> 2245dfc55


HBASE-12444 Total number of requests overflow because it's int


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/2245dfc5
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2245dfc5
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2245dfc5

Branch: refs/heads/branch-2
Commit: 2245dfc55820fea3811177ec15c66c6b993adfcb
Parents: f8e2323
Author: Chia-Ping Tsai <chia7712@gmail.com>
Authored: Thu Dec 7 18:39:12 2017 +0800
Committer: Chia-Ping Tsai <chia7712@gmail.com>
Committed: Thu Dec 7 18:42:32 2017 +0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/ClusterStatus.java  | 20 +++++++++++++-------
 .../rest/StorageClusterStatusResource.java      |  2 +-
 .../rest/model/StorageClusterStatusModel.java   |  2 +-
 .../hbase/regionserver/HRegionServer.java       |  2 +-
 .../org/apache/hadoop/hbase/util/HBaseFsck.java |  2 +-
 5 files changed, 17 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2245dfc5/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java
index 9c3cc73..693b418 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java
@@ -193,15 +193,21 @@ public class ClusterStatus {
 
   /**
    * @return the number of requests since last report
+   * @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0
+   *             Use {@link #getRequestCount()} instead.
    */
+  @Deprecated
   public int getRequestsCount() {
-    int count = 0;
-    if (liveServers != null && !liveServers.isEmpty()) {
-      for (Map.Entry<ServerName, ServerLoad> e: this.liveServers.entrySet()) {
-        count += e.getValue().getNumberOfRequests();
-      }
+    return (int) getRequestCount();
+  }
+
+  public long getRequestCount() {
+    if (liveServers == null) {
+      return 0L;
     }
-    return count;
+    return liveServers.values().stream()
+            .mapToLong(ServerLoad::getNumberOfRequests)
+            .sum();
   }
 
   /**
@@ -375,7 +381,7 @@ public class ClusterStatus {
     }
 
     sb.append("\nAverage load: " + getAverageLoad());
-    sb.append("\nNumber of requests: " + getRequestsCount());
+    sb.append("\nNumber of requests: " + getRequestCount());
     sb.append("\nNumber of regions: " + getRegionsCount());
 
     int ritSize = (intransition != null) ? intransition.size() : 0;

http://git-wip-us.apache.org/repos/asf/hbase/blob/2245dfc5/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java
index 865fab7..460f86a 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java
@@ -74,7 +74,7 @@ public class StorageClusterStatusResource extends ResourceBase {
         EnumSet.of(Option.LIVE_SERVERS, Option.DEAD_SERVERS));
       StorageClusterStatusModel model = new StorageClusterStatusModel();
       model.setRegions(status.getRegionsCount());
-      model.setRequests(status.getRequestsCount());
+      model.setRequests(status.getRequestCount());
       model.setAverageLoad(status.getAverageLoad());
       for (ServerName info: status.getServers()) {
         ServerLoad load = status.getLoad(info);

http://git-wip-us.apache.org/repos/asf/hbase/blob/2245dfc5/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java
----------------------------------------------------------------------
diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java
b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java
index 2f38a44..a20a405 100644
--- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java
+++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/StorageClusterStatusModel.java
@@ -630,7 +630,7 @@ public class StorageClusterStatusModel
    * @param requests the total number of requests per second handled by the
    * cluster
    */
-  public void setRequests(int requests) {
+  public void setRequests(long requests) {
     this.requests = requests;
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/2245dfc5/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 21a09a7..192c2e9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -1309,7 +1309,7 @@ public class HRegionServer extends HasThread implements
 
     ClusterStatusProtos.ServerLoad.Builder serverLoad = ClusterStatusProtos.ServerLoad.newBuilder();
     serverLoad.setNumberOfRequests((int) regionServerWrapper.getRequestsPerSecond());
-    serverLoad.setTotalNumberOfRequests((int) regionServerWrapper.getTotalRequestCount());
+    serverLoad.setTotalNumberOfRequests(regionServerWrapper.getTotalRequestCount());
     serverLoad.setUsedHeapMB((int)(usedMemory / 1024 / 1024));
     serverLoad.setMaxHeapMB((int) (maxMemory / 1024 / 1024));
     Set<String> coprocessors = getWAL(null).getCoprocessorHost().getCoprocessors();

http://git-wip-us.apache.org/repos/asf/hbase/blob/2245dfc5/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
index 0879a69..aab3b36 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
@@ -565,7 +565,7 @@ public class HBaseFsck extends Configured implements Closeable {
     }
 
     errors.print("Average load: " + status.getAverageLoad());
-    errors.print("Number of requests: " + status.getRequestsCount());
+    errors.print("Number of requests: " + status.getRequestCount());
     errors.print("Number of regions: " + status.getRegionsCount());
 
     List<RegionState> rits = status.getRegionsInTransition();


Mime
View raw message