Skip to content

Commit 6f84269

Browse files
committed
HDFS-15185. StartupProgress reports edits segments until the entire startup completes. Contributed by Konstantin V Shvachko.
1 parent e77767b commit 6f84269

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/StartupProgress.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public void setSize(Phase phase, long size) {
218218
* @param total long to set
219219
*/
220220
public void setTotal(Phase phase, Step step, long total) {
221-
if (!isComplete()) {
221+
if (!isComplete(phase)) {
222222
lazyInitStep(phase, step).total = total;
223223
}
224224
}

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/startupprogress/TestStartupProgress.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.concurrent.Executors;
3434
import java.util.concurrent.TimeUnit;
3535

36+
import org.apache.hadoop.hdfs.server.namenode.startupprogress.StartupProgress.Counter;
3637
import org.junit.Before;
3738
import org.junit.Test;
3839

@@ -457,5 +458,15 @@ public void testTotal() {
457458
assertEquals(800L, view.getTotal(LOADING_FSIMAGE,
458459
loadingFsImageDelegationKeys));
459460
assertEquals(10000L, view.getTotal(LOADING_EDITS, loadingEditsFile));
461+
462+
// Try adding another step to the completed phase
463+
// Check the step is not added and the total is not updated
464+
Step step2 = new Step("file_2", 7000L);
465+
startupProgress.setTotal(LOADING_EDITS, step2, 2000L);
466+
view = startupProgress.createView();
467+
assertEquals(view.getTotal(LOADING_EDITS, step2), 0);
468+
Counter counter = startupProgress.getCounter(Phase.LOADING_EDITS, step2);
469+
counter.increment();
470+
assertEquals(view.getCount(LOADING_EDITS, step2), 0);
460471
}
461472
}

0 commit comments

Comments
 (0)