YARN-5384. Expose priority in ReservationSystem submission APIs. (Sean Po via Subru).
This commit is contained in:
parent
89bd6d29a6
commit
3a3697deab
|
@ -19,7 +19,6 @@
|
||||||
package org.apache.hadoop.yarn.api.records;
|
package org.apache.hadoop.yarn.api.records;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience.Public;
|
import org.apache.hadoop.classification.InterfaceAudience.Public;
|
||||||
import org.apache.hadoop.classification.InterfaceStability.Evolving;
|
|
||||||
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
||||||
import org.apache.hadoop.yarn.util.Records;
|
import org.apache.hadoop.yarn.util.Records;
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ public abstract class ReservationDefinition {
|
||||||
@Unstable
|
@Unstable
|
||||||
public static ReservationDefinition newInstance(long arrival, long deadline,
|
public static ReservationDefinition newInstance(long arrival, long deadline,
|
||||||
ReservationRequests reservationRequests, String name,
|
ReservationRequests reservationRequests, String name,
|
||||||
String recurrenceExpression) {
|
String recurrenceExpression, Priority priority) {
|
||||||
ReservationDefinition rDefinition =
|
ReservationDefinition rDefinition =
|
||||||
Records.newRecord(ReservationDefinition.class);
|
Records.newRecord(ReservationDefinition.class);
|
||||||
rDefinition.setArrival(arrival);
|
rDefinition.setArrival(arrival);
|
||||||
|
@ -46,6 +45,7 @@ public abstract class ReservationDefinition {
|
||||||
rDefinition.setReservationRequests(reservationRequests);
|
rDefinition.setReservationRequests(reservationRequests);
|
||||||
rDefinition.setReservationName(name);
|
rDefinition.setReservationName(name);
|
||||||
rDefinition.setRecurrenceExpression(recurrenceExpression);
|
rDefinition.setRecurrenceExpression(recurrenceExpression);
|
||||||
|
rDefinition.setPriority(priority);
|
||||||
return rDefinition;
|
return rDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ public abstract class ReservationDefinition {
|
||||||
@Unstable
|
@Unstable
|
||||||
public static ReservationDefinition newInstance(long arrival, long deadline,
|
public static ReservationDefinition newInstance(long arrival, long deadline,
|
||||||
ReservationRequests reservationRequests, String name) {
|
ReservationRequests reservationRequests, String name) {
|
||||||
ReservationDefinition rDefinition =
|
ReservationDefinition rDefinition = newInstance(arrival, deadline,
|
||||||
newInstance(arrival, deadline, reservationRequests, name, "0");
|
reservationRequests, name, "0", Priority.UNDEFINED);
|
||||||
return rDefinition;
|
return rDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ public abstract class ReservationDefinition {
|
||||||
* allocation in the scheduler
|
* allocation in the scheduler
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
@Evolving
|
@Unstable
|
||||||
public abstract String getReservationName();
|
public abstract String getReservationName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +142,7 @@ public abstract class ReservationDefinition {
|
||||||
* allocation in the scheduler
|
* allocation in the scheduler
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
@Evolving
|
@Unstable
|
||||||
public abstract void setReservationName(String name);
|
public abstract void setReservationName(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,7 +160,7 @@ public abstract class ReservationDefinition {
|
||||||
* @return recurrence of this reservation
|
* @return recurrence of this reservation
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
@Evolving
|
@Unstable
|
||||||
public abstract String getRecurrenceExpression();
|
public abstract String getRecurrenceExpression();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,7 +178,35 @@ public abstract class ReservationDefinition {
|
||||||
* @param recurrenceExpression recurrence interval of this reservation
|
* @param recurrenceExpression recurrence interval of this reservation
|
||||||
*/
|
*/
|
||||||
@Public
|
@Public
|
||||||
@Evolving
|
@Unstable
|
||||||
public abstract void setRecurrenceExpression(String recurrenceExpression);
|
public abstract void setRecurrenceExpression(String recurrenceExpression);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the priority for this reservation. A lower number for priority
|
||||||
|
* indicates a higher priority reservation. Recurring reservations are
|
||||||
|
* always higher priority than non-recurring reservations. Priority for
|
||||||
|
* non-recurring reservations are only compared with non-recurring
|
||||||
|
* reservations. Likewise for recurring reservations.
|
||||||
|
*
|
||||||
|
* @return int representing the priority of the reserved resource
|
||||||
|
* allocation in the scheduler
|
||||||
|
*/
|
||||||
|
@Public
|
||||||
|
@Unstable
|
||||||
|
public abstract Priority getPriority();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the priority for this reservation. A lower number for priority
|
||||||
|
* indicates a higher priority reservation. Recurring reservations are
|
||||||
|
* always higher priority than non-recurring reservations. Priority for
|
||||||
|
* non-recurring reservations are only compared with non-recurring
|
||||||
|
* reservations. Likewise for recurring reservations.
|
||||||
|
*
|
||||||
|
* @param priority representing the priority of the reserved resource
|
||||||
|
* allocation in the scheduler
|
||||||
|
*/
|
||||||
|
@Public
|
||||||
|
@Unstable
|
||||||
|
public abstract void setPriority(Priority priority);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,6 +489,7 @@ message ReservationDefinitionProto {
|
||||||
optional int64 deadline = 3;
|
optional int64 deadline = 3;
|
||||||
optional string reservation_name = 4;
|
optional string reservation_name = 4;
|
||||||
optional string recurrence_expression = 5 [default = "0"];
|
optional string recurrence_expression = 5 [default = "0"];
|
||||||
|
optional PriorityProto priority = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ResourceAllocationRequestProto {
|
message ResourceAllocationRequestProto {
|
||||||
|
|
|
@ -18,8 +18,10 @@
|
||||||
|
|
||||||
package org.apache.hadoop.yarn.api.records.impl.pb;
|
package org.apache.hadoop.yarn.api.records.impl.pb;
|
||||||
|
|
||||||
|
import org.apache.hadoop.yarn.api.records.Priority;
|
||||||
import org.apache.hadoop.yarn.api.records.ReservationDefinition;
|
import org.apache.hadoop.yarn.api.records.ReservationDefinition;
|
||||||
import org.apache.hadoop.yarn.api.records.ReservationRequests;
|
import org.apache.hadoop.yarn.api.records.ReservationRequests;
|
||||||
|
import org.apache.hadoop.yarn.proto.YarnProtos;
|
||||||
import org.apache.hadoop.yarn.proto.YarnProtos.ReservationDefinitionProto;
|
import org.apache.hadoop.yarn.proto.YarnProtos.ReservationDefinitionProto;
|
||||||
import org.apache.hadoop.yarn.proto.YarnProtos.ReservationDefinitionProtoOrBuilder;
|
import org.apache.hadoop.yarn.proto.YarnProtos.ReservationDefinitionProtoOrBuilder;
|
||||||
import org.apache.hadoop.yarn.proto.YarnProtos.ReservationRequestsProto;
|
import org.apache.hadoop.yarn.proto.YarnProtos.ReservationRequestsProto;
|
||||||
|
@ -32,6 +34,7 @@ public class ReservationDefinitionPBImpl extends ReservationDefinition {
|
||||||
boolean viaProto = false;
|
boolean viaProto = false;
|
||||||
|
|
||||||
private ReservationRequests reservationReqs;
|
private ReservationRequests reservationReqs;
|
||||||
|
private Priority priority = null;
|
||||||
|
|
||||||
public ReservationDefinitionPBImpl() {
|
public ReservationDefinitionPBImpl() {
|
||||||
builder = ReservationDefinitionProto.newBuilder();
|
builder = ReservationDefinitionProto.newBuilder();
|
||||||
|
@ -150,6 +153,33 @@ public class ReservationDefinitionPBImpl extends ReservationDefinition {
|
||||||
builder.setReservationName(name);
|
builder.setReservationName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Priority getPriority() {
|
||||||
|
ReservationDefinitionProtoOrBuilder p = viaProto ? proto : builder;
|
||||||
|
if (this.priority != null) {
|
||||||
|
return this.priority;
|
||||||
|
}
|
||||||
|
if (!p.hasPriority()) {
|
||||||
|
return Priority.UNDEFINED;
|
||||||
|
}
|
||||||
|
this.priority = convertFromProtoFormat(p.getPriority());
|
||||||
|
return this.priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPriority(Priority priority) {
|
||||||
|
maybeInitBuilder();
|
||||||
|
if (priority == null) {
|
||||||
|
this.priority = Priority.UNDEFINED;
|
||||||
|
}
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PriorityPBImpl convertFromProtoFormat(
|
||||||
|
YarnProtos.PriorityProto p) {
|
||||||
|
return new PriorityPBImpl(p);
|
||||||
|
}
|
||||||
|
|
||||||
private ReservationRequestsPBImpl convertFromProtoFormat(
|
private ReservationRequestsPBImpl convertFromProtoFormat(
|
||||||
ReservationRequestsProto p) {
|
ReservationRequestsProto p) {
|
||||||
return new ReservationRequestsPBImpl(p);
|
return new ReservationRequestsPBImpl(p);
|
||||||
|
@ -164,6 +194,7 @@ public class ReservationDefinitionPBImpl extends ReservationDefinition {
|
||||||
return "{Arrival: " + getArrival() + ", Deadline: " + getDeadline()
|
return "{Arrival: " + getArrival() + ", Deadline: " + getDeadline()
|
||||||
+ ", Reservation Name: " + getReservationName()
|
+ ", Reservation Name: " + getReservationName()
|
||||||
+ ", Recurrence expression: " + getRecurrenceExpression()
|
+ ", Recurrence expression: " + getRecurrenceExpression()
|
||||||
|
+ ", Priority: " + getPriority().toString()
|
||||||
+ ", Resources: " + getReservationRequests() + "}";
|
+ ", Resources: " + getReservationRequests() + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,9 @@ public class ReservationDefinitionInfo {
|
||||||
@XmlElement(name = "reservation-name")
|
@XmlElement(name = "reservation-name")
|
||||||
private String reservationName;
|
private String reservationName;
|
||||||
|
|
||||||
|
@XmlElement(name = "priority")
|
||||||
|
private int priority;
|
||||||
|
|
||||||
public ReservationDefinitionInfo() {
|
public ReservationDefinitionInfo() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -89,4 +92,12 @@ public class ReservationDefinitionInfo {
|
||||||
this.reservationName = reservationName;
|
this.reservationName = reservationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPriority(int priority) {
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import java.util.TreeMap;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest;
|
import org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest;
|
||||||
|
import org.apache.hadoop.yarn.api.records.Priority;
|
||||||
import org.apache.hadoop.yarn.api.records.ReservationDefinition;
|
import org.apache.hadoop.yarn.api.records.ReservationDefinition;
|
||||||
import org.apache.hadoop.yarn.api.records.ReservationId;
|
import org.apache.hadoop.yarn.api.records.ReservationId;
|
||||||
import org.apache.hadoop.yarn.api.records.ReservationRequest;
|
import org.apache.hadoop.yarn.api.records.ReservationRequest;
|
||||||
|
@ -199,6 +200,13 @@ public class ReservationSystemTestUtil {
|
||||||
public static ReservationSubmissionRequest createSimpleReservationRequest(
|
public static ReservationSubmissionRequest createSimpleReservationRequest(
|
||||||
ReservationId reservationId, int numContainers, long arrival,
|
ReservationId reservationId, int numContainers, long arrival,
|
||||||
long deadline, long duration) {
|
long deadline, long duration) {
|
||||||
|
return createSimpleReservationRequest(reservationId, numContainers,
|
||||||
|
arrival, deadline, duration, Priority.UNDEFINED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ReservationSubmissionRequest createSimpleReservationRequest(
|
||||||
|
ReservationId reservationId, int numContainers, long arrival,
|
||||||
|
long deadline, long duration, Priority priority) {
|
||||||
// create a request with a single atomic ask
|
// create a request with a single atomic ask
|
||||||
ReservationRequest r =
|
ReservationRequest r =
|
||||||
ReservationRequest.newInstance(Resource.newInstance(1024, 1),
|
ReservationRequest.newInstance(Resource.newInstance(1024, 1),
|
||||||
|
@ -208,7 +216,7 @@ public class ReservationSystemTestUtil {
|
||||||
ReservationRequestInterpreter.R_ALL);
|
ReservationRequestInterpreter.R_ALL);
|
||||||
ReservationDefinition rDef =
|
ReservationDefinition rDef =
|
||||||
ReservationDefinition.newInstance(arrival, deadline, reqs,
|
ReservationDefinition.newInstance(arrival, deadline, reqs,
|
||||||
"testClientRMService#reservation");
|
"testClientRMService#reservation", "0", priority);
|
||||||
ReservationSubmissionRequest request =
|
ReservationSubmissionRequest request =
|
||||||
ReservationSubmissionRequest.newInstance(rDef,
|
ReservationSubmissionRequest.newInstance(rDef,
|
||||||
reservationQ, reservationId);
|
reservationQ, reservationId);
|
||||||
|
|
|
@ -3237,6 +3237,7 @@ The Cluster Reservation API can be used to list reservations. When listing reser
|
||||||
| deadline | long | The UTC time representation of the latest time within which this reservation can be allocated. |
|
| deadline | long | The UTC time representation of the latest time within which this reservation can be allocated. |
|
||||||
| reservation-name | string | A mnemonic name of the reservation (not a valid identifier). |
|
| reservation-name | string | A mnemonic name of the reservation (not a valid identifier). |
|
||||||
| reservation-requests | object | A list of "stages" or phases of this reservation, each describing resource requirements and duration |
|
| reservation-requests | object | A list of "stages" or phases of this reservation, each describing resource requirements and duration |
|
||||||
|
| priority | int | An integer representing the priority of the reservation. A lower number for priority indicates a higher priority reservation. Recurring reservations are always higher priority than non-recurring reservations. Priority for non-recurring reservations are only compared with non-recurring reservations. Likewise with recurring reservations. |
|
||||||
|
|
||||||
### Elements of the *reservation-requests* object
|
### Elements of the *reservation-requests* object
|
||||||
|
|
||||||
|
@ -3500,6 +3501,7 @@ Elements of the *reservation-definition* object
|
||||||
| deadline | long | The UTC time representation of the latest time within which this reservation can be allocated. |
|
| deadline | long | The UTC time representation of the latest time within which this reservation can be allocated. |
|
||||||
| reservation-name | string | A mnemonic name of the reservation (not a valid identifier). |
|
| reservation-name | string | A mnemonic name of the reservation (not a valid identifier). |
|
||||||
| reservation-requests | object | A list of "stages" or phases of this reservation, each describing resource requirements and duration |
|
| reservation-requests | object | A list of "stages" or phases of this reservation, each describing resource requirements and duration |
|
||||||
|
| priority | int | An integer representing the priority of the reservation. A lower number for priority indicates a higher priority reservation. Recurring reservations are always higher priority than non-recurring reservations. Priority for non-recurring reservations are only compared with non-recurring reservations. Likewise with recurring reservations. |
|
||||||
|
|
||||||
Elements of the *reservation-requests* object
|
Elements of the *reservation-requests* object
|
||||||
|
|
||||||
|
@ -3675,6 +3677,7 @@ Elements of the *reservation-definition* object
|
||||||
| deadline | long | The UTC time representation of the latest time within which this reservation can be allocated. |
|
| deadline | long | The UTC time representation of the latest time within which this reservation can be allocated. |
|
||||||
| reservation-name | string | A mnemonic name of the reservation (not a valid identifier). |
|
| reservation-name | string | A mnemonic name of the reservation (not a valid identifier). |
|
||||||
| reservation-requests | object | A list of "stages" or phases of this reservation, each describing resource requirements and duration |
|
| reservation-requests | object | A list of "stages" or phases of this reservation, each describing resource requirements and duration |
|
||||||
|
| priority | int | An integer representing the priority of the reservation. A lower number for priority indicates a higher priority reservation. Recurring reservations are always higher priority than non-recurring reservations. Priority for non-recurring reservations are only compared with non-recurring reservations. Likewise with recurring reservations. |
|
||||||
|
|
||||||
Elements of the *reservation-requests* object
|
Elements of the *reservation-requests* object
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue