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.Public;
022import org.apache.hadoop.classification.InterfaceStability.Stable;
023import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
024import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
025import 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
046public 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   * This url if contains scheme then that will be used by resource manager
095   * web application proxy otherwise it will default to http.
096   * @return <em>tracking URL</em>for the <code>ApplicationMaster</code>
097   */
098  @Public
099  @Stable
100  public abstract String getTrackingUrl();
101
102  /**
103   * Set the <em>final tracking URL</em>for the <code>ApplicationMaster</code>.
104   * This is the web-URL to which ResourceManager or web-application proxy will
105   * redirect client/users once the application is finished and the
106   * <code>ApplicationMaster</code> is gone.
107   * <p>
108   * If the passed url has a scheme then that will be used by the
109   * ResourceManager and web-application proxy, otherwise the scheme will
110   * default to http.
111   * </p>
112   * <p>
113   * Empty, null, "N/A" strings are all valid besides a real URL. In case an url
114   * isn't explicitly passed, it defaults to "N/A" on the ResourceManager.
115   * <p>
116   *
117   * @param url
118   *          <em>tracking URL</em>for the <code>ApplicationMaster</code>
119   */
120  @Public
121  @Stable
122  public abstract void setTrackingUrl(String url);
123
124}