devmadhuu commented on code in PR #12079:
URL: https://github.com/apache/ozone/pull/12079#discussion_r4694831387


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/SCMPipelineMetrics.java:
##########
@@ -104,6 +124,61 @@ public void getMetrics(MetricsCollector collector, boolean 
all) {
     pipelineCreationLatencyNs.snapshot(recordBuilder, true);
     numBlocksAllocated
         .forEach((pid, metric) -> metric.snapshot(recordBuilder, true));
+    tierPlacementFailures.forEach((tier, counters) -> 
counters.forEach((reason, counter) ->
+        collector.addRecord(SOURCE_NAME)
+            .tag(REQUESTED_TIER, tier)
+            .tag(REASON, reason.label)
+            .addCounter(TIER_PLACEMENT_FAILURES, counter.value())));
+  }
+
+  private void addTierPlacementCounters(String tier) {
+    Map<PlacementFailureReason, MutableCounterLong> counters = new 
EnumMap<>(PlacementFailureReason.class);
+    for (PlacementFailureReason reason : PlacementFailureReason.values()) {
+      counters.put(reason, new MutableCounterLong(TIER_PLACEMENT_FAILURES, 0));
+    }
+    tierPlacementFailures.put(tier, counters);
+  }
+
+  /**
+   * Counts one unsuccessful RATIS/standalone tier allocation after all 
provider retries. A later allocation on a
+   * fallback tier may still succeed. This does not count background pipeline 
creation or change aggregate counters.
+   * Missing/empty tiers are UNKNOWN. Reasons use SCM result codes, never 
exception messages; no_space includes
+   * insufficient eligible storage of the requested type, not just full 
volumes. Unclassified failures are other.
+   *
+   * @param tier tier of this allocation attempt, including a fallback tier 
when it is attempted
+   * @param failure last unsuccessful creation/wait operation, or null when no 
structured failure is available
+   */
+  void incTierPlacementFailure(StorageTier tier, IOException failure) {
+    String requestedTier = tier == null || tier == StorageTier.EMPTY ? 
UNKNOWN_TIER : tier.name();
+    
tierPlacementFailures.get(requestedTier).get(PlacementFailureReason.fromException(failure)).incr();
+  }
+
+  private enum PlacementFailureReason {
+    NO_SPACE("no_space"),
+    NO_SUITABLE_NODE("no_suitable_node"),
+    OTHER("other");

Review Comment:
   Mostly yes. The remaining cases are safe mode, SCM HA/Ratis errors, internal 
errors, a pipeline that disappears while waiting, and a created pipeline that 
still yields no container. Most of them are SCM-wide rather than tier-specific, 
and several are plain IOExceptions without a result code, so splitting them 
would mean reading the exception message, which I wanted to avoid. The one 
tier-related case is the pipeline readiness timeout; per-tier pipeline outcomes 
are tracked by HDDS-17823.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableRatisContainerProvider.java:
##########
@@ -53,6 +54,7 @@ public WritableRatisContainerProvider(
     this.pipelineManager = pipelineManager;
     this.containerManager = containerManager;
     this.pipelineChoosePolicy = pipelineChoosePolicy;
+    this.metrics = SCMPipelineMetrics.create();

Review Comment:
   You are right. We can use `PipelineManager.getMetrics`. Updated the code.



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