http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Configuration.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Configuration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Configuration.java deleted file mode 100644 index e89306c..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Configuration.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * 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.slider.api.resource; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang.StringUtils; -import org.apache.slider.common.tools.SliderUtils; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** - * 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. - **/ - -@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 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>(); - private List<ConfigFile> files = new ArrayList<ConfigFile>(); - - /** - * A blob of key-value pairs of common application properties. - **/ - public Configuration properties(Map<String, String> properties) { - this.properties = properties; - return this; - } - - @ApiModelProperty(example = "null", value = "A blob of key-value pairs of common application properties.") - @JsonProperty("properties") - public Map<String, String> getProperties() { - return properties; - } - - public void setProperties(Map<String, String> properties) { - this.properties = properties; - } - - /** - * A blob of key-value pairs which will be appended to the default system - * properties and handed off to the application at start time. All placeholder - * references to properties will be substituted before injection. - **/ - public Configuration env(Map<String, String> env) { - this.env = env; - return this; - } - - @ApiModelProperty(example = "null", value = "A blob of key-value pairs which will be appended to the default system properties and handed off to the application at start time. All placeholder references to properties will be substituted before injection.") - @JsonProperty("env") - public Map<String, String> getEnv() { - return env; - } - - public void setEnv(Map<String, String> env) { - this.env = env; - } - - /** - * Array of list of files that needs to be created and made available as - * volumes in the application component containers. - **/ - public Configuration files(List<ConfigFile> files) { - this.files = files; - return this; - } - - @ApiModelProperty(example = "null", value = "Array of list of files that needs to be created and made available as volumes in the application component containers.") - @JsonProperty("files") - public List<ConfigFile> getFiles() { - return files; - } - - public void setFiles(List<ConfigFile> files) { - this.files = files; - } - - public long getPropertyLong(String name, long defaultValue) { - String value = getProperty(name); - if (StringUtils.isEmpty(value)) { - return defaultValue; - } - return Long.parseLong(value); - } - - public int getPropertyInt(String name, int defaultValue) { - String value = getProperty(name); - if (StringUtils.isEmpty(value)) { - return defaultValue; - } - return Integer.parseInt(value); - } - - public boolean getPropertyBool(String name, boolean defaultValue) { - String value = getProperty(name); - if (StringUtils.isEmpty(value)) { - return defaultValue; - } - return Boolean.parseBoolean(value); - } - - public String getProperty(String name, String defaultValue) { - String value = getProperty(name); - if (StringUtils.isEmpty(value)) { - return defaultValue; - } - return value; - } - - public void setProperty(String name, String value) { - properties.put(name, value); - } - - public String getProperty(String name) { - return properties.get(name.trim()); - } - - public String getEnv(String name) { - return env.get(name.trim()); - } - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Configuration configuration = (Configuration) o; - return Objects.equals(this.properties, configuration.properties) - && Objects.equals(this.env, configuration.env) - && Objects.equals(this.files, configuration.files); - } - - @Override - public int hashCode() { - return Objects.hash(properties, env, files); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Configuration {\n"); - - sb.append(" properties: ").append(toIndentedString(properties)) - .append("\n"); - sb.append(" env: ").append(toIndentedString(env)).append("\n"); - sb.append(" files: ").append(toIndentedString(files)).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 "); - } - - /** - * Merge all properties and envs from that configuration to this configration. - * For ConfigFiles, all properties and envs of that ConfigFile are merged into - * this ConfigFile. - */ - public synchronized void mergeFrom(Configuration that) { - SliderUtils.mergeMapsIgnoreDuplicateKeys(this.properties, that - .getProperties()); - SliderUtils.mergeMapsIgnoreDuplicateKeys(this.env, that.getEnv()); - - Map<String, ConfigFile> thatMap = new HashMap<>(); - for (ConfigFile file : that.getFiles()) { - thatMap.put(file.getDestFile(), file.copy()); - } - for (ConfigFile thisFile : files) { - if(thatMap.containsKey(thisFile.getDestFile())) { - ConfigFile thatFile = thatMap.get(thisFile.getDestFile()); - SliderUtils.mergeMapsIgnoreDuplicateKeys(thisFile.getProps(), - thatFile.getProps()); - thatMap.remove(thisFile.getDestFile()); - } - } - // add remaining new files from that Configration - for (ConfigFile thatFile : thatMap.values()) { - files.add(thatFile.copy()); - } - } -}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Container.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Container.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Container.java deleted file mode 100644 index c5dc627..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Container.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * 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.slider.api.resource; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.util.Date; -import java.util.Objects; - -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * An instance of a running application container. - **/ - -@ApiModel(description = "An instance of a running application container") -@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 Container extends BaseResource { - private static final long serialVersionUID = -8955788064529288L; - - private String id = null; - private Date launchTime = null; - private String ip = null; - private String hostname = null; - private String bareHost = null; - private ContainerState state = null; - private String componentName = null; - private Resource resource = null; - private Artifact artifact = null; - private Boolean privilegedContainer = null; - - /** - * Unique container id of a running application, e.g. - * container_e3751_1458061340047_0008_01_000002. - **/ - public Container id(String id) { - this.id = id; - return this; - } - - @ApiModelProperty(example = "null", value = "Unique container id of a running application, e.g. container_e3751_1458061340047_0008_01_000002.") - @JsonProperty("id") - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - /** - * 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. - **/ - public Container launchTime(Date 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 Date getLaunchTime() { - return launchTime == null ? null : (Date) launchTime.clone(); - } - - @XmlElement(name = "launch_time") - public void setLaunchTime(Date launchTime) { - this.launchTime = launchTime == null ? null : (Date) launchTime.clone(); - } - - /** - * IP address of a running container, e.g. 172.31.42.141. The IP address and - * hostname attribute values are dependent on the cluster/docker network setup - * as per YARN-4007. - **/ - public Container ip(String ip) { - this.ip = ip; - return this; - } - - @ApiModelProperty(example = "null", value = "IP address of a running container, e.g. 172.31.42.141. The IP address and hostname attribute values are dependent on the cluster/docker network setup as per YARN-4007.") - @JsonProperty("ip") - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - /** - * Fully qualified hostname of a running container, e.g. - * ctr-e3751-1458061340047-0008-01-000002.examplestg.site. The IP address and - * hostname attribute values are dependent on the cluster/docker network setup - * as per YARN-4007. - **/ - public Container hostname(String hostname) { - this.hostname = hostname; - return this; - } - - @ApiModelProperty(example = "null", value = "Fully qualified hostname of a running container, e.g. ctr-e3751-1458061340047-0008-01-000002.examplestg.site. The IP address and hostname attribute values are dependent on the cluster/docker network setup as per YARN-4007.") - @JsonProperty("hostname") - public String getHostname() { - return hostname; - } - - public void setHostname(String hostname) { - this.hostname = hostname; - } - - /** - * The bare node or host in which the container is running, e.g. - * cn008.example.com. - **/ - public Container bareHost(String bareHost) { - this.bareHost = bareHost; - return this; - } - - @ApiModelProperty(example = "null", value = "The bare node or host in which the container is running, e.g. cn008.example.com.") - @JsonProperty("bare_host") - public String getBareHost() { - return bareHost; - } - - @XmlElement(name = "bare_host") - public void setBareHost(String bareHost) { - this.bareHost = bareHost; - } - - /** - * State of the container of an application. - **/ - public Container state(ContainerState state) { - this.state = state; - return this; - } - - @ApiModelProperty(example = "null", value = "State of the container of an application.") - @JsonProperty("state") - public ContainerState getState() { - return state; - } - - public void setState(ContainerState state) { - this.state = state; - } - - /** - * Name of the component that this container instance belongs to. - **/ - public Container componentName(String componentName) { - this.componentName = componentName; - return this; - } - - @ApiModelProperty(example = "null", value = "Name of the component that this container instance belongs to.") - @JsonProperty("component_name") - public String getComponentName() { - return componentName; - } - - @XmlElement(name = "component_name") - public void setComponentName(String componentName) { - this.componentName = componentName; - } - - /** - * Resource used for this container. - **/ - public Container resource(Resource resource) { - this.resource = resource; - return this; - } - - @ApiModelProperty(example = "null", value = "Resource used for this container.") - @JsonProperty("resource") - public Resource getResource() { - return resource; - } - - public void setResource(Resource resource) { - this.resource = resource; - } - - /** - * Artifact used for this container. - **/ - public Container artifact(Artifact artifact) { - this.artifact = artifact; - return this; - } - - @ApiModelProperty(example = "null", value = "Artifact used for this container.") - @JsonProperty("artifact") - public Artifact getArtifact() { - return artifact; - } - - public void setArtifact(Artifact artifact) { - this.artifact = artifact; - } - - /** - * Container running in privileged mode or not. - **/ - public Container privilegedContainer(Boolean privilegedContainer) { - this.privilegedContainer = privilegedContainer; - return this; - } - - @ApiModelProperty(example = "null", value = "Container running in privileged mode or not.") - @JsonProperty("privileged_container") - public Boolean getPrivilegedContainer() { - return privilegedContainer; - } - - public void setPrivilegedContainer(Boolean privilegedContainer) { - this.privilegedContainer = privilegedContainer; - } - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Container container = (Container) o; - return Objects.equals(this.id, container.id); - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Container {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" launchTime: ").append(toIndentedString(launchTime)) - .append("\n"); - sb.append(" ip: ").append(toIndentedString(ip)).append("\n"); - sb.append(" hostname: ").append(toIndentedString(hostname)).append("\n"); - sb.append(" bareHost: ").append(toIndentedString(bareHost)).append("\n"); - sb.append(" state: ").append(toIndentedString(state)).append("\n"); - sb.append(" componentName: ").append(toIndentedString(componentName)) - .append("\n"); - sb.append(" resource: ").append(toIndentedString(resource)).append("\n"); - sb.append(" artifact: ").append(toIndentedString(artifact)).append("\n"); - sb.append(" privilegedContainer: ") - .append(toIndentedString(privilegedContainer)).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 "); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/ContainerState.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/ContainerState.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/ContainerState.java deleted file mode 100644 index cd1ef4a..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/ContainerState.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.slider.api.resource; - -/** - * The current state of the container of an application. - **/ -public enum ContainerState { - RUNNING_BUT_UNREADY, READY, STOPPED -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Error.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Error.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Error.java deleted file mode 100644 index 3cf9b29..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Error.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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.slider.api.resource; - -import io.swagger.annotations.ApiModelProperty; - -import java.util.Objects; - -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") -public class Error { - - private Integer code = null; - private String message = null; - private String fields = null; - - /** - **/ - public Error code(Integer code) { - this.code = code; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("code") - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - - /** - **/ - public Error message(String message) { - this.message = message; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("message") - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - /** - **/ - public Error fields(String fields) { - this.fields = fields; - return this; - } - - @ApiModelProperty(example = "null", value = "") - @JsonProperty("fields") - public String getFields() { - return fields; - } - - public void setFields(String fields) { - this.fields = fields; - } - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Error error = (Error) o; - return Objects.equals(this.code, error.code) - && Objects.equals(this.message, error.message) - && Objects.equals(this.fields, error.fields); - } - - @Override - public int hashCode() { - return Objects.hash(code, message, fields); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Error {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append(" fields: ").append(toIndentedString(fields)).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 "); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/PlacementPolicy.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/PlacementPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/PlacementPolicy.java deleted file mode 100644 index 306338f..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/PlacementPolicy.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.slider.api.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; - -/** - * Placement policy of an instance of an application. This feature is in the - * works in YARN-4902. - **/ - -@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 implements Serializable { - private static final long serialVersionUID = 4341110649551172231L; - - private String label = null; - - /** - * Assigns an app to a named partition of the cluster where the application - * desires to run (optional). If not specified all apps are submitted to a - * default label of the app owner. One or more labels can be setup for each - * application owner account with required constraints like no-preemption, - * sla-99999, preemption-ok, etc. - **/ - public PlacementPolicy label(String label) { - this.label = label; - return this; - } - - @ApiModelProperty(example = "null", value = "Assigns an app to a named partition of the cluster where the application desires to run (optional). If not specified all apps are submitted to a default label of the app owner. One or more labels can be setup for each application owner account with required constraints like no-preemption, sla-99999, preemption-ok, etc.") - @JsonProperty("label") - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PlacementPolicy placementPolicy = (PlacementPolicy) o; - return Objects.equals(this.label, placementPolicy.label); - } - - @Override - public int hashCode() { - return Objects.hash(label); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PlacementPolicy {\n"); - - sb.append(" label: ").append(toIndentedString(label)).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 "); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/ReadinessCheck.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/ReadinessCheck.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/ReadinessCheck.java deleted file mode 100644 index b3c85bd..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/ReadinessCheck.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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.slider.api.resource; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * 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. - **/ - -@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 implements Serializable { - private static final long serialVersionUID = -3836839816887186801L; - - public enum TypeEnum { - HTTP("HTTP"), - PORT("PORT"); - - private String value; - - TypeEnum(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return value; - } - } - - private TypeEnum type = null; - private Map<String, String> props = new HashMap<String, String>(); - private Artifact artifact = null; - - /** - * E.g. HTTP (YARN will perform a simple REST call at a regular interval and - * expect a 204 No content). - **/ - public ReadinessCheck type(TypeEnum type) { - this.type = type; - return this; - } - - @ApiModelProperty(example = "null", value = "E.g. HTTP (YARN will perform a simple REST call at a regular interval and expect a 204 No content).") - @JsonProperty("type") - public TypeEnum getType() { - return type; - } - - public void setType(TypeEnum type) { - this.type = type; - } - - public ReadinessCheck props(Map<String, String> props) { - this.props = props; - return this; - } - - public ReadinessCheck putPropsItem(String key, String propsItem) { - this.props.put(key, propsItem); - return this; - } - - /** - * A blob of key value pairs that will be used to configure the check. - * @return props - **/ - @ApiModelProperty(example = "null", value = "A blob of key value pairs that will be used to configure the check.") - public Map<String, String> getProps() { - return props; - } - - public void setProps(Map<String, String> props) { - this.props = props; - } - - /** - * Artifact of the pluggable readiness check helper container (optional). If - * specified, this helper container typically hosts the http uri and - * encapsulates the complex scripts required to perform actual container - * readiness check. At the end it is expected to respond a 204 No content just - * like the simplified use case. This pluggable framework benefits application - * owners who can run applications without any packaging modifications. Note, - * artifacts of type docker only is supported for now. - **/ - public ReadinessCheck artifact(Artifact artifact) { - this.artifact = artifact; - return this; - } - - @ApiModelProperty(example = "null", value = "Artifact of the pluggable readiness check helper container (optional). If specified, this helper container typically hosts the http uri and encapsulates the complex scripts required to perform actual container readiness check. At the end it is expected to respond a 204 No content just like the simplified use case. This pluggable framework benefits application owners who can run applications without any packaging modifications. Note, artifacts of type docker only is supported for now.") - @JsonProperty("artifact") - public Artifact getArtifact() { - return artifact; - } - - public void setArtifact(Artifact artifact) { - this.artifact = artifact; - } - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ReadinessCheck readinessCheck = (ReadinessCheck) o; - return Objects.equals(this.type, readinessCheck.type) && - Objects.equals(this.props, readinessCheck.props) && - Objects.equals(this.artifact, readinessCheck.artifact); - } - - @Override - public int hashCode() { - return Objects.hash(type, props, artifact); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ReadinessCheck {\n"); - - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" props: ").append(toIndentedString(props)).append("\n"); - sb.append(" artifact: ").append(toIndentedString(artifact)).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 "); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Resource.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Resource.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Resource.java deleted file mode 100644 index 314dfbb..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/resource/Resource.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.slider.api.resource; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * 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. - **/ - -@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 implements Cloneable { - private static final long serialVersionUID = -6431667797380250037L; - - private String profile = null; - private Integer cpus = 1; - private String memory = null; - - /** - * Each resource profile has a unique id which is associated with a - * cluster-level predefined memory, cpus, etc. - **/ - public Resource profile(String profile) { - this.profile = profile; - return this; - } - - @ApiModelProperty(example = "null", value = "Each resource profile has a unique id which is associated with a cluster-level predefined memory, cpus, etc.") - @JsonProperty("profile") - public String getProfile() { - return profile; - } - - public void setProfile(String profile) { - this.profile = profile; - } - - /** - * Amount of vcores allocated to each container (optional but overrides cpus - * in profile if specified). - **/ - public Resource cpus(Integer cpus) { - this.cpus = cpus; - return this; - } - - @ApiModelProperty(example = "null", value = "Amount of vcores allocated to each container (optional but overrides cpus in profile if specified).") - @JsonProperty("cpus") - public Integer getCpus() { - return cpus; - } - - public void setCpus(Integer cpus) { - this.cpus = cpus; - } - - /** - * 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. - **/ - public Resource memory(String memory) { - this.memory = memory; - return this; - } - - @ApiModelProperty(example = "null", value = "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.") - @JsonProperty("memory") - public String getMemory() { - return memory; - } - - public void setMemory(String memory) { - this.memory = memory; - } - - public long getMemoryMB() { - if (this.memory == null) { - return 0; - } - return Long.valueOf(memory); - } - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Resource resource = (Resource) o; - return Objects.equals(this.profile, resource.profile) - && Objects.equals(this.cpus, resource.cpus) - && Objects.equals(this.memory, resource.memory); - } - - @Override - public int hashCode() { - return Objects.hash(profile, cpus, memory); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Resource {\n"); - - 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("}"); - 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 "); - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java deleted file mode 100644 index 687edd2..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ApplicationLivenessInformation.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.slider.api.types; - -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -/** - * Serialized information about liveness - * <p> - * If true liveness probes are implemented, this - * datatype can be extended to publish their details. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -public class ApplicationLivenessInformation { - /** flag set if the cluster is at size */ - public boolean allRequestsSatisfied; - - /** number of outstanding requests: those needed to satisfy */ - public int requestsOutstanding; - - @Override - public String toString() { - final StringBuilder sb = - new StringBuilder("ApplicationLivenessInformation{"); - sb.append("allRequestsSatisfied=").append(allRequestsSatisfied); - sb.append(", requestsOutstanding=").append(requestsOutstanding); - sb.append('}'); - return sb.toString(); - } -} - - http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ComponentInformation.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ComponentInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ComponentInformation.java deleted file mode 100644 index d2fdd62..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ComponentInformation.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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.slider.api.types; - -import org.apache.slider.api.StatusKeys; -import org.apache.slider.server.appmaster.state.RoleStatus; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Serializable version of component data. - * <p> - * This is sent in REST calls as a JSON object âbut is also marshalled into - * a protobuf structure. Look at {@link RestTypeMarshalling} - * for the specifics there. - * <p> - * This means that if any fields are added here. they must be added to - * <code>src/main/proto/SliderClusterMessages.proto</code> and - * the protobuf structures rebuilt via a {@code mvn generate-sources -Pcompile-protobuf} - * - * See also {@link RoleStatus#serialize()} - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) - -public class ComponentInformation { - - public String name; - public int priority; - public int desired, actual, releasing; - public int placementPolicy; - public int requested; - public int failed, started, startFailed, completed, totalRequested; - public int nodeFailed, failedRecently, preempted; - public int pendingAntiAffineRequestCount; - public boolean isAARequestOutstanding; - - public String failureMessage; - public List<String> containers; - - /** - * Build the statistics map from the current data - * @return a map for use in statistics reports - */ - public Map<String, Integer> buildStatistics() { - Map<String, Integer> stats = new HashMap<>(); - stats.put(StatusKeys.STATISTICS_CONTAINERS_ACTIVE_REQUESTS, requested); - stats.put(StatusKeys.STATISTICS_CONTAINERS_ANTI_AFFINE_PENDING, pendingAntiAffineRequestCount); - stats.put(StatusKeys.STATISTICS_CONTAINERS_COMPLETED, completed); - stats.put(StatusKeys.STATISTICS_CONTAINERS_DESIRED, desired); - stats.put(StatusKeys.STATISTICS_CONTAINERS_FAILED, failed); - stats.put(StatusKeys.STATISTICS_CONTAINERS_FAILED_NODE, nodeFailed); - stats.put(StatusKeys.STATISTICS_CONTAINERS_FAILED_RECENTLY, failedRecently); - stats.put(StatusKeys.STATISTICS_CONTAINERS_LIVE, actual); - stats.put(StatusKeys.STATISTICS_CONTAINERS_PREEMPTED, preempted); - stats.put(StatusKeys.STATISTICS_CONTAINERS_REQUESTED, totalRequested); - stats.put(StatusKeys.STATISTICS_CONTAINERS_STARTED, started); - stats.put(StatusKeys.STATISTICS_CONTAINERS_START_FAILED, startFailed); - return stats; - } - - @Override - public String toString() { - final StringBuilder sb = - new StringBuilder("ComponentInformation{"); - sb.append(", name='").append(name).append('\''); - sb.append(", actual=").append(actual); - sb.append(", completed=").append(completed); - sb.append(", desired=").append(desired); - sb.append(", failed=").append(failed); - sb.append(", failureMessage='").append(failureMessage).append('\''); - sb.append(", placementPolicy=").append(placementPolicy); - sb.append(", isAARequestOutstanding=").append(isAARequestOutstanding); - sb.append(", pendingAntiAffineRequestCount=").append(pendingAntiAffineRequestCount); - sb.append(", priority=").append(priority); - sb.append(", releasing=").append(releasing); - sb.append(", requested=").append(requested); - sb.append(", started=").append(started); - sb.append(", startFailed=").append(startFailed); - sb.append(", totalRequested=").append(totalRequested); - sb.append(", container count='") - .append(containers == null ? 0 : containers.size()) - .append('\''); - sb.append('}'); - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ContainerInformation.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ContainerInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ContainerInformation.java deleted file mode 100644 index 6991340..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/ContainerInformation.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.slider.api.types; - -import org.apache.hadoop.registry.client.binding.JsonSerDeser; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -/** - * Serializable version of component instance data - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -public class ContainerInformation { - - public String containerId; - public String component; - public String appVersion; - public Boolean released; - public int state; - public Integer exitCode; - public String diagnostics; - public long createTime; - public long startTime; - - public String host; - public String hostURL; - public String placement; - /** - * What is the tail output from the executed process (or [] if not started - * or the log cannot be picked up - */ - public String[] output; - - @Override - public String toString() { - JsonSerDeser<ContainerInformation> serDeser = - new JsonSerDeser<>( - ContainerInformation.class); - return serDeser.toString(this); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeEntryInformation.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeEntryInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeEntryInformation.java deleted file mode 100644 index 8424be2..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeEntryInformation.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.slider.api.types; - -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -/** - * Serialized node entry information. Must be kept in sync with the protobuf equivalent. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -public class NodeEntryInformation { - - /** incrementing counter of instances that failed */ - public int failed; - - /** Counter of "failed recently" events. */ - public int failedRecently; - - /** timestamp of last use */ - public long lastUsed; - - /** Number of live nodes. */ - public int live; - - /** incrementing counter of instances that have been pre-empted. */ - public int preempted; - - /** Priority */ - public int priority; - - /** instance explicitly requested on this node */ - public int requested; - - /** number of containers being released off this node */ - public int releasing; - - /** incrementing counter of instances that failed to start */ - public int startFailed; - - /** number of starting instances */ - public int starting; - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder( - "NodeEntryInformation{"); - sb.append("priority=").append(priority); - sb.append(", live=").append(live); - sb.append(", requested=").append(requested); - sb.append(", releasing=").append(releasing); - sb.append(", starting=").append(starting); - sb.append(", failed=").append(failed); - sb.append(", failedRecently=").append(failedRecently); - sb.append(", startFailed=").append(startFailed); - sb.append(", preempted=").append(preempted); - sb.append(", lastUsed=").append(lastUsed); - sb.append('}'); - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformation.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformation.java deleted file mode 100644 index 4fe5b4c..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformation.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.slider.api.types; - -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Serialized node information. Must be kept in sync with the protobuf equivalent. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -public class NodeInformation { - - public String hostname; - public String state; - public String labels; - public String rackName; - public String httpAddress; - public String healthReport; - public long lastUpdated; - public Map<String, NodeEntryInformation> entries = new HashMap<>(); - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder( - "NodeInformation{"); - sb.append("hostname='").append(hostname).append('\''); - sb.append(", state='").append(state).append('\''); - sb.append(", labels='").append(labels).append('\''); - sb.append(", rackName='").append(rackName).append('\''); - sb.append(", httpAddress='").append(httpAddress).append('\''); - sb.append(", healthReport='").append(healthReport).append('\''); - sb.append(", lastUpdated=").append(lastUpdated); - sb.append('}'); - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformationList.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformationList.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformationList.java deleted file mode 100644 index 741523e..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/NodeInformationList.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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.slider.api.types; - -import org.apache.slider.core.persist.JsonSerDeser; - -import java.util.ArrayList; -import java.util.Collection; - -public class NodeInformationList extends ArrayList<NodeInformation> { - public NodeInformationList() { - } - - public NodeInformationList(Collection<? extends NodeInformation> c) { - super(c); - } - - public NodeInformationList(int initialCapacity) { - super(initialCapacity); - } - - public static JsonSerDeser<NodeInformationList> createSerializer() { - return new JsonSerDeser<>(NodeInformationList.class); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/PingInformation.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/PingInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/PingInformation.java deleted file mode 100644 index 223edca..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/PingInformation.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.slider.api.types; - -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -/** - * Serialized information to/from Ping operations - */ -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) -public class PingInformation { - public long time; - public String text; - public String verb; - public String body; - - @Override - public String toString() { - - final StringBuilder sb = - new StringBuilder("PingResource{"); - sb.append("time=").append(time); - sb.append(", verb=").append(verb); - sb.append(", text='").append(text).append('\''); - sb.append(", body='").append(body).append('\''); - sb.append('}'); - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RestTypeMarshalling.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RestTypeMarshalling.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RestTypeMarshalling.java deleted file mode 100644 index bc3d526..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RestTypeMarshalling.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * 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.slider.api.types; - -import org.apache.slider.api.proto.Messages; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Class to handle marshalling of REST - * types to/from Protobuf records. - */ -public class RestTypeMarshalling { - - public static Messages.ApplicationLivenessInformationProto - marshall(ApplicationLivenessInformation info) { - - Messages.ApplicationLivenessInformationProto.Builder builder = - Messages.ApplicationLivenessInformationProto.newBuilder(); - builder.setAllRequestsSatisfied(info.allRequestsSatisfied); - builder.setRequestsOutstanding(info.requestsOutstanding); - return builder.build(); - } - - public static ApplicationLivenessInformation - unmarshall(Messages.ApplicationLivenessInformationProto wire) { - ApplicationLivenessInformation info = new ApplicationLivenessInformation(); - info.allRequestsSatisfied = wire.getAllRequestsSatisfied(); - info.requestsOutstanding = wire.getRequestsOutstanding(); - return info; - } - - public static ComponentInformation - unmarshall(Messages.ComponentInformationProto wire) { - ComponentInformation info = new ComponentInformation(); - info.name = wire.getName(); - info.priority = wire.getPriority(); - info.placementPolicy = wire.getPlacementPolicy(); - - info.actual = wire.getActual(); - info.completed = wire.getCompleted(); - info.desired = wire.getDesired(); - info.failed = wire.getFailed(); - info.releasing = wire.getReleasing(); - info.requested = wire.getRequested(); - info.started = wire.getStarted(); - info.startFailed = wire.getStartFailed(); - info.totalRequested = wire.getTotalRequested(); - info.containers = new ArrayList<>(wire.getContainersList()); - if (wire.hasFailureMessage()) { - info.failureMessage = wire.getFailureMessage(); - } - if (wire.hasPendingAntiAffineRequestCount()) { - info.pendingAntiAffineRequestCount = wire.getPendingAntiAffineRequestCount(); - } - if (wire.hasIsAARequestOutstanding()) { - info.isAARequestOutstanding = wire.getIsAARequestOutstanding(); - } - return info; - } - public static Messages.ComponentInformationProto marshall(ComponentInformation info) { - - Messages.ComponentInformationProto.Builder builder = - Messages.ComponentInformationProto.newBuilder(); - builder.setName(info.name); - builder.setPriority(info.priority); - builder.setPlacementPolicy(info.placementPolicy); - - builder.setActual(info.actual); - builder.setCompleted(info.completed); - builder.setDesired(info.desired); - builder.setFailed(info.failed); - builder.setReleasing(info.releasing); - builder.setRequested(info.requested); - builder.setStarted(info.started); - builder.setStartFailed(info.startFailed); - builder.setTotalRequested(info.totalRequested); - builder.setNodeFailed(info.nodeFailed); - builder.setPreempted(info.preempted); - builder.setFailedRecently(info.failedRecently); - if (info.failureMessage != null) { - builder.setFailureMessage(info.failureMessage); - } - if (info.containers != null) { - builder.addAllContainers(info.containers); - } - builder.setPendingAntiAffineRequestCount(info.pendingAntiAffineRequestCount); - builder.setIsAARequestOutstanding(info.isAARequestOutstanding); - return builder.build(); - } - - public static Messages.NodeInformationProto marshall(NodeInformation info) { - - Messages.NodeInformationProto.Builder builder = - Messages.NodeInformationProto.newBuilder(); - builder.setHostname(info.hostname); - builder.setLastUpdated(info.lastUpdated); - builder.setState(info.state != null? info.state : "unknown"); - builder.setRackName(info.rackName != null ? info.rackName : ""); - builder.setHealthReport(info.healthReport != null ? info.healthReport : ""); - builder.setHttpAddress(info.httpAddress != null ? info.httpAddress : ""); - builder.setLabels(info.labels != null ? info.labels: ""); - - - if (info.entries != null) { - for (Map.Entry<String, NodeEntryInformation> elt : info.entries.entrySet()) { - NodeEntryInformation entry = elt.getValue(); - Messages.NodeEntryInformationProto.Builder node = - Messages.NodeEntryInformationProto.newBuilder(); - node.setPriority(entry.priority); - node.setName(elt.getKey()); - node.setFailed(entry.failed); - node.setFailedRecently(entry.failedRecently); - node.setLive(entry.live); - node.setLastUsed(entry.lastUsed); - node.setPreempted(entry.preempted); - node.setRequested(entry.requested); - node.setReleasing(entry.releasing); - node.setStartFailed(entry.startFailed); - node.setStarting(entry.starting); - builder.addEntries(node.build()); - } - } - return builder.build(); - } - - public static NodeInformation unmarshall(Messages.NodeInformationProto wire) { - NodeInformation info = new NodeInformation(); - info.healthReport = wire.getHealthReport(); - info.hostname = wire.getHostname(); - info.httpAddress = wire.getHttpAddress(); - info.labels = wire.getLabels(); - info.lastUpdated = wire.getLastUpdated(); - info.rackName = wire.getRackName(); - info.state = wire.getState(); - List<Messages.NodeEntryInformationProto> entriesList = wire.getEntriesList(); - if (entriesList != null) { - info.entries = new HashMap<>(entriesList.size()); - for (Messages.NodeEntryInformationProto entry : entriesList) { - NodeEntryInformation nei = new NodeEntryInformation(); - nei.failed = entry.getFailed(); - nei.failedRecently = entry.getFailedRecently(); - nei.lastUsed = entry.getLastUsed(); - nei.live = entry.getLive(); - nei.preempted = entry.getPreempted(); - nei.priority = entry.getPriority(); - nei.requested = entry.getRequested(); - nei.releasing = entry.getReleasing(); - nei.startFailed = entry.getStartFailed(); - nei.starting = entry.getStarting(); - info.entries.put(entry.getName(), nei); - } - } - return info; - } - - public static ContainerInformation unmarshall(Messages.ContainerInformationProto wire) { - ContainerInformation info = new ContainerInformation(); - info.containerId = wire.getContainerId(); - info.component = wire.getComponent(); - info.appVersion = wire.getAppVersion(); - info.state = wire.getState(); - if (wire.hasReleased()) { - info.released = wire.getReleased(); - } - if (wire.hasExitCode()) { - info.exitCode = wire.getExitCode(); - } - if (wire.hasDiagnostics()) { - info.diagnostics = wire.getDiagnostics(); - } - if (wire.hasHost()) { - info.host = wire.getHost(); - } - if (wire.hasHostURL()) { - info.host = wire.getHostURL(); - } - info.createTime = wire.getCreateTime(); - info.startTime = wire.getStartTime(); - info.output = wire.getOutputList().toArray( - new String[wire.getOutputCount()] - ); - if (wire.hasPlacement()) { - info.placement = wire.getPlacement(); - } - return info; - } - - public static List<ContainerInformation> unmarshall(Messages.GetLiveContainersResponseProto wire) { - List<ContainerInformation> infoList = new ArrayList<>(wire.getContainersList().size()); - for (Messages.ContainerInformationProto container : wire.getContainersList()) { - infoList.add(unmarshall(container)); - } - return infoList; - } - - public static Messages.ContainerInformationProto marshall(ContainerInformation info) { - - Messages.ContainerInformationProto.Builder builder = - Messages.ContainerInformationProto.newBuilder(); - if (info.containerId != null) { - builder.setContainerId(info.containerId); - } - if (info.component != null) { - builder.setComponent(info.component); - } - if (info.appVersion != null) { - builder.setAppVersion(info.appVersion); - } - builder.setCreateTime(info.createTime); - if (info.diagnostics != null) { - builder.setDiagnostics(info.diagnostics); - } - if (info.host != null) { - builder.setHost(info.host); - } - if (info.hostURL != null) { - builder.setHostURL(info.hostURL); - } - if (info.output != null) { - builder.addAllOutput(Arrays.asList(info.output)); - } - if (info.released != null) { - builder.setReleased(info.released); - } - if (info.placement != null) { - builder.setPlacement(info.placement); - } - builder.setStartTime(info.startTime); - builder.setState(info.state); - return builder.build(); - } - - public static String unmarshall(Messages.WrappedJsonProto wire) { - return wire.getJson(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RoleStatistics.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RoleStatistics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RoleStatistics.java deleted file mode 100644 index 25f4d9d..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/RoleStatistics.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.slider.api.types; - -import org.codehaus.jackson.annotate.JsonIgnoreProperties; - -/** - * Simple role statistics for state views; can be generated by RoleStatus - * instances, and aggregated for summary information. - */ -@JsonIgnoreProperties(ignoreUnknown = true) -public class RoleStatistics { - public long activeAA = 0L; - public long actual = 0L; - public long completed = 0L; - public long desired = 0L; - public long failed = 0L; - public long failedRecently = 0L; - public long limitsExceeded = 0L; - public long nodeFailed = 0L; - public long preempted = 0L; - public long requested = 0L; - public long started = 0L; - - /** - * Add another statistics instance - * @param that the other value - * @return this entry - */ - public RoleStatistics add(final RoleStatistics that) { - activeAA += that.activeAA; - actual += that.actual; - completed += that.completed; - desired += that.desired; - failed += that.failed; - failedRecently += that.failedRecently; - limitsExceeded += that.limitsExceeded; - nodeFailed += that.nodeFailed; - preempted += that.preempted; - requested += that.requested; - started += that.started; - return this; - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/SliderInstanceDescription.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/SliderInstanceDescription.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/SliderInstanceDescription.java deleted file mode 100644 index 3b95f80..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/api/types/SliderInstanceDescription.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.slider.api.types; - -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.yarn.api.records.ApplicationReport; - -/** - * Description of a slider instance - */ -public class SliderInstanceDescription { - - public final String name; - public final Path path; - public final ApplicationReport applicationReport; - - public SliderInstanceDescription(String name, - Path path, - ApplicationReport applicationReport) { - this.name = name; - this.path = path; - this.applicationReport = applicationReport; - } - - @Override - public String toString() { - final StringBuilder sb = - new StringBuilder("SliderInstanceDescription{"); - sb.append("name='").append(name).append('\''); - sb.append(", path=").append(path); - sb.append(", applicationReport: ") - .append(applicationReport == null - ? "null" - : (" id " + applicationReport.getApplicationId())); - sb.append('}'); - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/hadoop/blob/4e20105a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientRegistryBinder.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientRegistryBinder.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientRegistryBinder.java deleted file mode 100644 index da37d11..0000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/client/ClientRegistryBinder.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * 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.slider.client; - -import com.google.common.base.Preconditions; -import org.apache.hadoop.fs.PathNotFoundException; -import org.apache.hadoop.registry.client.api.RegistryConstants; -import org.apache.hadoop.registry.client.api.RegistryOperations; -import org.apache.hadoop.registry.client.binding.RegistryPathUtils; -import org.apache.hadoop.registry.client.binding.RegistryTypeUtils; -import org.apache.hadoop.registry.client.exceptions.InvalidRecordException; -import org.apache.hadoop.registry.client.impl.zk.RegistryInternalConstants; -import org.apache.hadoop.registry.client.types.Endpoint; -import org.apache.hadoop.registry.client.types.ServiceRecord; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.List; - -import static org.apache.hadoop.registry.client.binding.RegistryPathUtils.encodeForRegistry; -import static org.apache.hadoop.registry.client.binding.RegistryUtils.convertUsername; -import static org.apache.hadoop.registry.client.binding.RegistryUtils.getCurrentUsernameUnencoded; -import static org.apache.hadoop.registry.client.binding.RegistryUtils.servicePath; - -/** - * Generic code to get the URLs for clients via the registry - */ -public class ClientRegistryBinder { - private static final Logger log = - LoggerFactory.getLogger(ClientRegistryBinder.class); - - private final RegistryOperations operations; - - public ClientRegistryBinder(RegistryOperations operations) { - this.operations = operations; - } - - /** - * Buld the user path -switches to the system path if the user is "". - * It also cross-converts the username to ascii via punycode - * @param username username or "" - * @return the path to the user - */ - public static String homePathForUser(String username) { - Preconditions.checkArgument(username != null, "null user"); - - // catch recursion - if (username.startsWith(RegistryConstants.PATH_USERS)) { - return username; - } - - if (username.isEmpty()) { - return RegistryConstants.PATH_SYSTEM_SERVICES; - } - - // convert username to registry name - String convertedName = convertUsername(username); - - return RegistryPathUtils.join(RegistryConstants.PATH_USERS, - encodeForRegistry(convertedName)); - } - - /** - * Get the current username, before any encoding has been applied. - * @return the current user from the kerberos identity, falling back - * to the user and/or env variables. - */ - public static String currentUsernameUnencoded() { - String env_hadoop_username = System.getenv( - RegistryInternalConstants.HADOOP_USER_NAME); - return getCurrentUsernameUnencoded(env_hadoop_username); - } - - /** - * Qualify a user. - * <ol> - * <li> <code>"~"</code> maps to user home path home</li> - * <li> <code>"~user"</code> maps to <code>/users/$user</code></li> - * <li> <code>"/"</code> maps to <code>/services/</code></li> - * </ol> - * @param user the username - * @return the base path - */ - public static String qualifyUser(String user) { - // qualify the user - String t = user.trim(); - if (t.startsWith("/")) { - // already resolved - return t; - } else if (t.equals("~")) { - // self - return currentUsernameUnencoded(); - } else if (t.startsWith("~")) { - // another user - // convert username to registry name - String convertedName = convertUsername(t.substring(1)); - - return RegistryPathUtils.join(RegistryConstants.PATH_USERS, - encodeForRegistry(convertedName)); - } else { - return "/" + t; - } - } - - /** - * Look up an external REST API - * @param user user which will be qualified as per {@link #qualifyUser(String)} - * @param serviceClass service class - * @param instance instance name - * @param api API - * @return the API, or an exception is raised. - * @throws IOException - */ - public String lookupExternalRestAPI(String user, - String serviceClass, - String instance, - String api) - throws IOException { - String qualified = qualifyUser(user); - String path = servicePath(qualified, serviceClass, instance); - String restAPI = resolveExternalRestAPI(api, path); - if (restAPI == null) { - throw new PathNotFoundException(path + " API " + api); - } - return restAPI; - } - - /** - * Resolve a service record then return an external REST API exported it. - * - * @param api API to resolve - * @param path path of the service record - * @return null if the record exists but the API is absent or it has no - * REST endpoints. - * @throws IOException resolution problems, as covered in - * {@link RegistryOperations#resolve(String)} - */ - protected String resolveExternalRestAPI(String api, String path) throws - IOException { - ServiceRecord record = operations.resolve(path); - return lookupRestAPI(record, api, true); - } - - /** - * Look up an external REST API endpoint - * @param record service record - * @param api URI of api - * @param external flag to indicate this is an external record - * @return the first endpoint of the implementation, or null if there - * is no entry for the API, implementation or it's the wrong type. - */ - public static String lookupRestAPI(ServiceRecord record, - String api, boolean external) throws InvalidRecordException { - try { - String url = null; - Endpoint endpoint = getEndpoint(record, api, external); - List<String> addresses = - RegistryTypeUtils.retrieveAddressesUriType(endpoint); - if (addresses != null && !addresses.isEmpty()) { - url = addresses.get(0); - } - return url; - } catch (InvalidRecordException e) { - log.debug("looking for API {}", api, e); - return null; - } - } - - /** - * Get an endpont by API - * @param record service record - * @param api API - * @param external flag to indicate this is an external record - * @return the endpoint or null - */ - public static Endpoint getEndpoint(ServiceRecord record, - String api, - boolean external) { - return external ? record.getExternalEndpoint(api) - : record.getInternalEndpoint(api); - } - - -} --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org