Skip to content

Commit be50df6

Browse files
author
Zhihai Xu
committed
YARN-4440. FSAppAttempt#getAllowedLocalityLevelByTime should init the lastScheduler time. Contributed by Lin Yiqun
(cherry picked from commit 2aaed10)
1 parent 992f65d commit be50df6

File tree

3 files changed

+70
-0
lines changed
  • hadoop-yarn-project
    • hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src

3 files changed

+70
-0
lines changed

hadoop-yarn-project/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,9 @@ Release 2.8.0 - UNRELEASED
10831083
YARN-4402. TestNodeManagerShutdown And TestNodeManagerResync fails with
10841084
bind exception. (Brahma Reddy Battula via jianhe)
10851085

1086+
YARN-4440. FSAppAttempt#getAllowedLocalityLevelByTime should init the
1087+
lastScheduler time. (Lin Yiqun via zxu)
1088+
10861089
Release 2.7.3 - UNRELEASED
10871090

10881091
INCOMPATIBLE CHANGES

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/FSAppAttempt.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ public synchronized NodeType getAllowedLocalityLevelByTime(Priority priority,
286286

287287
// default level is NODE_LOCAL
288288
if (! allowedLocalityLevel.containsKey(priority)) {
289+
// add the initial time of priority to prevent comparing with FsApp
290+
// startTime and allowedLocalityLevel degrade
291+
lastScheduledContainer.put(priority, currentTimeMs);
292+
if (LOG.isDebugEnabled()) {
293+
LOG.debug("Init the lastScheduledContainer time, priority: " + priority
294+
+ ", time: " + currentTimeMs);
295+
}
289296
allowedLocalityLevel.put(priority, NodeType.NODE_LOCAL);
290297
return NodeType.NODE_LOCAL;
291298
}

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5151,4 +5151,64 @@ public void testUserAsDefaultQueueWithLeadingTrailingSpaceUserName()
51515151
assertEquals("root.user1", resourceManager.getRMContext().getRMApps()
51525152
.get(attId3.getApplicationId()).getQueue());
51535153
}
5154+
5155+
@Test
5156+
public void testFairSchedulerContinuousSchedulingInitTime() throws Exception {
5157+
int DELAY_THRESHOLD_TIME_MS = 1000;
5158+
conf.set(FairSchedulerConfiguration.CONTINUOUS_SCHEDULING_ENABLED, "true");
5159+
conf.set(FairSchedulerConfiguration.LOCALITY_DELAY_NODE_MS,
5160+
String.valueOf(DELAY_THRESHOLD_TIME_MS));
5161+
conf.set(FairSchedulerConfiguration.LOCALITY_DELAY_RACK_MS,
5162+
String.valueOf(DELAY_THRESHOLD_TIME_MS));
5163+
5164+
ControlledClock clock = new ControlledClock();
5165+
scheduler.setClock(clock);
5166+
scheduler.init(conf);
5167+
scheduler.start();
5168+
5169+
int priorityValue;
5170+
Priority priority;
5171+
FSAppAttempt fsAppAttempt;
5172+
ResourceRequest request1;
5173+
ResourceRequest request2;
5174+
ApplicationAttemptId id11;
5175+
5176+
priorityValue = 1;
5177+
id11 = createAppAttemptId(1, 1);
5178+
createMockRMApp(id11);
5179+
priority = Priority.newInstance(priorityValue);
5180+
scheduler.addApplication(id11.getApplicationId(), "root.queue1", "user1",
5181+
false);
5182+
scheduler.addApplicationAttempt(id11, false, false);
5183+
fsAppAttempt = scheduler.getApplicationAttempt(id11);
5184+
5185+
String hostName = "127.0.0.1";
5186+
RMNode node1 =
5187+
MockNodes.newNodeInfo(1, Resources.createResource(16 * 1024, 16), 1,
5188+
hostName);
5189+
List<ResourceRequest> ask1 = new ArrayList<>();
5190+
request1 =
5191+
createResourceRequest(1024, 8, node1.getRackName(), priorityValue, 1,
5192+
true);
5193+
request2 =
5194+
createResourceRequest(1024, 8, ResourceRequest.ANY, priorityValue, 1,
5195+
true);
5196+
ask1.add(request1);
5197+
ask1.add(request2);
5198+
scheduler.allocate(id11, ask1, new ArrayList<ContainerId>(), null, null,
5199+
null, null);
5200+
5201+
NodeAddedSchedulerEvent nodeEvent1 = new NodeAddedSchedulerEvent(node1);
5202+
scheduler.handle(nodeEvent1);
5203+
FSSchedulerNode node =
5204+
(FSSchedulerNode) scheduler.getSchedulerNode(node1.getNodeID());
5205+
// Tick the time and let the fsApp startTime different from initScheduler
5206+
// time
5207+
clock.tickSec(DELAY_THRESHOLD_TIME_MS / 1000);
5208+
scheduler.attemptScheduling(node);
5209+
Map<Priority, Long> lastScheduledContainer =
5210+
fsAppAttempt.getLastScheduledContainer();
5211+
long initSchedulerTime = lastScheduledContainer.get(priority);
5212+
assertEquals(DELAY_THRESHOLD_TIME_MS, initSchedulerTime);
5213+
}
51545214
}

0 commit comments

Comments
 (0)