From 1263e024b9744574bf4042b2f479a749c340fbcd Mon Sep 17 00:00:00 2001 From: Viraj Jasani Date: Thu, 12 Jan 2023 14:26:52 -0800 Subject: [PATCH] HDFS-16887 Log start and end of phase/step in startup progress (#5292) Signed-off-by: Chris Nauroth --- .../namenode/startupprogress/PhaseTracking.java | 12 ++++++++++++ .../namenode/startupprogress/StartupProgress.java | 10 ++++++++++ .../hdfs/server/namenode/startupprogress/Step.java | 11 +++++++++++ .../namenode/startupprogress/StepTracking.java | 11 +++++++++++ 4 files changed, 44 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/PhaseTracking.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/PhaseTracking.java index 3f1d9030297..b01a4c2845f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/PhaseTracking.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/PhaseTracking.java @@ -20,6 +20,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.hadoop.classification.InterfaceAudience; /** @@ -43,4 +44,15 @@ final class PhaseTracking extends AbstractTracking { } return clone; } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("file", file) + .append("size", size) + .append("steps", steps) + .append("beginTime", beginTime) + .append("endTime", endTime) + .toString(); + } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/StartupProgress.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/StartupProgress.java index 6249a84e7f9..0ca338b34b1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/StartupProgress.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/StartupProgress.java @@ -24,6 +24,9 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.apache.hadoop.classification.InterfaceAudience; /** @@ -48,6 +51,9 @@ import org.apache.hadoop.classification.InterfaceAudience; */ @InterfaceAudience.Private public class StartupProgress { + + private static final Logger LOG = LoggerFactory.getLogger(StartupProgress.class); + // package-private for access by StartupProgressView final Map phases = new ConcurrentHashMap(); @@ -81,6 +87,7 @@ public class StartupProgress { if (!isComplete()) { phases.get(phase).beginTime = monotonicNow(); } + LOG.debug("Beginning of the phase: {}", phase); } /** @@ -94,6 +101,7 @@ public class StartupProgress { if (!isComplete(phase)) { lazyInitStep(phase, step).beginTime = monotonicNow(); } + LOG.debug("Beginning of the step. Phase: {}, Step: {}", phase, step); } /** @@ -105,6 +113,7 @@ public class StartupProgress { if (!isComplete()) { phases.get(phase).endTime = monotonicNow(); } + LOG.debug("End of the phase: {}", phase); } /** @@ -118,6 +127,7 @@ public class StartupProgress { if (!isComplete(phase)) { lazyInitStep(phase, step).endTime = monotonicNow(); } + LOG.debug("End of the step. Phase: {}, Step: {}", phase, step); } /** diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/Step.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/Step.java index 0baf99d994e..5dee13d2a5e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/Step.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/Step.java @@ -21,6 +21,7 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.lang3.builder.CompareToBuilder; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.hadoop.classification.InterfaceAudience; /** @@ -139,4 +140,14 @@ public class Step implements Comparable { return new HashCodeBuilder().append(file).append(size).append(type) .toHashCode(); } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("file", file) + .append("sequenceNumber", sequenceNumber) + .append("size", size) + .append("type", type) + .toString(); + } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/StepTracking.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/StepTracking.java index bc224ec5670..799b4d0b09f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/StepTracking.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/StepTracking.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hdfs.server.namenode.startupprogress; import java.util.concurrent.atomic.AtomicLong; +import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.hadoop.classification.InterfaceAudience; /** @@ -36,4 +37,14 @@ final class StepTracking extends AbstractTracking { clone.total = total; return clone; } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("count", count) + .append("total", total) + .append("beginTime", beginTime) + .append("endTime", endTime) + .toString(); + } }