diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Container.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Container.java index 38fa8b9..893d273 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Container.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Container.java @@ -43,6 +43,7 @@ *
  • HTTP uri of the node.
  • *
  • {@link Resource} allocated to the container.
  • *
  • {@link Priority} at which the container was allocated.
  • + *
  • {@link ContainerType} of the container.
  • *
  • * Container {@link Token} of the container, used to securely verify * authenticity of the allocation. @@ -66,12 +67,22 @@ public static Container newInstance(ContainerId containerId, NodeId nodeId, String nodeHttpAddress, Resource resource, Priority priority, Token containerToken) { + return newInstance(containerId, nodeId, nodeHttpAddress, resource, + priority, ContainerType.GUARANTEED, containerToken); + } + + @Private + @Unstable + public static Container newInstance(ContainerId containerId, NodeId nodeId, + String nodeHttpAddress, Resource resource, Priority priority, + ContainerType containerType, Token containerToken) { Container container = Records.newRecord(Container.class); container.setId(containerId); container.setNodeId(nodeId); container.setNodeHttpAddress(nodeHttpAddress); container.setResource(resource); container.setPriority(priority); + container.setContainerType(containerType); container.setContainerToken(containerToken); return container; } @@ -134,6 +145,15 @@ public static Container newInstance(ContainerId containerId, NodeId nodeId, @Stable public abstract Priority getPriority(); + /** + * Get the Type of the Container. + * + * @return the Type of the Container. + */ + public abstract ContainerType getContainerType(); + + public abstract void setContainerType(ContainerType containerType); + @Private @Unstable public abstract void setPriority(Priority priority); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java index c9b9618..f6b711c 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java @@ -39,16 +39,23 @@ public abstract class ContainerId implements Comparable{ public static final long CONTAINER_ID_BITMASK = 0xffffffffffL; private static final Splitter _SPLITTER = Splitter.on('_').trimResults(); - private static final String CONTAINER_PREFIX = "container"; private static final String EPOCH_PREFIX = "e"; @Private @Unstable public static ContainerId newContainerId(ApplicationAttemptId appAttemptId, long containerId) { + return newContainerId(appAttemptId, containerId, ContainerType.GUARANTEED); + } + + @Private + @Unstable + public static ContainerId newContainerId(ApplicationAttemptId appAttemptId, + long containerId, ContainerType containerType) { ContainerId id = Records.newRecord(ContainerId.class); id.setContainerId(containerId); id.setApplicationAttemptId(appAttemptId); + id.setContainerType(containerType); id.build(); return id; } @@ -58,9 +65,18 @@ public static ContainerId newContainerId(ApplicationAttemptId appAttemptId, @Unstable public static ContainerId newInstance(ApplicationAttemptId appAttemptId, int containerId) { + return newInstance(appAttemptId, containerId, ContainerType.GUARANTEED); + } + + @Private + @Deprecated + @Unstable + public static ContainerId newInstance(ApplicationAttemptId appAttemptId, + int containerId, ContainerType containerType) { ContainerId id = Records.newRecord(ContainerId.class); id.setContainerId(containerId); id.setApplicationAttemptId(appAttemptId); + id.setContainerType(containerType); id.build(); return id; } @@ -115,6 +131,20 @@ public static ContainerId newInstance(ApplicationAttemptId appAttemptId, protected abstract void setContainerId(long id); + /** + * Determines the ContainerType of the container represented by this + * ContainerId. + * + * @return the ContainerType of the container. + */ + @Public + @Stable + public abstract ContainerType getContainerType(); + + @Private + @Unstable + protected abstract void setContainerType(ContainerType containerType); + // TODO: fail the app submission if attempts are more than 10 or something private static final ThreadLocal appAttemptIdAndEpochFormat = new ThreadLocal() { @@ -160,6 +190,8 @@ public boolean equals(Object obj) { return false; if (this.getContainerId() != other.getContainerId()) return false; + if (this.getContainerType() != other.getContainerType()) + return false; return true; } @@ -167,8 +199,11 @@ public boolean equals(Object obj) { public int compareTo(ContainerId other) { if (this.getApplicationAttemptId().compareTo( other.getApplicationAttemptId()) == 0) { - return Long.valueOf(getContainerId()) - .compareTo(Long.valueOf(other.getContainerId())); + if (this.getContainerId() == other.getContainerId()) { + return this.getContainerType().compareTo(other.getContainerType()); + } else { + return Long.compare(getContainerId(), other.getContainerId()); + } } else { return this.getApplicationAttemptId().compareTo( other.getApplicationAttemptId()); @@ -187,7 +222,7 @@ public int compareTo(ContainerId other) { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append(CONTAINER_PREFIX + "_"); + sb.append(getContainerType().getPrefix()).append("_"); long epoch = getContainerId() >> 40; if (epoch > 0) { sb.append(EPOCH_PREFIX) @@ -209,7 +244,10 @@ public String toString() { @Unstable public static ContainerId fromString(String containerIdStr) { Iterator it = _SPLITTER.split(containerIdStr).iterator(); - if (!it.next().equals(CONTAINER_PREFIX)) { + String containerPrefix = it.next(); + ContainerType containerType = ContainerType + .getContainerTypeFromPrefix(containerPrefix); + if (containerType == null) { throw new IllegalArgumentException("Invalid ContainerId prefix: " + containerIdStr); } @@ -228,7 +266,8 @@ public static ContainerId fromString(String containerIdStr) { } long id = Long.parseLong(it.next()); long cid = (epoch << 40) | id; - ContainerId containerId = ContainerId.newContainerId(appAttemptID, cid); + ContainerId containerId = ContainerId.newContainerId(appAttemptID, cid, + containerType); return containerId; } catch (NumberFormatException n) { throw new IllegalArgumentException("Invalid ContainerId: " diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerLaunchContext.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerLaunchContext.java index 932945b..e1b6094 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerLaunchContext.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerLaunchContext.java @@ -37,6 +37,7 @@ *
      *
    • {@link ContainerId} of the container.
    • *
    • {@link Resource} allocated to the container.
    • + *
    • {@link ContainerType} of the container request.
    • *
    • User to whom the container is allocated.
    • *
    • Security tokens (if security is enabled).
    • *
    • @@ -61,10 +62,23 @@ public static ContainerLaunchContext newInstance( Map environment, List commands, Map serviceData, ByteBuffer tokens, Map acls) { - ContainerLaunchContext container = - Records.newRecord(ContainerLaunchContext.class); + return newInstance(localResources, environment, + ContainerType.GUARANTEED, commands, serviceData, + tokens, acls); + } + + @Public + @Stable + public static ContainerLaunchContext newInstance( + Map localResources, + Map environment, ContainerType containerType, + List commands, Map serviceData, + ByteBuffer tokens, Map acls) { + ContainerLaunchContext container = Records + .newRecord(ContainerLaunchContext.class); container.setLocalResources(localResources); container.setEnvironment(environment); + container.setContainerType(containerType); container.setCommands(commands); container.setServiceData(serviceData); container.setTokens(tokens); @@ -163,6 +177,23 @@ public static ContainerLaunchContext newInstance( public abstract void setEnvironment(Map environment); /** + * Get container type of the request. + * @return container type of the request + */ + @Public + @Stable + public abstract ContainerType getContainerType(); + + /** + * Set container type for the request. + * @param container type for the request + */ + @Public + @Stable + public abstract void setContainerType( + ContainerType containerType); + + /** * Get the list of commands for launching the container. * @return the list of commands for launching the container */ diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerStatus.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerStatus.java index 5ccf6dc..7e6b1cc 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerStatus.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerStatus.java @@ -32,6 +32,7 @@ *
        *
      • {@code ContainerId} of the container.
      • *
      • {@code ContainerState} of the container.
      • + *
      • {@code ContainerType} of the container.
      • *
      • Exit status of a completed container.
      • *
      • Diagnostic message for a failed container.
      • *
      @@ -44,7 +45,17 @@ @Unstable public static ContainerStatus newInstance(ContainerId containerId, ContainerState containerState, String diagnostics, int exitStatus) { + return newInstance(containerId, ContainerType.GUARANTEED, + containerState, diagnostics, exitStatus); + } + + @Private + @Unstable + public static ContainerStatus newInstance(ContainerId containerId, + ContainerType containerType, ContainerState containerState, + String diagnostics, int exitStatus) { ContainerStatus containerStatus = Records.newRecord(ContainerStatus.class); + containerStatus.setContainerType(containerType); containerStatus.setState(containerState); containerStatus.setContainerId(containerId); containerStatus.setDiagnostics(diagnostics); @@ -63,6 +74,19 @@ public static ContainerStatus newInstance(ContainerId containerId, @Private @Unstable public abstract void setContainerId(ContainerId containerId); + + /** + * Get the ContainerType of the container. + * + * @return ContainerType of the container + */ + @Public + @Stable + public abstract ContainerType getContainerType(); + + @Private + @Unstable + public abstract void setContainerType(ContainerType containerType); /** * Get the ContainerState of the container. diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerType.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerType.java new file mode 100644 index 0000000..1bb1c7a --- /dev/null +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerType.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.yarn.api.records; + +import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Stable; + +/** + * Container property encoding allocation and execution semantics. + * + *

      + * The container types are the following: + *

        + *
      • {@link #GUARANTEED} - this container is guaranteed to start its + * execution, once received by an NM.
      • + *
      • {@link #QUEUEABLE} - this container is allowed to be queued in one of the + * NMs. It is thus not guaranteed to start its execution immediately. + *
      + *

      + */ +@Public +@Stable +public enum ContainerType { + GUARANTEED("container"), QUEUEABLE("queueable-container"); + + private final String prefix; + + private ContainerType(String prefix) { + this.prefix = prefix; + } + + public String getPrefix() { + return this.prefix; + } + + public static ContainerType getContainerTypeFromPrefix(String prefix) { + for (ContainerType containerType : values()) { + if (containerType.getPrefix().equals(prefix)) { + return containerType; + } + } + return null; + } +} \ No newline at end of file diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceRequest.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceRequest.java index 790120a..7ae587d 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceRequest.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceRequest.java @@ -50,6 +50,7 @@ * locality to be loose (i.e. allows fall-through to rack or any) * or strict (i.e. specify hard constraint on resource allocation). *
    • + *
    • {@link ContainerType} of the containers of the request.
    • *
    * * @see Resource @@ -63,7 +64,8 @@ @Stable public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers) { - return newInstance(priority, hostName, capability, numContainers, true); + return newInstance(priority, hostName, capability, numContainers, + ContainerType.GUARANTEED); } @Public @@ -71,7 +73,16 @@ public static ResourceRequest newInstance(Priority priority, String hostName, public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality) { return newInstance(priority, hostName, capability, numContainers, - relaxLocality, null); + relaxLocality, ContainerType.GUARANTEED, null); + } + + @Public + @Stable + public static ResourceRequest newInstance(Priority priority, String hostName, + Resource capability, int numContainers, + ContainerType containerType) { + return newInstance(priority, hostName, capability, numContainers, true, + containerType, null); } @Public @@ -79,12 +90,23 @@ public static ResourceRequest newInstance(Priority priority, String hostName, public static ResourceRequest newInstance(Priority priority, String hostName, Resource capability, int numContainers, boolean relaxLocality, String labelExpression) { + return newInstance(priority, hostName, capability, numContainers, + relaxLocality, ContainerType.GUARANTEED, + labelExpression); + } + + @Public + @Stable + public static ResourceRequest newInstance(Priority priority, String hostName, + Resource capability, int numContainers, boolean relaxLocality, + ContainerType containerType, String labelExpression) { ResourceRequest request = Records.newRecord(ResourceRequest.class); request.setPriority(priority); request.setResourceName(hostName); request.setCapability(capability); request.setNumContainers(numContainers); request.setRelaxLocality(relaxLocality); + request.setContainerType(containerType); request.setNodeLabelExpression(labelExpression); return request; } @@ -250,6 +272,26 @@ public static boolean isAnyLocation(String hostName) { public abstract void setRelaxLocality(boolean relaxLocality); /** + * Get the ContainerType of the request's containers. + * + * @return ContainerType of the request's containers + */ + @Public + @Stable + public abstract ContainerType getContainerType(); + + /** + * Set the ContainerType of the containers of the request. + * + * @param containerType + * ContainerType of the containers of the request + */ + @Public + @Stable + public abstract void setContainerType( + ContainerType containerType); + + /** * Get node-label-expression for this Resource Request. If this is set, all * containers allocated to satisfy this resource-request will be only on those * nodes that satisfy this node-label-expression. @@ -322,6 +364,9 @@ public boolean equals(Object obj) { return false; } else if (!priority.equals(other.getPriority())) return false; + ContainerType containerType = getContainerType(); + if (!containerType.equals(other.getContainerType())) + return false; if (getNodeLabelExpression() == null) { if (other.getNodeLabelExpression() != null) { return false; @@ -349,7 +394,13 @@ public int compareTo(ResourceRequest other) { int capabilityComparison = this.getCapability().compareTo(other.getCapability()); if (capabilityComparison == 0) { - return this.getNumContainers() - other.getNumContainers(); + int containerTypeComparison = + this.getContainerType().compareTo(other.getContainerType()); + if (containerTypeComparison == 0) { + return this.getNumContainers() - other.getNumContainers(); + } else { + return containerTypeComparison; + } } else { return capabilityComparison; } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto index c45081a..ce491dc 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto @@ -51,6 +51,7 @@ message ContainerIdProto { optional ApplicationIdProto app_id = 1; optional ApplicationAttemptIdProto app_attempt_id = 2; optional int64 id = 3; + optional ContainerTypeProto container_type = 4 [default = GUARANTEED]; } message ResourceProto { @@ -78,6 +79,11 @@ enum ContainerStateProto { C_COMPLETE = 3; } +enum ContainerTypeProto { + GUARANTEED = 1; + QUEUEABLE = 2; +} + message ContainerProto { optional ContainerIdProto id = 1; optional NodeIdProto nodeId = 2; @@ -85,6 +91,7 @@ message ContainerProto { optional ResourceProto resource = 4; optional PriorityProto priority = 5; optional hadoop.common.TokenProto container_token = 6; + optional ContainerTypeProto container_type = 7 [default = GUARANTEED]; } message ContainerReportProto { @@ -275,7 +282,8 @@ message ResourceRequestProto { optional ResourceProto capability = 3; optional int32 num_containers = 4; optional bool relax_locality = 5 [default = true]; - optional string node_label_expression = 6; + optional ContainerTypeProto container_type = 6 [default = GUARANTEED]; + optional string node_label_expression = 7; } enum AMCommandProto { @@ -451,6 +459,7 @@ message ContainerLaunchContextProto { repeated StringStringMapProto environment = 4; repeated string command = 5; repeated ApplicationACLMapProto application_ACLs = 6; + optional ContainerTypeProto container_type = 7 [default = GUARANTEED]; } message ContainerStatusProto { @@ -458,6 +467,7 @@ message ContainerStatusProto { optional ContainerStateProto state = 2; optional string diagnostics = 3 [default = "N/A"]; optional int32 exit_status = 4 [default = -1000]; + optional ContainerTypeProto containerType = 5 [default = GUARANTEED]; } enum ContainerExitStatusProto { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java index 298f092..dcaab94 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerIdPBImpl.java @@ -22,8 +22,10 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerTypeProto; import com.google.common.base.Preconditions; @@ -80,6 +82,18 @@ protected void setApplicationAttemptId(ApplicationAttemptId atId) { } this.applicationAttemptId = atId; } + + @Override + public ContainerType getContainerType() { + Preconditions.checkNotNull(proto); + return convertFromProtoFormat(proto.getContainerType()); + } + + @Override + protected void setContainerType(ContainerType containerType) { + Preconditions.checkNotNull(builder); + builder.setContainerType(convertToProtoFormat(containerType)); + } private ApplicationAttemptIdPBImpl convertFromProtoFormat( ApplicationAttemptIdProto p) { @@ -90,6 +104,14 @@ private ApplicationAttemptIdProto convertToProtoFormat( ApplicationAttemptId t) { return ((ApplicationAttemptIdPBImpl)t).getProto(); } + + private ContainerType convertFromProtoFormat(ContainerTypeProto e) { + return ProtoUtils.convertFromProtoFormat(e); + } + + private ContainerTypeProto convertToProtoFormat(ContainerType e) { + return ProtoUtils.convertToProtoFormat(e); + } @Override protected void build() { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java index 12dcfcd..25ee890 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java @@ -29,10 +29,12 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.yarn.api.records.ApplicationAccessType; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerTypeProto; import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.StringBytesMapProto; import org.apache.hadoop.yarn.proto.YarnProtos.StringLocalResourceMapProto; @@ -54,6 +56,7 @@ private ByteBuffer tokens = null; private Map serviceData = null; private Map environment = null; + private ContainerType containerType = null; private List commands = null; private Map applicationACLS = null; @@ -101,6 +104,16 @@ protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) { return ProtoUtils.convertToProtoFormat(byteBuffer); } + protected ContainerType convertFromProtoFormat( + ContainerTypeProto containerType) { + return ProtoUtils.convertFromProtoFormat(containerType); + } + + protected ContainerTypeProto convertToProtoFormat( + ContainerType containerType) { + return ProtoUtils.convertToProtoFormat(containerType); + } + private void mergeLocalToBuilder() { if (this.localResources != null) { addLocalResourcesToProto(); @@ -114,6 +127,9 @@ private void mergeLocalToBuilder() { if (this.environment != null) { addEnvToProto(); } + if (this.containerType != null) { + builder.setContainerType(convertToProtoFormat(this.containerType)); + } if (this.commands != null) { addCommandsToProto(); } @@ -386,6 +402,31 @@ public boolean hasNext() { }; builder.addAllEnvironment(iterable); } + + @Override + public ContainerType getContainerType() { + + ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; + if (this.containerType != null) { + return this.containerType; + } + if (!p.hasContainerType()) { + return null; + } + this.containerType = convertFromProtoFormat(p + .getContainerType()); + return this.containerType; + } + + @Override + public void setContainerType(ContainerType type) { + maybeInitBuilder(); + if (type == null) { + builder.clearContainerType(); + return; + } + this.containerType = type; + } @Override public Map getApplicationACLs() { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java index 1700068..bbfb68d 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java @@ -23,6 +23,7 @@ import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; import org.apache.hadoop.yarn.api.records.Container; import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.Priority; import org.apache.hadoop.yarn.api.records.Resource; @@ -30,6 +31,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerTypeProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; @@ -226,6 +228,25 @@ public void setPriority(Priority priority) { } this.priority = priority; } + + @Override + public ContainerType getContainerType() { + ContainerProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasContainerType()) { + return null; + } + return convertFromProtoFormat(p.getContainerType()); + } + + @Override + public void setContainerType(ContainerType containerType) { + maybeInitBuilder(); + if (containerType == null) { + builder.clearContainerType(); + return; + } + builder.setContainerType(convertToProtoFormat(containerType)); + } @Override public Token getContainerToken() { @@ -280,6 +301,14 @@ private PriorityProto convertToProtoFormat(Priority p) { return ((PriorityPBImpl)p).getProto(); } + private ContainerType convertFromProtoFormat(ContainerTypeProto e) { + return ProtoUtils.convertFromProtoFormat(e); + } + + private ContainerTypeProto convertToProtoFormat(ContainerType e) { + return ProtoUtils.convertToProtoFormat(e); + } + private TokenPBImpl convertFromProtoFormat(TokenProto p) { return new TokenPBImpl(p); } @@ -296,6 +325,7 @@ public String toString() { sb.append("NodeHttpAddress: ").append(getNodeHttpAddress()).append(", "); sb.append("Resource: ").append(getResource()).append(", "); sb.append("Priority: ").append(getPriority()).append(", "); + sb.append("ContainerType: ").append(getContainerType()).append(','); sb.append("Token: ").append(getContainerToken()).append(", "); sb.append("]"); return sb.toString(); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java index 86f2af9..49f859f 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java @@ -24,10 +24,12 @@ import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerState; import org.apache.hadoop.yarn.api.records.ContainerStatus; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerTypeProto; import com.google.protobuf.TextFormat; @@ -77,6 +79,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("ContainerStatus: ["); sb.append("ContainerId: ").append(getContainerId()).append(", "); + sb.append("ContainerType: ").append(getContainerType()).append(", "); sb.append("State: ").append(getState()).append(", "); sb.append("Diagnostics: ").append(getDiagnostics()).append(", "); sb.append("ExitStatus: ").append(getExitStatus()).append(", "); @@ -144,6 +147,26 @@ public synchronized void setContainerId(ContainerId containerId) { builder.clearContainerId(); this.containerId = containerId; } + + @Override + public synchronized ContainerType getContainerType() { + ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasContainerType()) { + return null; + } + return convertFromProtoFormat(p.getContainerType()); + } + + @Override + public synchronized void setContainerType(ContainerType containerType) { + maybeInitBuilder(); + if (containerType == null) { + builder.clearContainerType(); + return; + } + builder.setContainerType(convertToProtoFormat(containerType)); + } + @Override public synchronized int getExitStatus() { ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; @@ -184,6 +207,13 @@ private ContainerIdProto convertToProtoFormat(ContainerId t) { return ((ContainerIdPBImpl)t).getProto(); } + private ContainerType convertFromProtoFormat(ContainerTypeProto e) { + return ProtoUtils.convertFromProtoFormat(e); + } + + private ContainerTypeProto convertToProtoFormat(ContainerType e) { + return ProtoUtils.convertToProtoFormat(e); + } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java index 4e8a19c..4214905 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ProtoUtils.java @@ -27,6 +27,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationAccessType; import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; import org.apache.hadoop.yarn.api.records.ContainerState; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.LocalResourceType; import org.apache.hadoop.yarn.api.records.LocalResourceVisibility; @@ -42,6 +43,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAccessTypeProto; import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerTypeProto; import org.apache.hadoop.yarn.proto.YarnProtos.FinalApplicationStatusProto; import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceTypeProto; import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceVisibilityProto; @@ -164,6 +166,16 @@ public static LocalResourceType convertFromProtoFormat(LocalResourceTypeProto e) } /* + * ContainerType + */ + public static ContainerType convertFromProtoFormat(ContainerTypeProto e) { + return ContainerType.valueOf(e.name()); + } + public static ContainerTypeProto convertToProtoFormat(ContainerType e) { + return ContainerTypeProto.valueOf(e.name()); + } + + /* * LocalResourceVisibility */ public static LocalResourceVisibilityProto convertToProtoFormat(LocalResourceVisibility e) { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java index 27fb5ae..b6e51ce 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ResourceRequestPBImpl.java @@ -21,9 +21,11 @@ import org.apache.hadoop.classification.InterfaceAudience.Private; import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.api.records.Priority; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.ResourceRequest; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerTypeProto; import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProto; @@ -38,6 +40,7 @@ private Priority priority = null; private Resource capability = null; + private ContainerType containerType = null; public ResourceRequestPBImpl() { @@ -63,6 +66,9 @@ private void mergeLocalToBuilder() { if (this.capability != null) { builder.setCapability(convertToProtoFormat(this.capability)); } + if (this.containerType != null) { + builder.setContainerType(convertToProtoFormat(this.containerType)); + } } private void mergeLocalToProto() { @@ -163,6 +169,30 @@ public void setRelaxLocality(boolean relaxLocality) { builder.setRelaxLocality(relaxLocality); } + @Override + public ContainerType getContainerType() { + ResourceRequestProtoOrBuilder p = viaProto ? proto : builder; + if (this.containerType != null) { + return this.containerType; + } + if (!p.hasContainerType()) { + return null; + } + this.containerType = convertFromProtoFormat(p + .getContainerType()); + return this.containerType; + } + + @Override + public void setContainerType(ContainerType type) { + maybeInitBuilder(); + if (type == null) { + builder.clearContainerType(); + return; + } + this.containerType = type; + } + private PriorityPBImpl convertFromProtoFormat(PriorityProto p) { return new PriorityPBImpl(p); } @@ -179,6 +209,14 @@ private ResourceProto convertToProtoFormat(Resource t) { return ((ResourcePBImpl)t).getProto(); } + private ContainerType convertFromProtoFormat(ContainerTypeProto requestType) { + return ProtoUtils.convertFromProtoFormat(requestType); + } + + private ContainerTypeProto convertToProtoFormat(ContainerType containerType) { + return ProtoUtils.convertToProtoFormat(containerType); + } + @Override public String toString() { return "{Priority: " + getPriority() + ", Capability: " + getCapability() @@ -205,4 +243,4 @@ public void setNodeLabelExpression(String nodeLabelExpression) { } builder.setNodeLabelExpression(nodeLabelExpression); } -} \ No newline at end of file +} diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/Container.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/Container.java index 56b4fdd..c552367 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/Container.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/Container.java @@ -26,6 +26,7 @@ import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; import org.apache.hadoop.yarn.api.records.ContainerStatus; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.event.EventHandler; import org.apache.hadoop.yarn.security.ContainerTokenIdentifier; @@ -42,6 +43,8 @@ String getUser(); ContainerState getContainerState(); + + ContainerType getContainerType(); ContainerLaunchContext getLaunchContext(); diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java index 9997ca2..59f1311 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/ContainerImpl.java @@ -42,6 +42,7 @@ import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; import org.apache.hadoop.yarn.api.records.ContainerStatus; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.api.records.LocalResourceVisibility; import org.apache.hadoop.yarn.api.records.Resource; @@ -91,6 +92,7 @@ private final ContainerLaunchContext launchContext; private final ContainerTokenIdentifier containerTokenIdentifier; private final ContainerId containerId; + private final ContainerType containerType; private final Resource resource; private final String user; private int exitCode = ContainerExitStatus.INVALID; @@ -129,12 +131,22 @@ public ContainerImpl(Configuration conf, Dispatcher dispatcher, NMStateStoreService stateStore, ContainerLaunchContext launchContext, Credentials creds, NodeManagerMetrics metrics, ContainerTokenIdentifier containerTokenIdentifier) { + this(conf, dispatcher, stateStore, launchContext, creds, metrics, + containerTokenIdentifier, ContainerType.GUARANTEED); + } + + public ContainerImpl(Configuration conf, Dispatcher dispatcher, + NMStateStoreService stateStore, ContainerLaunchContext launchContext, + Credentials creds, NodeManagerMetrics metrics, + ContainerTokenIdentifier containerTokenIdentifier, + ContainerType containerType) { this.daemonConf = conf; this.dispatcher = dispatcher; this.stateStore = stateStore; this.launchContext = launchContext; this.containerTokenIdentifier = containerTokenIdentifier; this.containerId = containerTokenIdentifier.getContainerID(); + this.containerType = containerType; this.resource = containerTokenIdentifier.getResource(); this.diagnostics = new StringBuilder(); this.credentials = creds; @@ -410,6 +422,11 @@ public ContainerState getContainerState() { } @Override + public ContainerType getContainerType() { + return this.containerType; + } + + @Override public ContainerLaunchContext getLaunchContext() { this.readLock.lock(); try { diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/AMRMClient.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/AMRMClient.java index bfe10d6..c7749b2 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/AMRMClient.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/AMRMClient.java @@ -32,6 +32,7 @@ import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse; import org.apache.hadoop.yarn.api.records.ContainerId; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.Priority; import org.apache.hadoop.yarn.api.records.Resource; @@ -105,6 +106,7 @@ protected AMRMClient(String name) { final List racks; final Priority priority; final boolean relaxLocality; + final ContainerType containerType; final String nodeLabelsExpression; /** @@ -175,6 +177,36 @@ public ContainerRequest(Resource capability, String[] nodes, public ContainerRequest(Resource capability, String[] nodes, String[] racks, Priority priority, boolean relaxLocality, String nodeLabelsExpression) { + this(capability, nodes, racks, priority, relaxLocality, + ContainerType.GUARANTEED, nodeLabelsExpression); + } + + /** + * Instantiates a {@link ContainerRequest} with the given constraints. + * + * @param capability + * The {@link Resource} to be requested for each container. + * @param nodes + * Any hosts to request that the containers are placed on. + * @param racks + * Any racks to request that the containers are placed on. The + * racks corresponding to any hosts requested will be automatically + * added to this list. + * @param priority + * The priority at which to request the containers. Higher + * priorities have lower numerical values. + * @param relaxLocality + * If true, containers for this request may be assigned on hosts + * and racks other than the ones explicitly requested. + * @param containerType + * The {@link ContainerType} of the container to be requested. + * @param nodeLabelsExpression + * Set node labels to allocate resource, now we only support + * asking for only a single node label + */ + public ContainerRequest(Resource capability, String[] nodes, + String[] racks, Priority priority, boolean relaxLocality, + ContainerType containerType, String nodeLabelsExpression) { // Validate request Preconditions.checkArgument(capability != null, "The Resource to be requested for each container " + @@ -191,6 +223,7 @@ public ContainerRequest(Resource capability, String[] nodes, this.racks = (racks != null ? ImmutableList.copyOf(racks) : null); this.priority = priority; this.relaxLocality = relaxLocality; + this.containerType = containerType; this.nodeLabelsExpression = nodeLabelsExpression; } @@ -214,6 +247,10 @@ public boolean getRelaxLocality() { return relaxLocality; } + public ContainerType getContainerType() { + return containerType; + } + public String getNodeLabelExpression() { return nodeLabelsExpression; } @@ -222,6 +259,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Capability[").append(capability).append("]"); sb.append("Priority[").append(priority).append("]"); + sb.append("ContainerType[").append(containerType).append("]"); return sb.toString(); } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java index b1324c1..30cf2f4 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java @@ -51,6 +51,7 @@ import org.apache.hadoop.yarn.api.protocolrecords.RegisterApplicationMasterResponse; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerStatus; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.NMToken; import org.apache.hadoop.yarn.api.records.Priority; @@ -250,7 +251,8 @@ public AllocateResponse allocate(float progressIndicator) // RPC layer is using it to send info across askList.add(ResourceRequest.newInstance(r.getPriority(), r.getResourceName(), r.getCapability(), r.getNumContainers(), - r.getRelaxLocality(), r.getNodeLabelExpression())); + r.getRelaxLocality(), r.getContainerType(), + r.getNodeLabelExpression())); } releaseList = new ArrayList(release); // optimistically clear this collection assuming no RPC failure diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/MockContainer.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/MockContainer.java index b2ccb61..cec0b08 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/MockContainer.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/MockContainer.java @@ -31,6 +31,7 @@ import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; import org.apache.hadoop.yarn.api.records.ContainerStatus; +import org.apache.hadoop.yarn.api.records.ContainerType; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.event.Dispatcher; import org.apache.hadoop.yarn.factories.RecordFactory; @@ -52,6 +53,7 @@ new HashMap>(); private RecordFactory recordFactory; private final ContainerTokenIdentifier containerTokenIdentifier; + private ContainerType containerType; public MockContainer(ApplicationAttemptId appAttemptId, Dispatcher dispatcher, Configuration conf, String user, @@ -70,6 +72,7 @@ public MockContainer(ApplicationAttemptId appAttemptId, BuilderUtils.newResource(1024, 1), currentTime + 10000, 123, "password".getBytes(), currentTime)); this.state = ContainerState.NEW; + this.containerType = ContainerType.GUARANTEED; } public void setState(ContainerState state) { @@ -140,4 +143,9 @@ public ContainerTokenIdentifier getContainerTokenIdentifier() { public NMContainerStatus getNMContainerStatus() { return null; } + + @Override + public ContainerType getContainerType() { + return this.containerType; + } }