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 org.apache.hadoop.classification.InterfaceAudience.Private;
022import org.apache.hadoop.classification.InterfaceAudience.Public;
023import org.apache.hadoop.classification.InterfaceStability.Stable;
024import org.apache.hadoop.classification.InterfaceStability.Unstable;
025import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
026import org.apache.hadoop.yarn.util.Records;
027
028/**
029 * The response sent by the <code>ResourceManager</code> to a
030 * <code>ApplicationMaster</code> on it's completion.
031 * <p>
032 * The response, includes:
033 * <ul>
034 * <li>A flag which indicates that the application has successfully unregistered
035 * with the RM and the application can safely stop.</li>
036 * </ul>
037 * <p>
038 * Note: The flag indicates whether the application has successfully
039 * unregistered and is safe to stop. The application may stop after the flag is
040 * true. If the application stops before the flag is true then the RM may retry
041 * the application.
042 * 
043 * @see ApplicationMasterProtocol#finishApplicationMaster(FinishApplicationMasterRequest)
044 */
045@Public
046@Stable
047public abstract class FinishApplicationMasterResponse {
048
049  @Private
050  @Unstable
051  public static FinishApplicationMasterResponse newInstance(
052      boolean isRemovedFromRMStateStore) {
053    FinishApplicationMasterResponse response =
054        Records.newRecord(FinishApplicationMasterResponse.class);
055    response.setIsUnregistered(isRemovedFromRMStateStore);
056    return response;
057  }
058
059  /**
060   * Get the flag which indicates that the application has successfully
061   * unregistered with the RM and the application can safely stop.
062   * @return true if the application has unregistered with the RM,
063   *         false otherwise
064   */
065  @Public
066  @Stable
067  public abstract boolean getIsUnregistered();
068
069  /**
070   * Set the flag which indicates that the application has successfully
071   * unregistered with the RM and the application can safely stop.
072   * @param isUnregistered boolean flag to indicate that the application has
073   *        successfully unregistered with the RM
074   */
075  @Private
076  @Unstable
077  public abstract void setIsUnregistered(boolean isUnregistered);
078}