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

This commit is contained in:
Chia-Ping Tsai 2017-12-07 18:39:12 +08:00
parent ba4f9f8349
commit 464e4e8058
5 changed files with 17 additions and 11 deletions

View File

@ -193,15 +193,21 @@ public class ClusterStatus {
/** /**
* @return the number of requests since last report * @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() { public int getRequestsCount() {
int count = 0; return (int) getRequestCount();
if (liveServers != null && !liveServers.isEmpty()) { }
for (Map.Entry<ServerName, ServerLoad> e: this.liveServers.entrySet()) {
count += e.getValue().getNumberOfRequests(); 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("\nAverage load: " + getAverageLoad());
sb.append("\nNumber of requests: " + getRequestsCount()); sb.append("\nNumber of requests: " + getRequestCount());
sb.append("\nNumber of regions: " + getRegionsCount()); sb.append("\nNumber of regions: " + getRegionsCount());
int ritSize = (intransition != null) ? intransition.size() : 0; int ritSize = (intransition != null) ? intransition.size() : 0;

View File

@ -74,7 +74,7 @@ public class StorageClusterStatusResource extends ResourceBase {
EnumSet.of(Option.LIVE_SERVERS, Option.DEAD_SERVERS)); EnumSet.of(Option.LIVE_SERVERS, Option.DEAD_SERVERS));
StorageClusterStatusModel model = new StorageClusterStatusModel(); StorageClusterStatusModel model = new StorageClusterStatusModel();
model.setRegions(status.getRegionsCount()); model.setRegions(status.getRegionsCount());
model.setRequests(status.getRequestsCount()); model.setRequests(status.getRequestCount());
model.setAverageLoad(status.getAverageLoad()); model.setAverageLoad(status.getAverageLoad());
for (ServerName info: status.getServers()) { for (ServerName info: status.getServers()) {
ServerLoad load = status.getLoad(info); ServerLoad load = status.getLoad(info);

View File

@ -630,7 +630,7 @@ public class StorageClusterStatusModel
* @param requests the total number of requests per second handled by the * @param requests the total number of requests per second handled by the
* cluster * cluster
*/ */
public void setRequests(int requests) { public void setRequests(long requests) {
this.requests = requests; this.requests = requests;
} }

View File

@ -1309,7 +1309,7 @@ public class HRegionServer extends HasThread implements
ClusterStatusProtos.ServerLoad.Builder serverLoad = ClusterStatusProtos.ServerLoad.newBuilder(); ClusterStatusProtos.ServerLoad.Builder serverLoad = ClusterStatusProtos.ServerLoad.newBuilder();
serverLoad.setNumberOfRequests((int) regionServerWrapper.getRequestsPerSecond()); serverLoad.setNumberOfRequests((int) regionServerWrapper.getRequestsPerSecond());
serverLoad.setTotalNumberOfRequests((int) regionServerWrapper.getTotalRequestCount()); serverLoad.setTotalNumberOfRequests(regionServerWrapper.getTotalRequestCount());
serverLoad.setUsedHeapMB((int)(usedMemory / 1024 / 1024)); serverLoad.setUsedHeapMB((int)(usedMemory / 1024 / 1024));
serverLoad.setMaxHeapMB((int) (maxMemory / 1024 / 1024)); serverLoad.setMaxHeapMB((int) (maxMemory / 1024 / 1024));
Set<String> coprocessors = getWAL(null).getCoprocessorHost().getCoprocessors(); Set<String> coprocessors = getWAL(null).getCoprocessorHost().getCoprocessors();

View File

@ -565,7 +565,7 @@ public class HBaseFsck extends Configured implements Closeable {
} }
errors.print("Average load: " + status.getAverageLoad()); 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()); errors.print("Number of regions: " + status.getRegionsCount());
List<RegionState> rits = status.getRegionsInTransition(); List<RegionState> rits = status.getRegionsInTransition();