diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/resources/definition/YARN-Simplified-V1-API-Layer-For-Services.yaml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/resources/definition/YARN-Simplified-V1-API-Layer-For-Services.yaml index 088b50cca8b..1be30c51c2e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/resources/definition/YARN-Simplified-V1-API-Layer-For-Services.yaml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/resources/definition/YARN-Simplified-V1-API-Layer-For-Services.yaml @@ -244,6 +244,21 @@ definitions: queue: type: string description: The YARN queue that this service should be submitted to. + ResourceInformation: + description: + ResourceInformation determines unit/name/value of resource types in addition to memory and vcores. It will be part of Resource object + properties: + name: + type: string + description: Name of the resource type, for example yarn.io/gpu . + value: + type: integer + format: int64 + description: Integer value of the resource. + unit: + type: string + description: + Unit of the resource, acceptable values are: p/n/u/m/k/M/G/T/P/Ki/Mi/Gi/Ti/Pi. By default it is empty means no unit Resource: description: Resource determines the amount of resources (vcores, memory, network, etc.) usable by a container. This field determines the resource to be applied for all the containers of a component or service. The resource specified at the service (or global) level can be overriden at the component level. Only one of profile OR cpu & memory are expected. It raises a validation exception otherwise. @@ -258,6 +273,11 @@ definitions: memory: type: string description: Amount of memory allocated to each container (optional but overrides memory in profile if specified). Currently accepts only an integer value and default unit is in MB. + resourceInformations: + type: object + additionalProperties: + $ref: '#/definitions/ResourceInformation' + description: Map of resource name to ResourceInformation PlacementPolicy: description: Placement policy of an instance of a service. This feature is in the works in YARN-6592. properties: diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/Resource.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/Resource.java index dfdf92a01c5..0c1158d38c7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/Resource.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/Resource.java @@ -17,9 +17,11 @@ package org.apache.hadoop.yarn.service.api.records; +import com.google.gson.annotations.SerializedName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.util.Map; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -46,6 +48,9 @@ private Integer cpus = 1; private String memory = null; + @SerializedName("resourceInformations") + private Map resourceInformations = null; + /** * Each resource profile has a unique id which is associated with a * cluster-level predefined memory, cpus, etc. @@ -112,6 +117,22 @@ public long getMemoryMB() { return Long.parseLong(memory); } + public Resource setResourceInformations( + Map resourceInformations) { + this.resourceInformations = resourceInformations; + return this; + } + + /** + * Map of resource name to ResourceInformation + * @return resourceInformations + **/ + @ApiModelProperty(value = "Map of resource name to ResourceInformation") + @JsonProperty("resourceInformations") + public Map getResourceInformations() { + return resourceInformations; + } + @Override public boolean equals(java.lang.Object o) { if (this == o) { @@ -123,12 +144,14 @@ public boolean equals(java.lang.Object o) { Resource resource = (Resource) o; return Objects.equals(this.profile, resource.profile) && Objects.equals(this.cpus, resource.cpus) - && Objects.equals(this.memory, resource.memory); + && Objects.equals(this.memory, resource.memory) + && Objects.equals( + this.resourceInformations, resource.resourceInformations); } @Override public int hashCode() { - return Objects.hash(profile, cpus, memory); + return Objects.hash(profile, cpus, memory, resourceInformations); } @Override @@ -139,6 +162,8 @@ public String toString() { sb.append(" profile: ").append(toIndentedString(profile)).append("\n"); sb.append(" cpus: ").append(toIndentedString(cpus)).append("\n"); sb.append(" memory: ").append(toIndentedString(memory)).append("\n"); + sb.append(" resourceInformations: ").append( + toIndentedString(resourceInformations)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/ResourceInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/ResourceInformation.java new file mode 100644 index 00000000000..6fbce0b4ce8 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/src/main/java/org/apache/hadoop/yarn/service/api/records/ResourceInformation.java @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.service.api.records; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Objects; + +/** + * ResourceInformation determines unit/name/value of resource types in addition to memory and vcores. It will be part of Resource object + */ +@ApiModel(description = "ResourceInformation determines unit/name/value of resource types in addition to memory and vcores. It will be part of Resource object") +@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", + date = "2017-11-22T15:15:49.495-08:00") +public class ResourceInformation { + @SerializedName("name") + private String name = null; + + @SerializedName("value") + private Long value = null; + + @SerializedName("unit") + private String unit = null; + + public ResourceInformation name(String name) { + this.name = name; + return this; + } + + /** + * Name of the resource type, for example yarn.io/gpu . + * + * @return name + **/ + @ApiModelProperty(value = "Name of the resource type, for example yarn.io/gpu .") + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ResourceInformation value(Long value) { + this.value = value; + return this; + } + + /** + * Integer value of the resource. + * + * @return value + **/ + @ApiModelProperty(value = "Integer value of the resource.") + @JsonProperty("value") + public Long getValue() { + return value; + } + + public void setValue(Long value) { + this.value = value; + } + + public ResourceInformation unit(String unit) { + this.unit = unit; + return this; + } + + /** + * @return unit + **/ + @ApiModelProperty(value = "") + @JsonProperty("unit") + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ResourceInformation resourceInformation = (ResourceInformation) o; + return Objects.equals(this.name, resourceInformation.name) && Objects + .equals(this.value, resourceInformation.value) && Objects.equals( + this.unit, resourceInformation.unit); + } + + @Override + public int hashCode() { + return Objects.hash(name, value, unit); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ResourceInformation {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" unit: ").append(toIndentedString(unit)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} +