Tejaskriya commented on code in PR #8448:
URL: https://github.com/apache/ozone/pull/8448#discussion_r2156699937


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/StorageVolumeChecker.java:
##########
@@ -165,7 +164,6 @@ public synchronized void registerVolumeSet(VolumeSet 
volumeSet) {
   public synchronized void checkAllVolumeSets() {
     final long gap = timer.monotonicNow() - lastAllVolumeSetsCheckComplete;
     if (gap < minDiskCheckGapMs) {
-      numSkippedChecks.incrementAndGet();

Review Comment:
   I don't think we should remove this metric, as it could be beneficial to 
know how many checks are skipped.
   Maybe we can name it as number of iterations skipped? Feel free to come up 
with a better name.



##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/dn/DatanodeTestUtils.java:
##########
@@ -219,20 +219,6 @@ public static void restoreBadVolume(StorageVolume vol) {
     restoreBadRootDir(vol.getStorageDir());
   }
 
-  /**
-   * Wait for detect volume failure.
-   *
-   * @param volSet
-   * @param numOfChecks target number of checks
-   * @throws Exception
-   */
-  public static void waitForCheckVolume(MutableVolumeSet volSet,
-                                        long numOfChecks) throws Exception {
-    GenericTestUtils.waitFor(
-        () -> numOfChecks == volSet.getVolumeChecker().getNumVolumeChecks(),
-        100, 10000);
-  }
-

Review Comment:
   What is the motivation behind removing this?



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/VolumeInfoMetrics.java:
##########
@@ -63,6 +64,9 @@ public class VolumeInfoMetrics implements MetricsSource {
   @Metric("Volume available space is insufficient")
   private MutableGaugeInt availableSpaceInsufficient;
 
+  @Metric("Returns the Number of Volumes Scanned")
+  private MutableCounterLong numScans;
+

Review Comment:
   If possible, let's track if a particular volume is skipped to be scanned. We 
can add a metric for that



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/StorageVolumeScannerMetrics.java:
##########
@@ -0,0 +1,106 @@
+/*
+ * 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.ozone.container.common.volume;
+
+import java.util.Collection;
+import org.apache.hadoop.hdds.annotation.InterfaceAudience;
+import org.apache.hadoop.metrics2.MetricsSystem;
+import org.apache.hadoop.metrics2.annotation.Metric;
+import org.apache.hadoop.metrics2.annotation.Metrics;
+import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
+import org.apache.hadoop.metrics2.lib.MutableCounterLong;
+import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
+
+/**
+ * This class captures the Storage Volume Scanner Metrics.
+ **/
[email protected]
+@Metrics(about = "Storage Volume Scanner Metrics", context = "dfs")
+public class StorageVolumeScannerMetrics {
+  public static final String SOURCE_NAME = 
StorageVolumeScannerMetrics.class.getSimpleName();
+
+  @Metric("number of volumes scanned in the current iteration")
+  private MutableGaugeLong numVolumesScanned;

Review Comment:
   ```suggestion
     private MutableGaugeLong numVolumesScannedInLastIteration;
   ```
   Rename this variable to indicate that it is only for the last iteration (as 
this is the String used in prometheus or grafana).



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/StorageVolumeChecker.java:
##########
@@ -176,12 +174,26 @@ public synchronized void checkAllVolumeSets() {
     }
 
     try {
+      int totalScanned = 0;
       for (VolumeSet volSet : registeredVolumeSets) {
+        if (volSet instanceof MutableVolumeSet) {
+          StorageVolume.VolumeType type = ((MutableVolumeSet) 
volSet).getVolumeType();
+          switch (type) {
+          case DATA_VOLUME:
+            metrics.incNumDataVolumesScanned();
+            break;
+          case META_VOLUME:
+            metrics.incNumMetadataVolumesScanned();

Review Comment:
   Seems like we are incrementing by 1 for 1 volume set scan. But a VolumeSet 
has multiple volumes, so the metric will be misleading. 
   We should increment the metric by the number of volumes in the set



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/StorageVolumeChecker.java:
##########
@@ -232,7 +244,7 @@ public Set<? extends StorageVolume> checkAllVolumes(
           maxAllowedTimeForCheckMs);
     }
 
-    numAllVolumeChecks.incrementAndGet();
+    metrics.incNumScanIterations();

Review Comment:
   checkAllVolumes is called for each volumeSet. So this metric ends up 
counting how many volume sets we are scanning, instead of how many iterations 
of the volume scanner has taken place.
   @errose28 which is the number we want to capture here?
   
   I was of the opinion that this is meant to capture the iterations of the 
background scanner, (hence the above suggestion about renaming skipped scans)



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to