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 @@ protected void rebootNodeStatusUpdaterAndRegisterWithRM() {
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 void setup() throws UnsupportedFileSystemException {
remoteLogsDir.mkdirs();
nmLocalDir.mkdirs();
syncBarrier = new CyclicBarrier(2);
updateBarrier = new CyclicBarrier(2);
}
@After
@ -803,9 +805,11 @@ protected void rebootNodeStatusUpdaterAndRegisterWithRM() {
.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()
@ -832,6 +836,8 @@ public void run() {
// 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 void run() {
Assert.assertTrue(increaseResponse.getFailedRequests().isEmpty());
} catch (Exception e) {
e.printStackTrace();
} finally {
updateBarrier.await();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}