001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package org.apache.hadoop.yarn.api.records;
020
021 import org.apache.hadoop.classification.InterfaceAudience.Public;
022 import org.apache.hadoop.classification.InterfaceStability.Evolving;
023 import org.apache.hadoop.classification.InterfaceStability.Unstable;
024 import org.apache.hadoop.yarn.util.Records;
025
026 /**
027 * {@link ReservationDefinition} captures the set of resource and time
028 * constraints the user cares about regarding a reservation.
029 *
030 * @see ResourceRequest
031 *
032 */
033 @Public
034 @Unstable
035 public abstract class ReservationDefinition {
036
037 @Public
038 @Unstable
039 public static ReservationDefinition newInstance(long arrival, long deadline,
040 ReservationRequests reservationRequests, String name) {
041 ReservationDefinition rDefinition =
042 Records.newRecord(ReservationDefinition.class);
043 rDefinition.setArrival(arrival);
044 rDefinition.setDeadline(deadline);
045 rDefinition.setReservationRequests(reservationRequests);
046 rDefinition.setReservationName(name);
047 return rDefinition;
048 }
049
050 /**
051 * Get the arrival time or the earliest time from which the resource(s) can be
052 * allocated. Time expressed as UTC.
053 *
054 * @return the earliest valid time for this reservation
055 */
056 @Public
057 @Unstable
058 public abstract long getArrival();
059
060 /**
061 * Set the arrival time or the earliest time from which the resource(s) can be
062 * allocated. Time expressed as UTC.
063 *
064 * @param earliestStartTime the earliest valid time for this reservation
065 */
066 @Public
067 @Unstable
068 public abstract void setArrival(long earliestStartTime);
069
070 /**
071 * Get the deadline or the latest time by when the resource(s) must be
072 * allocated. Time expressed as UTC.
073 *
074 * @return the deadline or the latest time by when the resource(s) must be
075 * allocated
076 */
077 @Public
078 @Unstable
079 public abstract long getDeadline();
080
081 /**
082 * Set the deadline or the latest time by when the resource(s) must be
083 * allocated. Time expressed as UTC.
084 *
085 * @param latestEndTime the deadline or the latest time by when the
086 * resource(s) should be allocated
087 */
088 @Public
089 @Unstable
090 public abstract void setDeadline(long latestEndTime);
091
092 /**
093 * Get the list of {@link ReservationRequests} representing the resources
094 * required by the application
095 *
096 * @return the list of {@link ReservationRequests}
097 */
098 @Public
099 @Unstable
100 public abstract ReservationRequests getReservationRequests();
101
102 /**
103 * Set the list of {@link ReservationRequests} representing the resources
104 * required by the application
105 *
106 * @param reservationRequests the list of {@link ReservationRequests}
107 */
108 @Public
109 @Unstable
110 public abstract void setReservationRequests(
111 ReservationRequests reservationRequests);
112
113 /**
114 * Get the name for this reservation. The name need-not be unique, and it is
115 * just a mnemonic for the user (akin to job names). Accepted reservations are
116 * uniquely identified by a system-generated ReservationId.
117 *
118 * @return string representing the name of the corresponding reserved resource
119 * allocation in the scheduler
120 */
121 @Public
122 @Evolving
123 public abstract String getReservationName();
124
125 /**
126 * Set the name for this reservation. The name need-not be unique, and it is
127 * just a mnemonic for the user (akin to job names). Accepted reservations are
128 * uniquely identified by a system-generated ReservationId.
129 *
130 * @param name representing the name of the corresponding reserved resource
131 * allocation in the scheduler
132 */
133 @Public
134 @Evolving
135 public abstract void setReservationName(String name);
136
137 }