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.Public;
022    import org.apache.hadoop.classification.InterfaceStability.Stable;
023    import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
024    import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
025    import org.apache.hadoop.yarn.util.Records;
026    
027    /**
028     * <p>The finalization request sent by the <code>ApplicationMaster</code> to
029     * inform the <code>ResourceManager</code> about its completion.</p>
030     *
031     * <p>The final request includes details such:
032     *   <ul>
033     *     <li>Final state of the <code>ApplicationMaster</code></li>
034     *     <li>
035     *       Diagnostic information in case of failure of the
036     *       <code>ApplicationMaster</code>
037     *     </li>
038     *     <li>Tracking URL</li>
039     *   </ul>
040     * </p>
041     *
042     * @see ApplicationMasterProtocol#finishApplicationMaster(FinishApplicationMasterRequest)
043     */
044    @Public
045    @Stable
046    public abstract class FinishApplicationMasterRequest {
047    
048      @Public
049      @Stable
050      public static FinishApplicationMasterRequest newInstance(
051          FinalApplicationStatus finalAppStatus, String diagnostics, String url) {
052        FinishApplicationMasterRequest request =
053            Records.newRecord(FinishApplicationMasterRequest.class);
054        request.setFinalApplicationStatus(finalAppStatus);
055        request.setDiagnostics(diagnostics);
056        request.setTrackingUrl(url);
057        return request;
058      }
059    
060      /**
061       * Get <em>final state</em> of the <code>ApplicationMaster</code>.
062       * @return <em>final state</em> of the <code>ApplicationMaster</code>
063       */
064      @Public
065      @Stable
066      public abstract FinalApplicationStatus getFinalApplicationStatus();
067    
068      /**
069       * Set the <em>final state</em> of the <code>ApplicationMaster</code>
070       * @param finalState <em>final state</em> of the <code>ApplicationMaster</code>
071       */
072      @Public
073      @Stable
074      public abstract void setFinalApplicationStatus(FinalApplicationStatus finalState);
075    
076      /**
077       * Get <em>diagnostic information</em> on application failure.
078       * @return <em>diagnostic information</em> on application failure
079       */
080      @Public
081      @Stable
082      public abstract String getDiagnostics();
083    
084      /**
085       * Set <em>diagnostic information</em> on application failure.
086       * @param diagnostics <em>diagnostic information</em> on application failure
087       */
088      @Public
089      @Stable
090      public abstract void setDiagnostics(String diagnostics);
091    
092      /**
093       * Get the <em>tracking URL</em> for the <code>ApplicationMaster</code>.
094       * @return <em>tracking URL</em>for the <code>ApplicationMaster</code>
095       */
096      @Public
097      @Stable
098      public abstract String getTrackingUrl();
099    
100      /**
101       * Set the <em>tracking URL</em>for the <code>ApplicationMaster</code>
102       * @param url <em>tracking URL</em>for the
103       *                   <code>ApplicationMaster</code>
104       */
105      @Public
106      @Stable
107      public abstract void setTrackingUrl(String url);
108    
109    }