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