YARN-5729. Bug fixes for the service Rest API. Contributed by Gour Saha

This commit is contained in:
Jian He 2016-10-14 13:47:38 -07:00
parent c0120e51b9
commit 7da243ebe0
10 changed files with 39 additions and 15 deletions

View File

@ -276,7 +276,7 @@ public class ApplicationApiService implements ApplicationApi {
// If it is a simple app with no components, then create a default component
if (application.getComponents() == null) {
application.setComponents(getDefaultComponentAsList());
application.setComponents(getDefaultComponentAsList(application));
}
// Application lifetime if not specified, is set to unlimited lifetime
@ -1029,7 +1029,8 @@ public class ApplicationApiService implements ApplicationApi {
// end-users point of view, is out of scope of the REST API. Also, this
// readiness has nothing to do with readiness-check defined at the component
// level (which is used for dependency resolution of component DAG).
if (totalNumberOfIpAssignedContainers == totalExpectedNumberOfRunningContainers) {
if (totalNumberOfIpAssignedContainers
.longValue() == totalExpectedNumberOfRunningContainers.longValue()) {
app.setState(ApplicationState.READY);
}
logger.info("Application = {}", app);
@ -1389,6 +1390,17 @@ public class ApplicationApiService implements ApplicationApi {
return Response.status(Status.NO_CONTENT).build();
}
// create default component and initialize with app level global values
private List<Component> getDefaultComponentAsList(Application app) {
List<Component> comps = getDefaultComponentAsList();
Component comp = comps.get(0);
comp.setArtifact(app.getArtifact());
comp.setResource(app.getResource());
comp.setNumberOfContainers(app.getNumberOfContainers());
comp.setLaunchCommand(app.getLaunchCommand());
return comps;
}
private List<Component> getDefaultComponentAsList() {
Component comp = new Component();
comp.setName(DEFAULT_COMPONENT_NAME);

View File

@ -168,19 +168,19 @@ public class Application extends BaseResource {
* The time when the application was created, e.g. 2016-03-16T01:01:49.000Z.
**/
public Application launchTime(Date launchTime) {
this.launchTime = launchTime;
this.launchTime = launchTime == null ? null : (Date) launchTime.clone();
return this;
}
@ApiModelProperty(example = "null", value = "The time when the application was created, e.g. 2016-03-16T01:01:49.000Z.")
@JsonProperty("launch_time")
public String getLaunchTime() {
return launchTime.toString();
return launchTime == null ? null : launchTime.toString();
}
@XmlElement(name = "launch_time")
public void setLaunchTime(Date launchTime) {
this.launchTime = launchTime;
this.launchTime = launchTime == null ? null : (Date) launchTime.clone();
}
/**

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.services.resource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonInclude;
@ -33,7 +34,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
@ApiModel(description = "Artifact of an application component")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-02T08:15:05.615-07:00")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Artifact {
public class Artifact implements Serializable {
private static final long serialVersionUID = 3608929500111099035L;
private String id = null;

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.services.resource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -42,7 +43,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-02T08:15:05.615-07:00")
@XmlRootElement
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Component {
public class Component implements Serializable {
private static final long serialVersionUID = -8430058381509087805L;
private String name = null;
private List<String> dependencies = new ArrayList<String>();

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.services.resource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Objects;
import javax.xml.bind.annotation.XmlElement;
@ -38,7 +39,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-02T08:15:05.615-07:00")
@XmlRootElement
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ConfigFile {
public class ConfigFile implements Serializable {
private static final long serialVersionUID = -7009402089417704612L;
public enum TypeEnum {
XML("xml"), PROPERTIES("properties"), JSON("json"), YAML("yaml"), TEMPLATE(

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.services.resource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -39,7 +40,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "Set of configuration properties that can be injected into the application components via envs, files and custom pluggable helper docker containers. Files of several standard formats like xml, properties, json, yaml and templates will be supported.")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-02T08:15:05.615-07:00")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Configuration {
public class Configuration implements Serializable {
private static final long serialVersionUID = -4330788704981074466L;
private Map<String, String> properties = new HashMap<String, String>();
private Map<String, String> env = new HashMap<String, String>();

View File

@ -73,19 +73,19 @@ public class Container extends BaseResource {
* This will most likely be different from cluster launch time.
**/
public Container launchTime(Date launchTime) {
this.launchTime = launchTime;
this.launchTime = launchTime == null ? null : (Date) launchTime.clone();
return this;
}
@ApiModelProperty(example = "null", value = "The time when the container was created, e.g. 2016-03-16T01:01:49.000Z. This will most likely be different from cluster launch time.")
@JsonProperty("launch_time")
public String getLaunchTime() {
return launchTime.toString();
return launchTime == null ? null : launchTime.toString();
}
@XmlElement(name = "launch_time")
public void setLaunchTime(Date launchTime) {
this.launchTime = launchTime;
this.launchTime = launchTime == null ? null : (Date) launchTime.clone();
}
/**

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.services.resource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -31,7 +32,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "Placement policy of an instance of an application. This feature is in the works in YARN-4902.")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-02T08:15:05.615-07:00")
public class PlacementPolicy {
public class PlacementPolicy implements Serializable {
private static final long serialVersionUID = 4341110649551172231L;
private String label = null;

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.services.resource;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -34,7 +35,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
@ApiModel(description = "A custom command or a pluggable helper container to determine the readiness of a container of a component. Readiness for every application is different. Hence the need for a simple interface, with scope to support advanced usecases.")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-02T08:15:05.615-07:00")
public class ReadinessCheck {
public class ReadinessCheck implements Serializable {
private static final long serialVersionUID = -3836839816887186801L;
public enum TypeEnum {
HTTP("http");

View File

@ -35,7 +35,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(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 application. The resource specified at the app (or global) level can be overriden at the component level. Only one of profile OR cpu & memory are exepected. It raises a validation exception otherwise.")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-02T08:15:05.615-07:00")
public class Resource extends BaseResource {
public class Resource extends BaseResource implements Cloneable {
private static final long serialVersionUID = -6431667797380250037L;
private String profile = null;