HDFS-5456. NameNode startup progress creates new steps if caller attempts to create a counter for a step that doesn't already exist. Contributed by Chris Nauroth.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1538872 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris Nauroth 2013-11-05 06:04:07 +00:00
parent d12010e658
commit c47b3d7502
3 changed files with 13 additions and 1 deletions

View File

@ -579,6 +579,9 @@ Release 2.2.1 - UNRELEASED
HDFS-5035. getFileLinkStatus and rename do not correctly check permissions HDFS-5035. getFileLinkStatus and rename do not correctly check permissions
of symlinks. (Andrew Wang via Colin Patrick McCabe) of symlinks. (Andrew Wang via Colin Patrick McCabe)
HDFS-5456. NameNode startup progress creates new steps if caller attempts to
create a counter for a step that doesn't already exist. (cnauroth)
Release 2.2.0 - 2013-10-13 Release 2.2.0 - 2013-10-13
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -149,8 +149,8 @@ public class StartupProgress {
* @return Counter associated with phase and step * @return Counter associated with phase and step
*/ */
public Counter getCounter(Phase phase, Step step) { public Counter getCounter(Phase phase, Step step) {
final StepTracking tracking = lazyInitStep(phase, step);
if (!isComplete()) { if (!isComplete()) {
final StepTracking tracking = lazyInitStep(phase, step);
return new Counter() { return new Counter() {
@Override @Override
public void increment() { public void increment() {

View File

@ -179,6 +179,14 @@ public class TestStartupProgress {
startupProgress.endStep(LOADING_FSIMAGE, step); startupProgress.endStep(LOADING_FSIMAGE, step);
startupProgress.endPhase(LOADING_FSIMAGE); startupProgress.endPhase(LOADING_FSIMAGE);
// Also attempt a whole new step that wasn't used last time.
startupProgress.beginPhase(LOADING_EDITS);
Step newStep = new Step("file1");
startupProgress.beginStep(LOADING_EDITS, newStep);
incrementCounter(startupProgress, LOADING_EDITS, newStep, 100L);
startupProgress.endStep(LOADING_EDITS, newStep);
startupProgress.endPhase(LOADING_EDITS);
StartupProgressView after = startupProgress.createView(); StartupProgressView after = startupProgress.createView();
// Expect that data was frozen after completion of entire startup process, so // Expect that data was frozen after completion of entire startup process, so
@ -200,6 +208,7 @@ public class TestStartupProgress {
after.getTotal(LOADING_FSIMAGE)); after.getTotal(LOADING_FSIMAGE));
assertEquals(before.getTotal(LOADING_FSIMAGE, step), assertEquals(before.getTotal(LOADING_FSIMAGE, step),
after.getTotal(LOADING_FSIMAGE, step)); after.getTotal(LOADING_FSIMAGE, step));
assertFalse(after.getSteps(LOADING_EDITS).iterator().hasNext());
} }
@Test(timeout=10000) @Test(timeout=10000)