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