YARN-2526. SLS can deadlock when all the threads are taken by AMSimulators. (Wei Yan via kasha)

This commit is contained in:
Karthik Kambatla 2014-09-09 15:13:07 -07:00
parent 3e8f353c8e
commit 28d99db992
2 changed files with 26 additions and 20 deletions

View File

@ -179,26 +179,8 @@ public class MRAMSimulator extends AMSimulator {
return rm.getApplicationMasterService().allocate(request); return rm.getApplicationMasterService().allocate(request);
} }
}); });
if (response != null) {
// waiting until the AM container is allocated responseQueue.put(response);
while (true) {
if (response != null && ! response.getAllocatedContainers().isEmpty()) {
// get AM container
Container container = response.getAllocatedContainers().get(0);
se.getNmMap().get(container.getNodeId())
.addNewContainer(container, -1L);
// start AM container
amContainer = container;
LOG.debug(MessageFormat.format("Application {0} starts its " +
"AM container ({1}).", appId, amContainer.getId()));
isAMContainerRunning = true;
break;
}
// this sleep time is different from HeartBeat
Thread.sleep(1000);
// send out empty request
sendContainerRequest();
response = responseQueue.take();
} }
} }
@ -206,6 +188,26 @@ public class MRAMSimulator extends AMSimulator {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void processResponseQueue() protected void processResponseQueue()
throws InterruptedException, YarnException, IOException { throws InterruptedException, YarnException, IOException {
// Check whether receive the am container
if (!isAMContainerRunning) {
if (!responseQueue.isEmpty()) {
AllocateResponse response = responseQueue.take();
if (response != null
&& !response.getAllocatedContainers().isEmpty()) {
// Get AM container
Container container = response.getAllocatedContainers().get(0);
se.getNmMap().get(container.getNodeId())
.addNewContainer(container, -1L);
// Start AM container
amContainer = container;
LOG.debug(MessageFormat.format("Application {0} starts its " +
"AM container ({1}).", appId, amContainer.getId()));
isAMContainerRunning = true;
}
}
return;
}
while (! responseQueue.isEmpty()) { while (! responseQueue.isEmpty()) {
AllocateResponse response = responseQueue.take(); AllocateResponse response = responseQueue.take();
@ -262,6 +264,7 @@ public class MRAMSimulator extends AMSimulator {
LOG.debug(MessageFormat.format("Application {0} sends out event " + LOG.debug(MessageFormat.format("Application {0} sends out event " +
"to clean up its AM container.", appId)); "to clean up its AM container.", appId));
isFinished = true; isFinished = true;
break;
} }
// check allocated containers // check allocated containers

View File

@ -302,6 +302,9 @@ Release 2.6.0 - UNRELEASED
YARN-2519. Credential Provider related unit tests failed on Windows. YARN-2519. Credential Provider related unit tests failed on Windows.
(Xiaoyu Yao via cnauroth) (Xiaoyu Yao via cnauroth)
YARN-2526. SLS can deadlock when all the threads are taken by AMSimulators.
(Wei Yan via kasha)
Release 2.5.1 - UNRELEASED Release 2.5.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES