sanjeet006py commented on code in PR #6868:
URL: https://github.com/apache/hbase/pull/6868#discussion_r2096341979


##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/metrics/ScanMetricsHolder.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.hadoop.hbase.client.metrics;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * Generic holder class for capturing Scan Metrics as a map of metric name 
({@link String}) -> Value
+ * ({@link AtomicLong}).
+ */
[email protected]
+public class ScanMetricsHolder {

Review Comment:
   The expected usage pattern looks like following: one thread will update the 
value of counters in `ScanMetrics` object as I see that scanners in HBase 
always scan in serial manner w/o any parallelism. For consuming the metrics, 
`getMetricsMap()` or `getMetricsMapByRegion()` can be called. Consumption of a 
metrics can happen from multiple threads in parallel. Because Scanners operate 
in sequential manner so, only one thread will be calling `moveToNextRegion()` 
at a given point in time to reset the counter variables with new set of 
`AtomicLong` instances. But older `AtomicLong` instances are not discarded 
rather kept in `ScanMetricsHolder` instance of the previous region. While 
`moveToNextRegion` is called, any number of threads can call `getMetricsMap()` 
and `getMetricsMapByRegion` and they will see consistent results.
   Please correct me if I understood anything wrong.



-- 
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]

Reply via email to