YARN-7023. Incorrect ReservationId.compareTo() implementation.
This closes #262
Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
(cherry picked from commit c5281a85e1
)
This commit is contained in:
parent
063b6d0c93
commit
305528768c
|
@ -31,7 +31,7 @@ import org.apache.hadoop.yarn.util.Records;
|
||||||
* {@link ReservationId} represents the <em>globally unique</em> identifier for
|
* {@link ReservationId} represents the <em>globally unique</em> identifier for
|
||||||
* a reservation.
|
* a reservation.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* The globally unique nature of the identifier is achieved by using the
|
* The globally unique nature of the identifier is achieved by using the
|
||||||
* <em>cluster timestamp</em> i.e. start-time of the {@code ResourceManager}
|
* <em>cluster timestamp</em> i.e. start-time of the {@code ResourceManager}
|
||||||
|
@ -62,7 +62,7 @@ public abstract class ReservationId implements Comparable<ReservationId> {
|
||||||
* Get the long identifier of the {@link ReservationId} which is unique for
|
* Get the long identifier of the {@link ReservationId} which is unique for
|
||||||
* all Reservations started by a particular instance of the
|
* all Reservations started by a particular instance of the
|
||||||
* {@code ResourceManager}.
|
* {@code ResourceManager}.
|
||||||
*
|
*
|
||||||
* @return long identifier of the {@link ReservationId}
|
* @return long identifier of the {@link ReservationId}
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
|
@ -76,7 +76,7 @@ public abstract class ReservationId implements Comparable<ReservationId> {
|
||||||
/**
|
/**
|
||||||
* Get the <em>start time</em> of the {@code ResourceManager} which is used to
|
* Get the <em>start time</em> of the {@code ResourceManager} which is used to
|
||||||
* generate globally unique {@link ReservationId}.
|
* generate globally unique {@link ReservationId}.
|
||||||
*
|
*
|
||||||
* @return <em>start time</em> of the {@code ResourceManager}
|
* @return <em>start time</em> of the {@code ResourceManager}
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
|
@ -94,10 +94,9 @@ public abstract class ReservationId implements Comparable<ReservationId> {
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(ReservationId other) {
|
public int compareTo(ReservationId other) {
|
||||||
if (this.getClusterTimestamp() - other.getClusterTimestamp() == 0) {
|
if (this.getClusterTimestamp() - other.getClusterTimestamp() == 0) {
|
||||||
return getId() > getId() ? 1 : getId() < getId() ? -1 : 0;
|
return Long.compare(getId(), other.getId());
|
||||||
} else {
|
} else {
|
||||||
return this.getClusterTimestamp() > other.getClusterTimestamp() ? 1
|
return Long.compare(getClusterTimestamp(), other.getClusterTimestamp());
|
||||||
: this.getClusterTimestamp() < other.getClusterTimestamp() ? -1 : 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue