001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.apache.hadoop.yarn.api.protocolrecords;
020
021import org.apache.hadoop.classification.InterfaceAudience.Public;
022import org.apache.hadoop.classification.InterfaceAudience.Private;
023import org.apache.hadoop.classification.InterfaceStability.Unstable;
024import org.apache.hadoop.yarn.api.ContainerManagementProtocol;
025import org.apache.hadoop.yarn.api.records.ContainerId;
026import org.apache.hadoop.yarn.api.records.SerializedException;
027import org.apache.hadoop.yarn.util.Records;
028
029import java.util.List;
030import java.util.Map;
031
032/**
033 * <p>
034 * The response sent by the <code>NodeManager</code> to the
035 * <code>ApplicationMaster</code> when asked to increase container resource.
036 * </p>
037 *
038 * @see ContainerManagementProtocol#increaseContainersResource(IncreaseContainersResourceRequest)
039 */
040@Public
041@Unstable
042public abstract class IncreaseContainersResourceResponse {
043
044  @Private
045  @Unstable
046  public static IncreaseContainersResourceResponse newInstance(
047      List<ContainerId> successfullyIncreasedContainers,
048      Map<ContainerId, SerializedException> failedRequests) {
049    IncreaseContainersResourceResponse response =
050        Records.newRecord(IncreaseContainersResourceResponse.class);
051    response.setSuccessfullyIncreasedContainers(
052        successfullyIncreasedContainers);
053    response.setFailedRequests(failedRequests);
054    return response;
055  }
056
057  /**
058   * Get the list of containerIds of containers whose resource
059   * have been successfully increased.
060   *
061   * @return the list of containerIds of containers whose resource have
062   * been successfully increased.
063   */
064  @Public
065  @Unstable
066  public abstract List<ContainerId> getSuccessfullyIncreasedContainers();
067
068  /**
069   * Set the list of containerIds of containers whose resource have
070   * been successfully increased.
071   */
072  @Private
073  @Unstable
074  public abstract void setSuccessfullyIncreasedContainers(
075      List<ContainerId> succeedIncreasedContainers);
076
077  /**
078   * Get the containerId-to-exception map in which the exception indicates
079   * error from each container for failed requests.
080   */
081  @Public
082  @Unstable
083  public abstract Map<ContainerId, SerializedException> getFailedRequests();
084
085  /**
086   * Set the containerId-to-exception map in which the exception indicates
087   * error from each container for failed requests.
088   */
089  @Private
090  @Unstable
091  public abstract void setFailedRequests(
092      Map<ContainerId, SerializedException> failedRequests);
093}