YARN-4756. Unnecessary wait in Node Status Updater during reboot. (Eric Badger via kasha)

This commit is contained in:
Karthik Kambatla 2016-04-07 17:05:29 -07:00
parent a62637a413
commit e82f961a39
2 changed files with 23 additions and 11 deletions

View File

@ -284,6 +284,7 @@ public class NodeStatusUpdaterImpl extends AbstractService implements
return;
}
this.isStopped = true;
sendOutofBandHeartBeat();
try {
statusUpdater.join();
registerWithRM();

View File

@ -108,6 +108,7 @@ public class TestNodeManagerResync {
static final String user = "nobody";
private FileContext localFS;
private CyclicBarrier syncBarrier;
private CyclicBarrier updateBarrier;
private AtomicBoolean assertionFailedInThread = new AtomicBoolean(false);
private AtomicBoolean isNMShutdownCalled = new AtomicBoolean(false);
private final NodeManagerEvent resyncEvent =
@ -125,6 +126,7 @@ public class TestNodeManagerResync {
remoteLogsDir.mkdirs();
nmLocalDir.mkdirs();
syncBarrier = new CyclicBarrier(2);
updateBarrier = new CyclicBarrier(2);
}
@After
@ -803,9 +805,11 @@ public class TestNodeManagerResync {
.getContainerStatuses(gcsRequest).getContainerStatuses().get(0);
assertEquals(Resource.newInstance(1024, 1),
containerStatus.getCapability());
updateBarrier.await();
// Call the actual rebootNodeStatusUpdaterAndRegisterWithRM().
// This function should be synchronized with
// increaseContainersResource().
updateBarrier.await();
super.rebootNodeStatusUpdaterAndRegisterWithRM();
// Check status after registerWithRM
containerStatus = getContainerManager()
@ -831,7 +835,9 @@ public class TestNodeManagerResync {
List<Token> increaseTokens = new ArrayList<Token>();
// Add increase request.
Resource targetResource = Resource.newInstance(4096, 2);
try{
try {
updateBarrier.await();
increaseTokens.add(getContainerToken(targetResource));
IncreaseContainersResourceRequest increaseRequest =
IncreaseContainersResourceRequest.newInstance(increaseTokens);
@ -844,6 +850,11 @@ public class TestNodeManagerResync {
Assert.assertTrue(increaseResponse.getFailedRequests().isEmpty());
} catch (Exception e) {
e.printStackTrace();
} finally {
updateBarrier.await();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}