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.nio.ByteBuffer;
022import java.util.List;
023import java.util.Map;
024
025import org.apache.hadoop.classification.InterfaceAudience.Private;
026import org.apache.hadoop.classification.InterfaceAudience.Public;
027import org.apache.hadoop.classification.InterfaceStability.Stable;
028import org.apache.hadoop.classification.InterfaceStability.Unstable;
029import org.apache.hadoop.yarn.api.ContainerManagementProtocol;
030import org.apache.hadoop.yarn.api.records.ContainerId;
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 <em>start</em> an allocated
038 * container.
039 * </p>
040 * 
041 * @see ContainerManagementProtocol#startContainers(StartContainersRequest)
042 */
043@Public
044@Stable
045public abstract class StartContainersResponse {
046
047  @Private
048  @Unstable
049  public static StartContainersResponse newInstance(
050      Map<String, ByteBuffer> servicesMetaData,
051      List<ContainerId> succeededContainers,
052      Map<ContainerId, SerializedException> failedContainers) {
053    StartContainersResponse response =
054        Records.newRecord(StartContainersResponse.class);
055    response.setAllServicesMetaData(servicesMetaData);
056    response.setSuccessfullyStartedContainers(succeededContainers);
057    response.setFailedRequests(failedContainers);
058    return response;
059  }
060
061  /**
062   * Get the list of <code>ContainerId</code> s of the containers that are
063   * started successfully.
064   * 
065   * @return the list of <code>ContainerId</code> s of the containers that are
066   *         started successfully.
067   * @see ContainerManagementProtocol#startContainers(StartContainersRequest)
068   */
069  @Public
070  @Stable
071  public abstract List<ContainerId> getSuccessfullyStartedContainers();
072
073  @Private
074  @Unstable
075  public abstract void setSuccessfullyStartedContainers(
076      List<ContainerId> succeededContainers);
077
078  /**
079   * Get the containerId-to-exception map in which the exception indicates error
080   * from per container for failed requests
081   * @return map of containerId-to-exception
082   */
083  @Public
084  @Stable
085  public abstract Map<ContainerId, SerializedException> getFailedRequests();
086
087  /**
088   * Set the containerId-to-exception map in which the exception indicates error
089   * from per container for failed requests
090   */
091  @Private
092  @Unstable
093  public abstract void setFailedRequests(
094      Map<ContainerId, SerializedException> failedContainers);
095
096  /**
097   * <p>
098   * Get the meta-data from all auxiliary services running on the
099   * <code>NodeManager</code>.
100   * </p>
101   * <p>
102   * The meta-data is returned as a Map between the auxiliary service names and
103   * their corresponding per service meta-data as an opaque blob
104   * <code>ByteBuffer</code>
105   * </p>
106   * 
107   * <p>
108   * To be able to interpret the per-service meta-data, you should consult the
109   * documentation for the Auxiliary-service configured on the NodeManager
110   * </p>
111   * 
112   * @return a Map between the names of auxiliary services and their
113   *         corresponding meta-data
114   */
115  @Public
116  @Stable
117  public abstract Map<String, ByteBuffer> getAllServicesMetaData();
118
119  /**
120   * Set to the list of auxiliary services which have been started on the
121   * <code>NodeManager</code>. This is done only once when the
122   * <code>NodeManager</code> starts up
123   * 
124   * @param allServicesMetaData
125   *          A map from auxiliary service names to the opaque blob
126   *          <code>ByteBuffer</code> for that auxiliary service
127   */
128  @Private
129  @Unstable
130  public abstract void setAllServicesMetaData(
131      Map<String, ByteBuffer> allServicesMetaData);
132}