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.records;
020
021 import java.util.List;
022
023 import org.apache.hadoop.classification.InterfaceAudience.Private;
024 import org.apache.hadoop.classification.InterfaceAudience.Public;
025 import org.apache.hadoop.classification.InterfaceStability.Stable;
026 import org.apache.hadoop.classification.InterfaceStability.Unstable;
027 import org.apache.hadoop.yarn.api.AMRMProtocol;
028 import org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest;
029
030 /**
031 * <p>The response sent by the <code>ResourceManager</code> the
032 * <code>ApplicationMaster</code> during resource negotiation.</p>
033 *
034 * <p>The response includes:
035 * <ul>
036 * <li>Response ID to track duplicate responses.</li>
037 * <li>
038 * A reboot flag to let the <code>ApplicationMaster</code> know that its
039 * horribly out of sync and needs to reboot.</li>
040 * <li>A list of newly allocated {@link Container}.</li>
041 * <li>A list of completed {@link Container}.</li>
042 * <li>
043 * The available headroom for resources in the cluster for the
044 * application.
045 * </li>
046 * </ul>
047 * </p>
048 *
049 * @see AMRMProtocol#allocate(AllocateRequest)
050 */
051 @Public
052 @Unstable
053 public interface AMResponse {
054 /**
055 * Should the <code>ApplicationMaster</code> reboot for being horribly
056 * out-of-sync with the <code>ResourceManager</code> as deigned by
057 * {@link #getResponseId()}?
058 *
059 * @return <code>true</code> if the <code>ApplicationMaster</code> should
060 * reboot, <code>false</code> otherwise
061 */
062 @Public
063 @Stable
064 public boolean getReboot();
065
066 @Private
067 @Unstable
068 public void setReboot(boolean reboot);
069
070 /**
071 * Get the <em>last response id</em>.
072 * @return <em>last response id</em>
073 */
074 @Public
075 @Stable
076 public int getResponseId();
077
078 @Private
079 @Unstable
080 public void setResponseId(int responseId);
081
082 /**
083 * Get the list of <em>newly allocated</em> <code>Container</code> by the
084 * <code>ResourceManager</code>.
085 * @return list of <em>newly allocated</em> <code>Container</code>
086 */
087 @Public
088 @Stable
089 public List<Container> getAllocatedContainers();
090
091 /**
092 * Set the list of <em>newly allocated</em> <code>Container</code> by the
093 * <code>ResourceManager</code>.
094 * @param containers list of <em>newly allocated</em> <code>Container</code>
095 */
096 @Public
097 @Stable
098 public void setAllocatedContainers(List<Container> containers);
099
100 /**
101 * Get the <em>available headroom</em> for resources in the cluster for the
102 * application.
103 * @return limit of available headroom for resources in the cluster for the
104 * application
105 */
106 @Public
107 @Stable
108 public Resource getAvailableResources();
109
110 @Private
111 @Unstable
112 public void setAvailableResources(Resource limit);
113
114 /**
115 * Get the list of <em>completed containers' statuses</em>.
116 * @return the list of <em>completed containers' statuses</em>
117 */
118 @Public
119 @Stable
120 public List<ContainerStatus> getCompletedContainersStatuses();
121
122 @Private
123 @Unstable
124 public void setCompletedContainersStatuses(List<ContainerStatus> containers);
125 }