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    
019    package org.apache.hadoop.yarn.api.protocolrecords;
020    
021    import java.nio.ByteBuffer;
022    import java.util.List;
023    import java.util.Map;
024    
025    import org.apache.hadoop.classification.InterfaceAudience.Private;
026    import org.apache.hadoop.classification.InterfaceAudience.Public;
027    import org.apache.hadoop.classification.InterfaceStability.Stable;
028    import org.apache.hadoop.classification.InterfaceStability.Unstable;
029    import org.apache.hadoop.yarn.api.ContainerManagementProtocol;
030    import org.apache.hadoop.yarn.api.records.ContainerId;
031    import org.apache.hadoop.yarn.api.records.SerializedException;
032    import 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
045    public 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       */
082      @Public
083      @Stable
084      public abstract Map<ContainerId, SerializedException> getFailedRequests();
085    
086      /**
087       * Set the containerId-to-exception map in which the exception indicates error
088       * from per container for failed requests
089       */
090      @Private
091      @Unstable
092      public abstract void setFailedRequests(
093          Map<ContainerId, SerializedException> failedContainers);
094    
095      /**
096       * <p>
097       * Get the meta-data from all auxiliary services running on the
098       * <code>NodeManager</code>.
099       * </p>
100       * <p>
101       * The meta-data is returned as a Map between the auxiliary service names and
102       * their corresponding per service meta-data as an opaque blob
103       * <code>ByteBuffer</code>
104       * </p>
105       * 
106       * <p>
107       * To be able to interpret the per-service meta-data, you should consult the
108       * documentation for the Auxiliary-service configured on the NodeManager
109       * </p>
110       * 
111       * @return a Map between the names of auxiliary services and their
112       *         corresponding meta-data
113       */
114      @Public
115      @Stable
116      public abstract Map<String, ByteBuffer> getAllServicesMetaData();
117    
118      /**
119       * Set to the list of auxiliary services which have been started on the
120       * <code>NodeManager</code>. This is done only once when the
121       * <code>NodeManager</code> starts up
122       * 
123       * @param allServicesMetaData
124       *          A map from auxiliary service names to the opaque blob
125       *          <code>ByteBuffer</code> for that auxiliary service
126       */
127      @Private
128      @Unstable
129      public abstract void setAllServicesMetaData(
130          Map<String, ByteBuffer> allServicesMetaData);
131    }