diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/local/TestLocalContainerAllocator.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/local/TestLocalContainerAllocator.java index f901ed8f100..167d804dee3 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/local/TestLocalContainerAllocator.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/local/TestLocalContainerAllocator.java @@ -46,8 +46,6 @@ import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.Container; -import org.apache.hadoop.yarn.api.records.ContainerResourceDecrease; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncrease; import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.NMToken; import org.apache.hadoop.yarn.api.records.NodeReport; @@ -254,8 +252,8 @@ public AllocateResponse allocate(AllocateRequest request) Resources.none(), null, 1, null, Collections.emptyList(), yarnToken, - Collections.emptyList(), - Collections.emptyList()); + Collections.emptyList(), + Collections.emptyList()); } } } diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index e461fe39807..7e4edceef69 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -200,6 +200,9 @@ Release 2.8.0 - UNRELEASED YARN-3212. RMNode State Transition Update with DECOMMISSIONING state. (Junping Du via wangda) + YARN-3866. AM-RM protocol changes to support container resizing. (Meng Ding + via jianhe) + IMPROVEMENTS YARN-644. Basic null check is not performed on passed in arguments before diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/AllocateRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/AllocateRequest.java index 2458d9ba431..0b65e5ca3b6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/AllocateRequest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/AllocateRequest.java @@ -22,11 +22,12 @@ import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Stable; +import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.yarn.api.ApplicationMasterProtocol; import org.apache.hadoop.yarn.api.records.Container; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncreaseRequest; +import org.apache.hadoop.yarn.api.records.ContainerResourceChangeRequest; import org.apache.hadoop.yarn.api.records.ResourceRequest; import org.apache.hadoop.yarn.util.Records; @@ -46,6 +47,16 @@ *
  • * A list of unused {@link Container} which are being returned. *
  • + *
  • + * A list of {@link ContainerResourceChangeRequest} to inform + * the ResourceManager about the resource increase + * requirements of running containers. + *
  • + *
  • + * A list of {@link ContainerResourceChangeRequest} to inform + * the ResourceManager about the resource decrease + * requirements of running containers. + *
  • * * * @see ApplicationMasterProtocol#allocate(AllocateRequest) @@ -61,7 +72,7 @@ public static AllocateRequest newInstance(int responseID, float appProgress, List containersToBeReleased, ResourceBlacklistRequest resourceBlacklistRequest) { return newInstance(responseID, appProgress, resourceAsk, - containersToBeReleased, resourceBlacklistRequest, null); + containersToBeReleased, resourceBlacklistRequest, null, null); } @Public @@ -70,7 +81,8 @@ public static AllocateRequest newInstance(int responseID, float appProgress, List resourceAsk, List containersToBeReleased, ResourceBlacklistRequest resourceBlacklistRequest, - List increaseRequests) { + List increaseRequests, + List decreaseRequests) { AllocateRequest allocateRequest = Records.newRecord(AllocateRequest.class); allocateRequest.setResponseId(responseID); allocateRequest.setProgress(appProgress); @@ -78,6 +90,7 @@ public static AllocateRequest newInstance(int responseID, float appProgress, allocateRequest.setReleaseList(containersToBeReleased); allocateRequest.setResourceBlacklistRequest(resourceBlacklistRequest); allocateRequest.setIncreaseRequests(increaseRequests); + allocateRequest.setDecreaseRequests(decreaseRequests); return allocateRequest; } @@ -184,20 +197,38 @@ public abstract void setResourceBlacklistRequest( ResourceBlacklistRequest resourceBlacklistRequest); /** - * Get the ContainerResourceIncreaseRequest being sent by the - * ApplicationMaster + * Get the list of container resource increase requests being sent by the + * ApplicationMaster. */ @Public - @Stable - public abstract List getIncreaseRequests(); - + @Unstable + public abstract List getIncreaseRequests(); + /** - * Set the ContainerResourceIncreaseRequest to inform the - * ResourceManager about some container's resources need to be - * increased + * Set the list of container resource increase requests to inform the + * ResourceManager about the containers whose resources need + * to be increased. */ @Public - @Stable + @Unstable public abstract void setIncreaseRequests( - List increaseRequests); + List increaseRequests); + + /** + * Get the list of container resource decrease requests being sent by the + * ApplicationMaster. + */ + @Public + @Unstable + public abstract List getDecreaseRequests(); + + /** + * Set the list of container resource decrease requests to inform the + * ResourceManager about the containers whose resources need + * to be decreased. + */ + @Public + @Unstable + public abstract void setDecreaseRequests( + List decreaseRequests); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/AllocateResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/AllocateResponse.java index c4fdb79f4e1..c3630704c50 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/AllocateResponse.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/AllocateResponse.java @@ -28,8 +28,6 @@ import org.apache.hadoop.yarn.api.ApplicationMasterProtocol; import org.apache.hadoop.yarn.api.records.AMCommand; import org.apache.hadoop.yarn.api.records.Container; -import org.apache.hadoop.yarn.api.records.ContainerResourceDecrease; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncrease; import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.NMToken; import org.apache.hadoop.yarn.api.records.NodeReport; @@ -59,6 +57,14 @@ *
  • The number of available nodes in a cluster.
  • *
  • A description of resources requested back by the cluster
  • *
  • AMRMToken, if AMRMToken has been rolled over
  • + *
  • + * A list of {@link Container} representing the containers + * whose resource has been increased. + *
  • + *
  • + * A list of {@link Container} representing the containers + * whose resource has been decreased. + *
  • * * * @see ApplicationMasterProtocol#allocate(AllocateRequest) @@ -94,8 +100,8 @@ public static AllocateResponse newInstance(int responseId, List allocatedContainers, List updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List nmTokens, - List increasedContainers, - List decreasedContainers) { + List increasedContainers, + List decreasedContainers) { AllocateResponse response = newInstance(responseId, completedContainers, allocatedContainers, updatedNodes, availResources, command, numClusterNodes, preempt, nmTokens); @@ -111,8 +117,8 @@ public static AllocateResponse newInstance(int responseId, List allocatedContainers, List updatedNodes, Resource availResources, AMCommand command, int numClusterNodes, PreemptionMessage preempt, List nmTokens, Token amRMToken, - List increasedContainers, - List decreasedContainers) { + List increasedContainers, + List decreasedContainers) { AllocateResponse response = newInstance(responseId, completedContainers, allocatedContainers, updatedNodes, availResources, command, numClusterNodes, preempt, @@ -263,34 +269,38 @@ public static AllocateResponse newInstance(int responseId, public abstract void setNMTokens(List nmTokens); /** - * Get the list of newly increased containers by ResourceManager + * Get the list of newly increased containers by + * ResourceManager. */ @Public - @Stable - public abstract List getIncreasedContainers(); + @Unstable + public abstract List getIncreasedContainers(); /** - * Set the list of newly increased containers by ResourceManager + * Set the list of newly increased containers by + * ResourceManager. */ @Private @Unstable public abstract void setIncreasedContainers( - List increasedContainers); + List increasedContainers); /** - * Get the list of newly decreased containers by NodeManager + * Get the list of newly decreased containers by + * ResourceManager. */ @Public - @Stable - public abstract List getDecreasedContainers(); + @Unstable + public abstract List getDecreasedContainers(); /** - * Set the list of newly decreased containers by NodeManager + * Set the list of newly decreased containers by + * ResourceManager. */ @Private @Unstable public abstract void setDecreasedContainers( - List decreasedContainers); + List decreasedContainers); /** * The AMRMToken that belong to this attempt diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceIncreaseRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceChangeRequest.java similarity index 55% rename from hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceIncreaseRequest.java rename to hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceChangeRequest.java index 9e3b64044cf..117015b868b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceIncreaseRequest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceChangeRequest.java @@ -19,59 +19,96 @@ package org.apache.hadoop.yarn.api.records; import org.apache.hadoop.classification.InterfaceAudience.Public; +import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.yarn.api.ApplicationMasterProtocol; import org.apache.hadoop.yarn.util.Records; /** - * Used by Application Master, send a container resource increase request to - * Resource Manager + * {@code ContainerResourceChangeRequest} represents the request made by an + * application to the {@code ResourceManager} to change resource allocation of + * a running {@code Container}. + *

    + * It includes: + *

      + *
    • {@link ContainerId} for the container.
    • + *
    • + * {@link Resource} capability of the container after the resource change + * is completed. + *
    • + *
    + * + * @see ApplicationMasterProtocol#allocate(org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest) */ @Public -public abstract class ContainerResourceIncreaseRequest { +@Unstable +public abstract class ContainerResourceChangeRequest { + @Public - public static ContainerResourceIncreaseRequest newInstance( + @Unstable + public static ContainerResourceChangeRequest newInstance( ContainerId existingContainerId, Resource targetCapability) { - ContainerResourceIncreaseRequest context = Records - .newRecord(ContainerResourceIncreaseRequest.class); + ContainerResourceChangeRequest context = Records + .newRecord(ContainerResourceChangeRequest.class); context.setContainerId(existingContainerId); context.setCapability(targetCapability); return context; } + /** + * Get the ContainerId of the container. + * @return ContainerId of the container + */ @Public + @Unstable public abstract ContainerId getContainerId(); + /** + * Set the ContainerId of the container. + * @param containerId ContainerId of the container + */ @Public + @Unstable public abstract void setContainerId(ContainerId containerId); + /** + * Get the Resource capability of the container. + * @return Resource capability of the container + */ @Public + @Unstable public abstract Resource getCapability(); + /** + * Set the Resource capability of the container. + * @param capability Resource capability of the container + */ @Public + @Unstable public abstract void setCapability(Resource capability); @Override public int hashCode() { return getCapability().hashCode() + getContainerId().hashCode(); } - + @Override public boolean equals(Object other) { - if (other instanceof ContainerResourceIncreaseRequest) { - ContainerResourceIncreaseRequest ctx = - (ContainerResourceIncreaseRequest) other; - + if (other instanceof ContainerResourceChangeRequest) { + ContainerResourceChangeRequest ctx = + (ContainerResourceChangeRequest) other; + if (getContainerId() == null && ctx.getContainerId() != null) { return false; } else if (!getContainerId().equals(ctx.getContainerId())) { return false; } - + if (getCapability() == null && ctx.getCapability() != null) { return false; } else if (!getCapability().equals(ctx.getCapability())) { return false; } - + return true; } else { return false; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceDecrease.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceDecrease.java deleted file mode 100644 index d766d922d7d..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceDecrease.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.hadoop.yarn.api.records; - -import org.apache.hadoop.classification.InterfaceAudience.Public; -import org.apache.hadoop.yarn.util.Records; - -/** - * Used by Application Master to ask Node Manager reduce size of a specified - * container - */ -public abstract class ContainerResourceDecrease { - @Public - public static ContainerResourceDecrease newInstance( - ContainerId existingContainerId, Resource targetCapability) { - ContainerResourceDecrease context = Records - .newRecord(ContainerResourceDecrease.class); - context.setContainerId(existingContainerId); - context.setCapability(targetCapability); - return context; - } - - @Public - public abstract ContainerId getContainerId(); - - @Public - public abstract void setContainerId(ContainerId containerId); - - @Public - public abstract Resource getCapability(); - - @Public - public abstract void setCapability(Resource capability); - - @Override - public int hashCode() { - return getCapability().hashCode() + getContainerId().hashCode(); - } - - @Override - public boolean equals(Object other) { - if (other instanceof ContainerResourceDecrease) { - ContainerResourceDecrease ctx = (ContainerResourceDecrease)other; - - if (getContainerId() == null && ctx.getContainerId() != null) { - return false; - } else if (!getContainerId().equals(ctx.getContainerId())) { - return false; - } - - if (getCapability() == null && ctx.getCapability() != null) { - return false; - } else if (!getCapability().equals(ctx.getCapability())) { - return false; - } - - return true; - } else { - return false; - } - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceIncrease.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceIncrease.java deleted file mode 100644 index f4c15605cb8..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerResourceIncrease.java +++ /dev/null @@ -1,84 +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.hadoop.yarn.api.records; - -import org.apache.hadoop.classification.InterfaceAudience.Public; -import org.apache.hadoop.yarn.util.Records; - -/** - * Represent a new increased container accepted by Resource Manager - */ -public abstract class ContainerResourceIncrease { - @Public - public static ContainerResourceIncrease newInstance( - ContainerId existingContainerId, Resource targetCapability, Token token) { - ContainerResourceIncrease context = Records - .newRecord(ContainerResourceIncrease.class); - context.setContainerId(existingContainerId); - context.setCapability(targetCapability); - context.setContainerToken(token); - return context; - } - - @Public - public abstract ContainerId getContainerId(); - - @Public - public abstract void setContainerId(ContainerId containerId); - - @Public - public abstract Resource getCapability(); - - @Public - public abstract void setCapability(Resource capability); - - @Public - public abstract Token getContainerToken(); - - @Public - public abstract void setContainerToken(Token token); - - @Override - public int hashCode() { - return getCapability().hashCode() + getContainerId().hashCode(); - } - - @Override - public boolean equals(Object other) { - if (other instanceof ContainerResourceIncrease) { - ContainerResourceIncrease ctx = (ContainerResourceIncrease)other; - - if (getContainerId() == null && ctx.getContainerId() != null) { - return false; - } else if (!getContainerId().equals(ctx.getContainerId())) { - return false; - } - - if (getCapability() == null && ctx.getCapability() != null) { - return false; - } else if (!getCapability().equals(ctx.getCapability())) { - return false; - } - - return true; - } else { - return false; - } - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerStatus.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerStatus.java index 5ccf6dceb6b..2c2238fa842 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerStatus.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerStatus.java @@ -34,6 +34,7 @@ *
  • {@code ContainerState} of the container.
  • *
  • Exit status of a completed container.
  • *
  • Diagnostic message for a failed container.
  • + *
  • {@link Resource} allocated to the container.
  • * */ @Public @@ -114,4 +115,16 @@ public static ContainerStatus newInstance(ContainerId containerId, @Private @Unstable public abstract void setDiagnostics(String diagnostics); + + /** + * Get the Resource allocated to the container. + * @return Resource allocated to the container + */ + @Public + @Unstable + public abstract Resource getCapability(); + + @Private + @Unstable + public abstract void setCapability(Resource capability); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto index 0bccfc41725..057aeee1ca7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto @@ -470,6 +470,7 @@ message ContainerStatusProto { optional ContainerStateProto state = 2; optional string diagnostics = 3 [default = "N/A"]; optional int32 exit_status = 4 [default = -1000]; + optional ResourceProto capability = 5; } enum ContainerExitStatusProto { @@ -479,22 +480,11 @@ enum ContainerExitStatusProto { DISKS_FAILED = -101; } -message ContainerResourceIncreaseRequestProto { +message ContainerResourceChangeRequestProto { optional ContainerIdProto container_id = 1; optional ResourceProto capability = 2; } -message ContainerResourceIncreaseProto { - optional ContainerIdProto container_id = 1; - optional ResourceProto capability = 2; - optional hadoop.common.TokenProto container_token = 3; -} - -message ContainerResourceDecreaseProto { - optional ContainerIdProto container_id = 1; - optional ResourceProto capability = 2; -} - //////////////////////////////////////////////////////////////////////// ////// From common////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto index b0b12d1df12..ff5a12787ad 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto @@ -66,7 +66,8 @@ message AllocateRequestProto { optional ResourceBlacklistRequestProto blacklist_request = 3; optional int32 response_id = 4; optional float progress = 5; - repeated ContainerResourceIncreaseRequestProto increase_request = 6; + repeated ContainerResourceChangeRequestProto increase_request = 6; + repeated ContainerResourceChangeRequestProto decrease_request = 7; } message NMTokenProto { @@ -84,8 +85,8 @@ message AllocateResponseProto { optional int32 num_cluster_nodes = 7; optional PreemptionMessageProto preempt = 8; repeated NMTokenProto nm_tokens = 9; - repeated ContainerResourceIncreaseProto increased_containers = 10; - repeated ContainerResourceDecreaseProto decreased_containers = 11; + repeated ContainerProto increased_containers = 10; + repeated ContainerProto decreased_containers = 11; optional hadoop.common.TokenProto am_rm_token = 12; } @@ -286,6 +287,15 @@ message GetContainerStatusesResponseProto { repeated ContainerExceptionMapProto failed_requests = 2; } +message IncreaseContainersResourceRequestProto { + repeated hadoop.common.TokenProto increase_containers = 1; +} + +message IncreaseContainersResourceResponseProto { + repeated ContainerIdProto succeeded_requests = 1; + repeated ContainerExceptionMapProto failed_requests = 2; +} + ////////////////////////////////////////////////////// /////// Application_History_Protocol ///////////////// ////////////////////////////////////////////////////// diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java index dc11165f6a8..d6db32c0984 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateRequestPBImpl.java @@ -27,15 +27,15 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest; import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncreaseRequest; +import org.apache.hadoop.yarn.api.records.ContainerResourceChangeRequest; import org.apache.hadoop.yarn.api.records.ResourceBlacklistRequest; import org.apache.hadoop.yarn.api.records.ResourceRequest; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerIdPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceIncreaseRequestPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceChangeRequestPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ResourceBlacklistRequestPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ResourceRequestPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseRequestProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceChangeRequestProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceBlacklistRequestProto; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceRequestProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateRequestProto; @@ -52,7 +52,8 @@ public class AllocateRequestPBImpl extends AllocateRequest { private List ask = null; private List release = null; - private List increaseRequests = null; + private List increaseRequests = null; + private List decreaseRequests = null; private ResourceBlacklistRequest blacklistRequest = null; public AllocateRequestPBImpl() { @@ -101,6 +102,9 @@ private void mergeLocalToBuilder() { if (this.increaseRequests != null) { addIncreaseRequestsToProto(); } + if (this.decreaseRequests != null) { + addDecreaseRequestsToProto(); + } if (this.blacklistRequest != null) { builder.setBlacklistRequest(convertToProtoFormat(this.blacklistRequest)); } @@ -162,14 +166,14 @@ public void setAskList(final List resourceRequests) { } @Override - public List getIncreaseRequests() { + public List getIncreaseRequests() { initIncreaseRequests(); return this.increaseRequests; } @Override public void setIncreaseRequests( - List increaseRequests) { + List increaseRequests) { if (increaseRequests == null) { return; } @@ -177,7 +181,24 @@ public void setIncreaseRequests( this.increaseRequests.clear(); this.increaseRequests.addAll(increaseRequests); } - + + @Override + public List getDecreaseRequests() { + initDecreaseRequests(); + return this.decreaseRequests; + } + + @Override + public void setDecreaseRequests( + List decreaseRequests) { + if (decreaseRequests == null) { + return; + } + initDecreaseRequests(); + this.decreaseRequests.clear(); + this.decreaseRequests.addAll(decreaseRequests); + } + @Override public ResourceBlacklistRequest getResourceBlacklistRequest() { AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; @@ -252,28 +273,42 @@ private void initIncreaseRequests() { return; } AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; - List list = + List list = p.getIncreaseRequestList(); - this.increaseRequests = new ArrayList(); + this.increaseRequests = new ArrayList(); - for (ContainerResourceIncreaseRequestProto c : list) { + for (ContainerResourceChangeRequestProto c : list) { this.increaseRequests.add(convertFromProtoFormat(c)); } } - + + private void initDecreaseRequests() { + if (this.decreaseRequests != null) { + return; + } + AllocateRequestProtoOrBuilder p = viaProto ? proto : builder; + List list = + p.getDecreaseRequestList(); + this.decreaseRequests = new ArrayList<>(); + + for (ContainerResourceChangeRequestProto c : list) { + this.decreaseRequests.add(convertFromProtoFormat(c)); + } + } + private void addIncreaseRequestsToProto() { maybeInitBuilder(); builder.clearIncreaseRequest(); if (increaseRequests == null) { return; } - Iterable iterable = - new Iterable() { + Iterable iterable = + new Iterable() { @Override - public Iterator iterator() { - return new Iterator() { + public Iterator iterator() { + return new Iterator() { - Iterator iter = + Iterator iter = increaseRequests.iterator(); @Override @@ -282,7 +317,7 @@ public boolean hasNext() { } @Override - public ContainerResourceIncreaseRequestProto next() { + public ContainerResourceChangeRequestProto next() { return convertToProtoFormat(iter.next()); } @@ -296,7 +331,43 @@ public void remove() { }; builder.addAllIncreaseRequest(iterable); } - + + private void addDecreaseRequestsToProto() { + maybeInitBuilder(); + builder.clearDecreaseRequest(); + if (decreaseRequests == null) { + return; + } + Iterable iterable = + new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + + Iterator iter = + decreaseRequests.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public ContainerResourceChangeRequestProto next() { + return convertToProtoFormat(iter.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + }; + + } + }; + builder.addAllDecreaseRequest(iterable); + } + @Override public List getReleaseList() { initReleases(); @@ -367,14 +438,14 @@ private ResourceRequestProto convertToProtoFormat(ResourceRequest t) { return ((ResourceRequestPBImpl)t).getProto(); } - private ContainerResourceIncreaseRequestPBImpl convertFromProtoFormat( - ContainerResourceIncreaseRequestProto p) { - return new ContainerResourceIncreaseRequestPBImpl(p); + private ContainerResourceChangeRequestPBImpl convertFromProtoFormat( + ContainerResourceChangeRequestProto p) { + return new ContainerResourceChangeRequestPBImpl(p); } - private ContainerResourceIncreaseRequestProto convertToProtoFormat( - ContainerResourceIncreaseRequest t) { - return ((ContainerResourceIncreaseRequestPBImpl) t).getProto(); + private ContainerResourceChangeRequestProto convertToProtoFormat( + ContainerResourceChangeRequest t) { + return ((ContainerResourceChangeRequestPBImpl) t).getProto(); } private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java index f2796fd788c..dd7d1a9ede6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/AllocateResponsePBImpl.java @@ -29,8 +29,6 @@ import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; import org.apache.hadoop.yarn.api.records.AMCommand; import org.apache.hadoop.yarn.api.records.Container; -import org.apache.hadoop.yarn.api.records.ContainerResourceDecrease; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncrease; import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.NMToken; import org.apache.hadoop.yarn.api.records.NodeReport; @@ -38,8 +36,6 @@ import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.Token; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceDecreasePBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceIncreasePBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerStatusPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.NMTokenPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.NodeReportPBImpl; @@ -48,8 +44,6 @@ import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.TokenPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceDecreaseProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProto; import org.apache.hadoop.yarn.proto.YarnProtos.PreemptionMessageProto; @@ -72,8 +66,8 @@ public class AllocateResponsePBImpl extends AllocateResponse { private List allocatedContainers = null; private List nmTokens = null; private List completedContainersStatuses = null; - private List increasedContainers = null; - private List decreasedContainers = null; + private List increasedContainers = null; + private List decreasedContainers = null; private List updatedNodes = null; private PreemptionMessage preempt; @@ -147,14 +141,14 @@ private synchronized void mergeLocalToBuilder() { } if (this.increasedContainers != null) { builder.clearIncreasedContainers(); - Iterable iterable = - getIncreaseProtoIterable(this.increasedContainers); + Iterable iterable = + getContainerProtoIterable(this.increasedContainers); builder.addAllIncreasedContainers(iterable); } if (this.decreasedContainers != null) { builder.clearDecreasedContainers(); - Iterable iterable = - getChangeProtoIterable(this.decreasedContainers); + Iterable iterable = + getContainerProtoIterable(this.decreasedContainers); builder.addAllDecreasedContainers(iterable); } if (this.amrmToken != null) { @@ -262,6 +256,36 @@ public synchronized void setAllocatedContainers( allocatedContainers.addAll(containers); } + @Override + public synchronized List getIncreasedContainers() { + initLocalIncreasedContainerList(); + return this.increasedContainers; + } + + @Override + public synchronized void setIncreasedContainers( + final List containers) { + if (containers == null) + return; + initLocalIncreasedContainerList(); + increasedContainers.addAll(containers); + } + + @Override + public synchronized List getDecreasedContainers() { + initLocalDecreasedContainerList(); + return this.decreasedContainers; + } + + @Override + public synchronized void setDecreasedContainers( + final List containers) { + if (containers == null) + return; + initLocalDecreasedContainerList(); + decreasedContainers.addAll(containers); + } + //// Finished containers @Override public synchronized List getCompletedContainersStatuses() { @@ -332,37 +356,6 @@ public synchronized void setPreemptionMessage(PreemptionMessage preempt) { this.preempt = preempt; } - @Override - public synchronized List getIncreasedContainers() { - initLocalIncreasedContainerList(); - return increasedContainers; - } - - @Override - public synchronized void setIncreasedContainers( - List increasedContainers) { - if (increasedContainers == null) - return; - initLocalIncreasedContainerList(); - this.increasedContainers.addAll(increasedContainers); - } - - @Override - public synchronized List getDecreasedContainers() { - initLocalDecreasedContainerList(); - return decreasedContainers; - } - - @Override - public synchronized void setDecreasedContainers( - List decreasedContainers) { - if (decreasedContainers == null) { - return; - } - initLocalDecreasedContainerList(); - this.decreasedContainers.addAll(decreasedContainers); - } - @Override public synchronized Token getAMRMToken() { AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; @@ -390,10 +383,10 @@ private synchronized void initLocalIncreasedContainerList() { return; } AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getIncreasedContainersList(); - increasedContainers = new ArrayList(); + List list = p.getIncreasedContainersList(); + increasedContainers = new ArrayList<>(); - for (ContainerResourceIncreaseProto c : list) { + for (ContainerProto c : list) { increasedContainers.add(convertFromProtoFormat(c)); } } @@ -403,10 +396,10 @@ private synchronized void initLocalDecreasedContainerList() { return; } AllocateResponseProtoOrBuilder p = viaProto ? proto : builder; - List list = p.getDecreasedContainersList(); - decreasedContainers = new ArrayList(); + List list = p.getDecreasedContainersList(); + decreasedContainers = new ArrayList<>(); - for (ContainerResourceDecreaseProto c : list) { + for (ContainerProto c : list) { decreasedContainers.add(convertFromProtoFormat(c)); } } @@ -453,70 +446,6 @@ private synchronized void initLocalNewNMTokenList() { } } - private synchronized Iterable - getIncreaseProtoIterable( - final List newContainersList) { - maybeInitBuilder(); - return new Iterable() { - @Override - public synchronized Iterator iterator() { - return new Iterator() { - - Iterator iter = newContainersList - .iterator(); - - @Override - public synchronized boolean hasNext() { - return iter.hasNext(); - } - - @Override - public synchronized ContainerResourceIncreaseProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public synchronized void remove() { - throw new UnsupportedOperationException(); - } - }; - - } - }; - } - - private synchronized Iterable - getChangeProtoIterable( - final List newContainersList) { - maybeInitBuilder(); - return new Iterable() { - @Override - public synchronized Iterator iterator() { - return new Iterator() { - - Iterator iter = newContainersList - .iterator(); - - @Override - public synchronized boolean hasNext() { - return iter.hasNext(); - } - - @Override - public synchronized ContainerResourceDecreaseProto next() { - return convertToProtoFormat(iter.next()); - } - - @Override - public synchronized void remove() { - throw new UnsupportedOperationException(); - } - }; - - } - }; - } - private synchronized Iterable getContainerProtoIterable( final List newContainersList) { maybeInitBuilder(); @@ -654,26 +583,6 @@ private synchronized void initLocalFinishedContainerList() { completedContainersStatuses.add(convertFromProtoFormat(c)); } } - - private synchronized ContainerResourceIncrease convertFromProtoFormat( - ContainerResourceIncreaseProto p) { - return new ContainerResourceIncreasePBImpl(p); - } - - private synchronized ContainerResourceIncreaseProto convertToProtoFormat( - ContainerResourceIncrease t) { - return ((ContainerResourceIncreasePBImpl) t).getProto(); - } - - private synchronized ContainerResourceDecrease convertFromProtoFormat( - ContainerResourceDecreaseProto p) { - return new ContainerResourceDecreasePBImpl(p); - } - - private synchronized ContainerResourceDecreaseProto convertToProtoFormat( - ContainerResourceDecrease t) { - return ((ContainerResourceDecreasePBImpl) t).getProto(); - } private synchronized NodeReportPBImpl convertFromProtoFormat( NodeReportProto p) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceIncreaseRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceChangeRequestPBImpl.java similarity index 79% rename from hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceIncreaseRequestPBImpl.java rename to hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceChangeRequestPBImpl.java index f5ebf6c0cfe..f382b8c8c62 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceIncreaseRequestPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceChangeRequestPBImpl.java @@ -19,35 +19,35 @@ package org.apache.hadoop.yarn.api.records.impl.pb; import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncreaseRequest; +import org.apache.hadoop.yarn.api.records.ContainerResourceChangeRequest; import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseRequestProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseRequestProtoOrBuilder; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceChangeRequestProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceChangeRequestProtoOrBuilder; import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; -public class ContainerResourceIncreaseRequestPBImpl extends - ContainerResourceIncreaseRequest { - ContainerResourceIncreaseRequestProto proto = - ContainerResourceIncreaseRequestProto.getDefaultInstance(); - ContainerResourceIncreaseRequestProto.Builder builder = null; +public class ContainerResourceChangeRequestPBImpl extends + ContainerResourceChangeRequest { + ContainerResourceChangeRequestProto proto = + ContainerResourceChangeRequestProto.getDefaultInstance(); + ContainerResourceChangeRequestProto.Builder builder = null; boolean viaProto = false; private ContainerId existingContainerId = null; private Resource targetCapability = null; - public ContainerResourceIncreaseRequestPBImpl() { - builder = ContainerResourceIncreaseRequestProto.newBuilder(); + public ContainerResourceChangeRequestPBImpl() { + builder = ContainerResourceChangeRequestProto.newBuilder(); } - public ContainerResourceIncreaseRequestPBImpl( - ContainerResourceIncreaseRequestProto proto) { + public ContainerResourceChangeRequestPBImpl( + ContainerResourceChangeRequestProto proto) { this.proto = proto; viaProto = true; } - public ContainerResourceIncreaseRequestProto getProto() { + public ContainerResourceChangeRequestProto getProto() { mergeLocalToProto(); proto = viaProto ? proto : builder.build(); viaProto = true; @@ -56,7 +56,7 @@ public ContainerResourceIncreaseRequestProto getProto() { @Override public ContainerId getContainerId() { - ContainerResourceIncreaseRequestProtoOrBuilder p = viaProto ? proto + ContainerResourceChangeRequestProtoOrBuilder p = viaProto ? proto : builder; if (this.existingContainerId != null) { return this.existingContainerId; @@ -78,7 +78,7 @@ public void setContainerId(ContainerId existingContainerId) { @Override public Resource getCapability() { - ContainerResourceIncreaseRequestProtoOrBuilder p = viaProto ? proto + ContainerResourceChangeRequestProtoOrBuilder p = viaProto ? proto : builder; if (this.targetCapability != null) { return this.targetCapability; @@ -125,7 +125,7 @@ private void mergeLocalToProto() { private void maybeInitBuilder() { if (viaProto || builder == null) { - builder = ContainerResourceIncreaseRequestProto.newBuilder(proto); + builder = ContainerResourceChangeRequestProto.newBuilder(proto); } viaProto = false; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceDecreasePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceDecreasePBImpl.java deleted file mode 100644 index 1834132f7ab..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceDecreasePBImpl.java +++ /dev/null @@ -1,136 +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.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerResourceDecrease; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceDecreaseProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceDecreaseProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; - -public class ContainerResourceDecreasePBImpl extends ContainerResourceDecrease { - ContainerResourceDecreaseProto proto = ContainerResourceDecreaseProto - .getDefaultInstance(); - ContainerResourceDecreaseProto.Builder builder = null; - boolean viaProto = false; - - private ContainerId existingContainerId = null; - private Resource targetCapability = null; - - public ContainerResourceDecreasePBImpl() { - builder = ContainerResourceDecreaseProto.newBuilder(); - } - - public ContainerResourceDecreasePBImpl(ContainerResourceDecreaseProto proto) { - this.proto = proto; - viaProto = true; - } - - public ContainerResourceDecreaseProto getProto() { - mergeLocalToProto(); - proto = viaProto ? proto : builder.build(); - viaProto = true; - return proto; - } - - @Override - public ContainerId getContainerId() { - ContainerResourceDecreaseProtoOrBuilder p = viaProto ? proto : builder; - if (this.existingContainerId != null) { - return this.existingContainerId; - } - if (p.hasContainerId()) { - this.existingContainerId = convertFromProtoFormat(p.getContainerId()); - } - return this.existingContainerId; - } - - @Override - public void setContainerId(ContainerId existingContainerId) { - maybeInitBuilder(); - if (existingContainerId == null) { - builder.clearContainerId(); - } - this.existingContainerId = existingContainerId; - } - - @Override - public Resource getCapability() { - ContainerResourceDecreaseProtoOrBuilder p = viaProto ? proto : builder; - if (this.targetCapability != null) { - return this.targetCapability; - } - if (p.hasCapability()) { - this.targetCapability = convertFromProtoFormat(p.getCapability()); - } - return this.targetCapability; - } - - @Override - public void setCapability(Resource targetCapability) { - maybeInitBuilder(); - if (targetCapability == null) { - builder.clearCapability(); - } - this.targetCapability = targetCapability; - } - - private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { - return new ContainerIdPBImpl(p); - } - - private ContainerIdProto convertToProtoFormat(ContainerId t) { - return ((ContainerIdPBImpl) t).getProto(); - } - - private Resource convertFromProtoFormat(ResourceProto p) { - return new ResourcePBImpl(p); - } - - private ResourceProto convertToProtoFormat(Resource t) { - return ((ResourcePBImpl) t).getProto(); - } - - private void mergeLocalToProto() { - if (viaProto) { - maybeInitBuilder(); - } - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ContainerResourceDecreaseProto.newBuilder(proto); - } - viaProto = false; - } - - private void mergeLocalToBuilder() { - if (this.existingContainerId != null) { - builder.setContainerId(convertToProtoFormat(this.existingContainerId)); - } - if (this.targetCapability != null) { - builder.setCapability(convertToProtoFormat(this.targetCapability)); - } - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceIncreasePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceIncreasePBImpl.java deleted file mode 100644 index 4e4f3a7f703..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerResourceIncreasePBImpl.java +++ /dev/null @@ -1,171 +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.hadoop.yarn.api.records.impl.pb; - -import org.apache.hadoop.security.proto.SecurityProtos.TokenProto; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncrease; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.api.records.Token; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseProtoOrBuilder; -import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; - -public class ContainerResourceIncreasePBImpl extends ContainerResourceIncrease { - ContainerResourceIncreaseProto proto = ContainerResourceIncreaseProto - .getDefaultInstance(); - ContainerResourceIncreaseProto.Builder builder = null; - boolean viaProto = false; - - private ContainerId existingContainerId = null; - private Resource targetCapability = null; - private Token token = null; - - public ContainerResourceIncreasePBImpl() { - builder = ContainerResourceIncreaseProto.newBuilder(); - } - - public ContainerResourceIncreasePBImpl(ContainerResourceIncreaseProto proto) { - this.proto = proto; - viaProto = true; - } - - public ContainerResourceIncreaseProto getProto() { - mergeLocalToProto(); - proto = viaProto ? proto : builder.build(); - viaProto = true; - return proto; - } - - @Override - public ContainerId getContainerId() { - ContainerResourceIncreaseProtoOrBuilder p = viaProto ? proto : builder; - if (this.existingContainerId != null) { - return this.existingContainerId; - } - if (p.hasContainerId()) { - this.existingContainerId = convertFromProtoFormat(p.getContainerId()); - } - return this.existingContainerId; - } - - @Override - public void setContainerId(ContainerId existingContainerId) { - maybeInitBuilder(); - if (existingContainerId == null) { - builder.clearContainerId(); - } - this.existingContainerId = existingContainerId; - } - - @Override - public Resource getCapability() { - ContainerResourceIncreaseProtoOrBuilder p = viaProto ? proto : builder; - if (this.targetCapability != null) { - return this.targetCapability; - } - if (p.hasCapability()) { - this.targetCapability = convertFromProtoFormat(p.getCapability()); - } - return this.targetCapability; - } - - @Override - public void setCapability(Resource targetCapability) { - maybeInitBuilder(); - if (targetCapability == null) { - builder.clearCapability(); - } - this.targetCapability = targetCapability; - } - - @Override - public Token getContainerToken() { - ContainerResourceIncreaseProtoOrBuilder p = viaProto ? proto : builder; - if (this.token != null) { - return this.token; - } - if (p.hasContainerToken()) { - this.token = convertFromProtoFormat(p.getContainerToken()); - } - return this.token; - } - - @Override - public void setContainerToken(Token token) { - maybeInitBuilder(); - if (token == null) { - builder.clearContainerToken(); - } - this.token = token; - } - - private ContainerIdPBImpl convertFromProtoFormat(ContainerIdProto p) { - return new ContainerIdPBImpl(p); - } - - private ContainerIdProto convertToProtoFormat(ContainerId t) { - return ((ContainerIdPBImpl) t).getProto(); - } - - private Resource convertFromProtoFormat(ResourceProto p) { - return new ResourcePBImpl(p); - } - - private ResourceProto convertToProtoFormat(Resource t) { - return ((ResourcePBImpl) t).getProto(); - } - - private Token convertFromProtoFormat(TokenProto p) { - return new TokenPBImpl(p); - } - - private TokenProto convertToProtoFormat(Token t) { - return ((TokenPBImpl) t).getProto(); - } - - private void mergeLocalToProto() { - if (viaProto) { - maybeInitBuilder(); - } - mergeLocalToBuilder(); - proto = builder.build(); - viaProto = true; - } - - private void maybeInitBuilder() { - if (viaProto || builder == null) { - builder = ContainerResourceIncreaseProto.newBuilder(proto); - } - viaProto = false; - } - - private void mergeLocalToBuilder() { - if (this.existingContainerId != null) { - builder.setContainerId(convertToProtoFormat(this.existingContainerId)); - } - if (this.targetCapability != null) { - builder.setCapability(convertToProtoFormat(this.targetCapability)); - } - if (this.token != null) { - builder.setContainerToken(convertToProtoFormat(this.token)); - } - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java index 86f2af95a19..d33d06dba46 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java @@ -24,6 +24,8 @@ 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.Resource; +import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; @@ -78,6 +80,7 @@ public String toString() { sb.append("ContainerStatus: ["); sb.append("ContainerId: ").append(getContainerId()).append(", "); sb.append("State: ").append(getState()).append(", "); + sb.append("Capability: ").append(getCapability()).append(", "); sb.append("Diagnostics: ").append(getDiagnostics()).append(", "); sb.append("ExitStatus: ").append(getExitStatus()).append(", "); sb.append("]"); @@ -168,6 +171,25 @@ public synchronized void setDiagnostics(String diagnostics) { builder.setDiagnostics(diagnostics); } + @Override + public synchronized Resource getCapability() { + ContainerStatusProtoOrBuilder p = viaProto ? proto : builder; + if (!p.hasCapability()) { + return null; + } + return convertFromProtoFormat(p.getCapability()); + } + + @Override + public synchronized void setCapability(Resource capability) { + maybeInitBuilder(); + if (capability == null) { + builder.clearCapability(); + return; + } + builder.setCapability(convertToProtoFormat(capability)); + } + private ContainerStateProto convertToProtoFormat(ContainerState e) { return ProtoUtils.convertToProtoFormat(e); } @@ -184,6 +206,11 @@ private ContainerIdProto convertToProtoFormat(ContainerId t) { return ((ContainerIdPBImpl)t).getProto(); } + private ResourceProto convertToProtoFormat(Resource e) { + return ((ResourcePBImpl)e).getProto(); + } - -} + private ResourcePBImpl convertFromProtoFormat(ResourceProto p) { + return new ResourcePBImpl(p); + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestAllocateRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestAllocateRequest.java deleted file mode 100644 index 5ea29f8afc6..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestAllocateRequest.java +++ /dev/null @@ -1,73 +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.hadoop.yarn.api; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; - -import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest; -import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateRequestPBImpl; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncreaseRequest; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateRequestProto; -import org.junit.Test; - -public class TestAllocateRequest { - @Test - public void testAllcoateRequestWithIncrease() { - List incRequests = - new ArrayList(); - for (int i = 0; i < 3; i++) { - incRequests.add(ContainerResourceIncreaseRequest.newInstance(null, - Resource.newInstance(0, i))); - } - AllocateRequest r = - AllocateRequest.newInstance(123, 0f, null, null, null, incRequests); - - // serde - AllocateRequestProto p = ((AllocateRequestPBImpl) r).getProto(); - r = new AllocateRequestPBImpl(p); - - // check value - Assert.assertEquals(123, r.getResponseId()); - Assert.assertEquals(incRequests.size(), r.getIncreaseRequests().size()); - - for (int i = 0; i < incRequests.size(); i++) { - Assert.assertEquals(r.getIncreaseRequests().get(i).getCapability() - .getVirtualCores(), incRequests.get(i).getCapability() - .getVirtualCores()); - } - } - - @Test - public void testAllcoateRequestWithoutIncrease() { - AllocateRequest r = - AllocateRequest.newInstance(123, 0f, null, null, null, null); - - // serde - AllocateRequestProto p = ((AllocateRequestPBImpl) r).getProto(); - r = new AllocateRequestPBImpl(p); - - // check value - Assert.assertEquals(123, r.getResponseId()); - Assert.assertEquals(0, r.getIncreaseRequests().size()); - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestAllocateResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestAllocateResponse.java deleted file mode 100644 index fbe9af91891..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestAllocateResponse.java +++ /dev/null @@ -1,114 +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.hadoop.yarn.api; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.hadoop.yarn.api.protocolrecords.AllocateResponse; -import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.AllocateResponsePBImpl; -import org.apache.hadoop.yarn.api.records.AMCommand; -import org.apache.hadoop.yarn.api.records.Container; -import org.apache.hadoop.yarn.api.records.ContainerResourceDecrease; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncrease; -import org.apache.hadoop.yarn.api.records.ContainerStatus; -import org.apache.hadoop.yarn.api.records.NMToken; -import org.apache.hadoop.yarn.api.records.NodeReport; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.proto.YarnServiceProtos.AllocateResponseProto; -import org.junit.Assert; -import org.junit.Test; - -/** - * 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. - */ -public class TestAllocateResponse { - @SuppressWarnings("deprecation") - @Test - public void testAllocateResponseWithIncDecContainers() { - List incContainers = - new ArrayList(); - List decContainers = - new ArrayList(); - for (int i = 0; i < 3; i++) { - incContainers.add(ContainerResourceIncrease.newInstance(null, - Resource.newInstance(1024, i), null)); - } - for (int i = 0; i < 5; i++) { - decContainers.add(ContainerResourceDecrease.newInstance(null, - Resource.newInstance(1024, i))); - } - - AllocateResponse r = - AllocateResponse.newInstance(3, new ArrayList(), - new ArrayList(), new ArrayList(), null, - AMCommand.AM_RESYNC, 3, null, new ArrayList(), - incContainers, decContainers); - - // serde - AllocateResponseProto p = ((AllocateResponsePBImpl) r).getProto(); - r = new AllocateResponsePBImpl(p); - - // check value - Assert - .assertEquals(incContainers.size(), r.getIncreasedContainers().size()); - Assert - .assertEquals(decContainers.size(), r.getDecreasedContainers().size()); - - for (int i = 0; i < incContainers.size(); i++) { - Assert.assertEquals(i, r.getIncreasedContainers().get(i).getCapability() - .getVirtualCores()); - } - - for (int i = 0; i < decContainers.size(); i++) { - Assert.assertEquals(i, r.getDecreasedContainers().get(i).getCapability() - .getVirtualCores()); - } - } - - @SuppressWarnings("deprecation") - @Test - public void testAllocateResponseWithoutIncDecContainers() { - AllocateResponse r = - AllocateResponse.newInstance(3, new ArrayList(), - new ArrayList(), new ArrayList(), null, - AMCommand.AM_RESYNC, 3, null, new ArrayList(), null, null); - - // serde - AllocateResponseProto p = ((AllocateResponsePBImpl) r).getProto(); - r = new AllocateResponsePBImpl(p); - - // check value - Assert.assertEquals(0, r.getIncreasedContainers().size()); - Assert.assertEquals(0, r.getDecreasedContainers().size()); - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceDecrease.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceDecrease.java deleted file mode 100644 index 29b0ffe38f2..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceDecrease.java +++ /dev/null @@ -1,66 +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.hadoop.yarn.api; - -import org.junit.Assert; - -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerResourceDecrease; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceDecreasePBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceDecreaseProto; -import org.junit.Test; - -public class TestContainerResourceDecrease { - @Test - public void testResourceDecreaseContext() { - ContainerId containerId = ContainerId - .newContainerId(ApplicationAttemptId.newInstance( - ApplicationId.newInstance(1234, 3), 3), 7); - Resource resource = Resource.newInstance(1023, 3); - ContainerResourceDecrease ctx = ContainerResourceDecrease.newInstance( - containerId, resource); - - // get proto and recover to ctx - ContainerResourceDecreaseProto proto = - ((ContainerResourceDecreasePBImpl) ctx).getProto(); - ctx = new ContainerResourceDecreasePBImpl(proto); - - // check values - Assert.assertEquals(ctx.getCapability(), resource); - Assert.assertEquals(ctx.getContainerId(), containerId); - } - - @Test - public void testResourceDecreaseContextWithNull() { - ContainerResourceDecrease ctx = ContainerResourceDecrease.newInstance(null, - null); - - // get proto and recover to ctx; - ContainerResourceDecreaseProto proto = - ((ContainerResourceDecreasePBImpl) ctx).getProto(); - ctx = new ContainerResourceDecreasePBImpl(proto); - - // check values - Assert.assertNull(ctx.getCapability()); - Assert.assertNull(ctx.getContainerId()); - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncrease.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncrease.java deleted file mode 100644 index 932d5a7a87c..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncrease.java +++ /dev/null @@ -1,74 +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.hadoop.yarn.api; - -import java.util.Arrays; - -import org.junit.Assert; - -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncrease; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.api.records.Token; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceIncreasePBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseProto; -import org.junit.Test; - -public class TestContainerResourceIncrease { - @Test - public void testResourceIncreaseContext() { - byte[] identifier = new byte[] { 1, 2, 3, 4 }; - Token token = Token.newInstance(identifier, "", "".getBytes(), ""); - ContainerId containerId = ContainerId - .newContainerId(ApplicationAttemptId.newInstance( - ApplicationId.newInstance(1234, 3), 3), 7); - Resource resource = Resource.newInstance(1023, 3); - ContainerResourceIncrease ctx = ContainerResourceIncrease.newInstance( - containerId, resource, token); - - // get proto and recover to ctx - ContainerResourceIncreaseProto proto = - ((ContainerResourceIncreasePBImpl) ctx).getProto(); - ctx = new ContainerResourceIncreasePBImpl(proto); - - // check values - Assert.assertEquals(ctx.getCapability(), resource); - Assert.assertEquals(ctx.getContainerId(), containerId); - Assert.assertTrue(Arrays.equals(ctx.getContainerToken().getIdentifier() - .array(), identifier)); - } - - @Test - public void testResourceIncreaseContextWithNull() { - ContainerResourceIncrease ctx = ContainerResourceIncrease.newInstance(null, - null, null); - - // get proto and recover to ctx; - ContainerResourceIncreaseProto proto = - ((ContainerResourceIncreasePBImpl) ctx).getProto(); - ctx = new ContainerResourceIncreasePBImpl(proto); - - // check values - Assert.assertNull(ctx.getContainerToken()); - Assert.assertNull(ctx.getCapability()); - Assert.assertNull(ctx.getContainerId()); - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncreaseRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncreaseRequest.java deleted file mode 100644 index cf4dabf71be..00000000000 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncreaseRequest.java +++ /dev/null @@ -1,68 +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.hadoop.yarn.api; - -import org.junit.Assert; - -import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ContainerId; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncreaseRequest; -import org.apache.hadoop.yarn.api.records.Resource; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceIncreaseRequestPBImpl; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseRequestProto; -import org.junit.Test; - -public class TestContainerResourceIncreaseRequest { - @Test - public void ContainerResourceIncreaseRequest() { - ContainerId containerId = ContainerId - .newContainerId(ApplicationAttemptId.newInstance( - ApplicationId.newInstance(1234, 3), 3), 7); - Resource resource = Resource.newInstance(1023, 3); - ContainerResourceIncreaseRequest context = ContainerResourceIncreaseRequest - .newInstance(containerId, resource); - - // to proto and get it back - ContainerResourceIncreaseRequestProto proto = - ((ContainerResourceIncreaseRequestPBImpl) context).getProto(); - ContainerResourceIncreaseRequest contextRecover = - new ContainerResourceIncreaseRequestPBImpl(proto); - - // check value - Assert.assertEquals(contextRecover.getContainerId(), containerId); - Assert.assertEquals(contextRecover.getCapability(), resource); - } - - @Test - public void testResourceChangeContextWithNullField() { - ContainerResourceIncreaseRequest context = ContainerResourceIncreaseRequest - .newInstance(null, null); - - // to proto and get it back - ContainerResourceIncreaseRequestProto proto = - ((ContainerResourceIncreaseRequestPBImpl) context).getProto(); - ContainerResourceIncreaseRequest contextRecover = - new ContainerResourceIncreaseRequestPBImpl(proto); - - // check value - Assert.assertNull(contextRecover.getContainerId()); - Assert.assertNull(contextRecover.getCapability()); - } -} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java index 6357c36db90..0979c75a7d8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestPBImplRecords.java @@ -113,9 +113,7 @@ import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerLaunchContext; import org.apache.hadoop.yarn.api.records.ContainerReport; -import org.apache.hadoop.yarn.api.records.ContainerResourceDecrease; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncrease; -import org.apache.hadoop.yarn.api.records.ContainerResourceIncreaseRequest; +import org.apache.hadoop.yarn.api.records.ContainerResourceChangeRequest; import org.apache.hadoop.yarn.api.records.ContainerStatus; import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.api.records.LogAggregationContext; @@ -155,9 +153,7 @@ import org.apache.hadoop.yarn.api.records.impl.pb.ContainerLaunchContextPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerReportPBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceDecreasePBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceIncreasePBImpl; -import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceIncreaseRequestPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.ContainerResourceChangeRequestPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.ContainerStatusPBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.LocalResourcePBImpl; import org.apache.hadoop.yarn.api.records.impl.pb.NMTokenPBImpl; @@ -190,9 +186,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerReportProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceDecreaseProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseProto; -import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceIncreaseRequestProto; +import org.apache.hadoop.yarn.proto.YarnProtos.ContainerResourceChangeRequestProto; import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto; import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; @@ -471,9 +465,7 @@ public static void setup() throws Exception { generateByNewInstance(ContainerLaunchContext.class); generateByNewInstance(ApplicationSubmissionContext.class); generateByNewInstance(ContainerReport.class); - generateByNewInstance(ContainerResourceDecrease.class); - generateByNewInstance(ContainerResourceIncrease.class); - generateByNewInstance(ContainerResourceIncreaseRequest.class); + generateByNewInstance(ContainerResourceChangeRequest.class); generateByNewInstance(ContainerStatus.class); generateByNewInstance(PreemptionContainer.class); generateByNewInstance(PreemptionResourceRequest.class); @@ -959,21 +951,9 @@ public void testContainerReportPBImpl() throws Exception { } @Test - public void testContainerResourceDecreasePBImpl() throws Exception { - validatePBImplRecord(ContainerResourceDecreasePBImpl.class, - ContainerResourceDecreaseProto.class); - } - - @Test - public void testContainerResourceIncreasePBImpl() throws Exception { - validatePBImplRecord(ContainerResourceIncreasePBImpl.class, - ContainerResourceIncreaseProto.class); - } - - @Test - public void testContainerResourceIncreaseRequestPBImpl() throws Exception { - validatePBImplRecord(ContainerResourceIncreaseRequestPBImpl.class, - ContainerResourceIncreaseRequestProto.class); + public void testContainerResourceChangeRequestPBImpl() throws Exception { + validatePBImplRecord(ContainerResourceChangeRequestPBImpl.class, + ContainerResourceChangeRequestProto.class); } @Test