From 867a4b7d78f81dde6f18e10e910f28ad96be037f Mon Sep 17 00:00:00 2001
From: Oleg Danilov
Date: Wed, 16 Aug 2017 15:19:26 +0300
Subject: [PATCH] YARN-7023. Incorrect ReservationId.compareTo()
implementation.
This closes #262
Signed-off-by: Akira Ajisaka
(cherry picked from commit c5281a85e108c7cab6e84dfe351843483d720b9b)
(cherry picked from commit b616462eef5ee06a0d7f7d5f78b34a8069b80507)
---
.../apache/hadoop/yarn/api/records/ReservationId.java | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ReservationId.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ReservationId.java
index a0c209d5707..fd0111538a4 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ReservationId.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ReservationId.java
@@ -31,7 +31,7 @@ import org.apache.hadoop.yarn.util.Records;
* {@link ReservationId} represents the globally unique identifier for
* a reservation.
*
- *
+ *
*
* The globally unique nature of the identifier is achieved by using the
* cluster timestamp i.e. start-time of the {@code ResourceManager}
@@ -62,7 +62,7 @@ public abstract class ReservationId implements Comparable {
* Get the long identifier of the {@link ReservationId} which is unique for
* all Reservations started by a particular instance of the
* {@code ResourceManager}.
- *
+ *
* @return long identifier of the {@link ReservationId}
*/
@Public
@@ -76,7 +76,7 @@ public abstract class ReservationId implements Comparable {
/**
* Get the start time of the {@code ResourceManager} which is used to
* generate globally unique {@link ReservationId}.
- *
+ *
* @return start time of the {@code ResourceManager}
*/
@Public
@@ -94,10 +94,9 @@ public abstract class ReservationId implements Comparable {
@Override
public int compareTo(ReservationId other) {
if (this.getClusterTimestamp() - other.getClusterTimestamp() == 0) {
- return getId() > getId() ? 1 : getId() < getId() ? -1 : 0;
+ return Long.compare(getId(), other.getId());
} else {
- return this.getClusterTimestamp() > other.getClusterTimestamp() ? 1
- : this.getClusterTimestamp() < other.getClusterTimestamp() ? -1 : 0;
+ return Long.compare(getClusterTimestamp(), other.getClusterTimestamp());
}
}