HDFS-15185. StartupProgress reports edits segments until the entire startup completes. Contributed by Konstantin V Shvachko.

This commit is contained in:
Konstantin V Shvachko 2020-02-21 10:51:14 -08:00
parent e77767bb1e
commit 6f84269bcd
2 changed files with 12 additions and 1 deletions

View File

@ -218,7 +218,7 @@ public class StartupProgress {
* @param total long to set * @param total long to set
*/ */
public void setTotal(Phase phase, Step step, long total) { public void setTotal(Phase phase, Step step, long total) {
if (!isComplete()) { if (!isComplete(phase)) {
lazyInitStep(phase, step).total = total; lazyInitStep(phase, step).total = total;
} }
} }

View File

@ -33,6 +33,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.hadoop.hdfs.server.namenode.startupprogress.StartupProgress.Counter;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -457,5 +458,15 @@ public class TestStartupProgress {
assertEquals(800L, view.getTotal(LOADING_FSIMAGE, assertEquals(800L, view.getTotal(LOADING_FSIMAGE,
loadingFsImageDelegationKeys)); loadingFsImageDelegationKeys));
assertEquals(10000L, view.getTotal(LOADING_EDITS, loadingEditsFile)); assertEquals(10000L, view.getTotal(LOADING_EDITS, loadingEditsFile));
// Try adding another step to the completed phase
// Check the step is not added and the total is not updated
Step step2 = new Step("file_2", 7000L);
startupProgress.setTotal(LOADING_EDITS, step2, 2000L);
view = startupProgress.createView();
assertEquals(view.getTotal(LOADING_EDITS, step2), 0);
Counter counter = startupProgress.getCounter(Phase.LOADING_EDITS, step2);
counter.increment();
assertEquals(view.getCount(LOADING_EDITS, step2), 0);
} }
} }