sanjeet006py commented on code in PR #6868:
URL: https://github.com/apache/hbase/pull/6868#discussion_r2057772153
##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/metrics/ServerSideScanMetrics.java:
##########
@@ -117,4 +121,64 @@ public Map<String, Long> getMetricsMap(boolean reset) {
// Build the immutable map so that people can't mess around with it.
return builder.build();
}
+
+ public ServerName getServerName() {
+ return this.serverName;
+ }
+
+ public void setServerName(ServerName serverName) {
+ if (this.serverName == null) {
+ this.serverName = serverName;
+ }
+ }
+
+ public void setEncodedRegionName(String encodedRegionName) {
+ if (this.encodedRegionName == null) {
+ this.encodedRegionName = encodedRegionName;
+ }
+ }
+
+ public String getEncodedRegionName() {
+ return this.encodedRegionName;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("ServerName:");
+ sb.append(this.serverName);
+ sb.append(",EncodedRegion:");
+ sb.append(this.encodedRegionName);
+ sb.append(",[");
+ boolean isFirstMetric = true;
+ for (Map.Entry<String, AtomicLong> e : this.counters.entrySet()) {
+ if (isFirstMetric) {
+ isFirstMetric = false;
+ } else {
+ sb.append(",");
+ }
+ sb.append(e.getKey());
+ sb.append(":");
+ sb.append(e.getValue().get());
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+
+ public void combineMetrics(ScanMetrics other) {
+ for (Map.Entry<String, AtomicLong> entry : other.counters.entrySet()) {
+ String counterName = entry.getKey();
+ AtomicLong counter = entry.getValue();
+ this.addToCounter(counterName, counter.get());
+ }
+ if (
+ this.encodedRegionName != null
+ && !Objects.equals(this.encodedRegionName,
other.getEncodedRegionName())
+ ) {
+ this.encodedRegionName = null;
+ }
+ if (this.serverName != null && !Objects.equals(this.serverName,
other.getServerName())) {
+ this.serverName = null;
Review Comment:
`encodedRegionName` and `serverName` are not part of ScanMetrics. When
combining ScanMetrics if we observe that the ScanMetrics object in which all
other ScanMetrics are getting combined has different `serverName` and
`encodedRegionName` then we set these two fields to `null` as now we can't
deterministically pick any one value. Plus, the assumption is someone getting
combined ScanMetrics is not interested in region level details as we have
separate getter for getting list of region level ScanMetrics.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]