YARN-881. Priority#compareTo method seems to be wrong. (Jian He via bikas)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1516331 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bikas Saha 2013-08-21 23:33:59 +00:00
parent 2d614a916c
commit 42a2846b3b
4 changed files with 12 additions and 3 deletions

View File

@ -80,6 +80,8 @@ Release 2.1.1-beta - UNRELEASED
YARN-1006. Fixed broken rendering in the Nodes list web page on the RM web YARN-1006. Fixed broken rendering in the Nodes list web page on the RM web
UI. (Xuan Gong via vinodkv) UI. (Xuan Gong via vinodkv)
YARN-881. Priority#compareTo method seems to be wrong. (Jian He via bikas)
Release 2.1.0-beta - 2013-08-22 Release 2.1.0-beta - 2013-08-22
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -81,7 +81,7 @@ public boolean equals(Object obj) {
@Override @Override
public int compareTo(Priority other) { public int compareTo(Priority other) {
return this.getPriority() - other.getPriority(); return other.getPriority() - this.getPriority();
} }
@Override @Override

View File

@ -385,8 +385,8 @@ protected void preemptResources(Collection<FSLeafQueue> scheds,
// Sort containers into reverse order of priority // Sort containers into reverse order of priority
Collections.sort(runningContainers, new Comparator<RMContainer>() { Collections.sort(runningContainers, new Comparator<RMContainer>() {
public int compare(RMContainer c1, RMContainer c2) { public int compare(RMContainer c1, RMContainer c2) {
int ret = c2.getContainer().getPriority().compareTo( int ret = c1.getContainer().getPriority().compareTo(
c1.getContainer().getPriority()); c2.getContainer().getPriority());
if (ret == 0) { if (ret == 0) {
return c2.getContainerId().compareTo(c1.getContainerId()); return c2.getContainerId().compareTo(c1.getContainerId());
} }

View File

@ -19,6 +19,7 @@
package org.apache.hadoop.yarn.server.resourcemanager.scheduler; package org.apache.hadoop.yarn.server.resourcemanager.scheduler;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -351,4 +352,10 @@ private void waitForLaunchedState(RMAppAttempt attempt)
RMAppAttemptState.LAUNCHED); RMAppAttemptState.LAUNCHED);
} }
@Test
public void testComparePriorities(){
Priority high = Priority.newInstance(1);
Priority low = Priority.newInstance(2);
assertTrue(high.compareTo(low) > 0);
}
} }