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 java.util.List;
022import java.util.Map;
023
024import org.apache.hadoop.classification.InterfaceAudience.Private;
025import org.apache.hadoop.classification.InterfaceAudience.Public;
026import org.apache.hadoop.classification.InterfaceStability.Stable;
027import org.apache.hadoop.classification.InterfaceStability.Unstable;
028import org.apache.hadoop.yarn.api.ContainerManagementProtocol;
029import org.apache.hadoop.yarn.api.records.ContainerId;
030import org.apache.hadoop.yarn.api.records.ContainerStatus;
031import org.apache.hadoop.yarn.api.records.SerializedException;
032import org.apache.hadoop.yarn.util.Records;
033
034/**
035 * <p>
036 * The response sent by the <code>NodeManager</code> to the
037 * <code>ApplicationMaster</code> when asked to obtain the
038 * <code>ContainerStatus</code> of requested containers.
039 * </p>
040 * 
041 * @see ContainerManagementProtocol#getContainerStatuses(GetContainerStatusesRequest)
042 */
043@Public
044@Stable
045public abstract class GetContainerStatusesResponse {
046
047  @Private
048  @Unstable
049  public static GetContainerStatusesResponse newInstance(
050      List<ContainerStatus> statuses,
051      Map<ContainerId, SerializedException> failedRequests) {
052    GetContainerStatusesResponse response =
053        Records.newRecord(GetContainerStatusesResponse.class);
054    response.setContainerStatuses(statuses);
055    response.setFailedRequests(failedRequests);
056    return response;
057  }
058
059  /**
060   * Get the <code>ContainerStatus</code>es of the requested containers.
061   * 
062   * @return <code>ContainerStatus</code>es of the requested containers.
063   */
064  @Public
065  @Stable
066  public abstract List<ContainerStatus> getContainerStatuses();
067
068  /**
069   * Set the <code>ContainerStatus</code>es of the requested containers.
070   */
071  @Private
072  @Unstable
073  public abstract void setContainerStatuses(List<ContainerStatus> statuses);
074
075  /**
076   * Get the containerId-to-exception map in which the exception indicates error
077   * from per container for failed requests
078   */
079  @Public
080  @Stable
081  public abstract Map<ContainerId, SerializedException> getFailedRequests();
082
083  /**
084   * Set the containerId-to-exception map in which the exception indicates error
085   * from per container for failed requests
086   */
087  @Private
088  @Unstable
089  public abstract void setFailedRequests(
090      Map<ContainerId, SerializedException> failedContainers);
091}