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 * The finalization request sent by the {@code ApplicationMaster} to
029 * inform the {@code ResourceManager} about its completion.
030 * <p>
031 * The final request includes details such:
032 * <ul>
033 *   <li>Final state of the {@code ApplicationMaster}</li>
034 *   <li>
035 *     Diagnostic information in case of failure of the
036 *     {@code ApplicationMaster}
037 *   </li>
038 *   <li>Tracking URL</li>
039 * </ul>
040 *
041 * @see ApplicationMasterProtocol#finishApplicationMaster(FinishApplicationMasterRequest)
042 */
043@Public
044@Stable
045public abstract class FinishApplicationMasterRequest {
046
047  @Public
048  @Stable
049  public static FinishApplicationMasterRequest newInstance(
050      FinalApplicationStatus finalAppStatus, String diagnostics, String url) {
051    FinishApplicationMasterRequest request =
052        Records.newRecord(FinishApplicationMasterRequest.class);
053    request.setFinalApplicationStatus(finalAppStatus);
054    request.setDiagnostics(diagnostics);
055    request.setTrackingUrl(url);
056    return request;
057  }
058
059  /**
060   * Get <em>final state</em> of the <code>ApplicationMaster</code>.
061   * @return <em>final state</em> of the <code>ApplicationMaster</code>
062   */
063  @Public
064  @Stable
065  public abstract FinalApplicationStatus getFinalApplicationStatus();
066
067  /**
068   * Set the <em>final state</em> of the <code>ApplicationMaster</code>
069   * @param finalState <em>final state</em> of the <code>ApplicationMaster</code>
070   */
071  @Public
072  @Stable
073  public abstract void setFinalApplicationStatus(FinalApplicationStatus finalState);
074
075  /**
076   * Get <em>diagnostic information</em> on application failure.
077   * @return <em>diagnostic information</em> on application failure
078   */
079  @Public
080  @Stable
081  public abstract String getDiagnostics();
082
083  /**
084   * Set <em>diagnostic information</em> on application failure.
085   * @param diagnostics <em>diagnostic information</em> on application failure
086   */
087  @Public
088  @Stable
089  public abstract void setDiagnostics(String diagnostics);
090
091  /**
092   * Get the <em>tracking URL</em> for the <code>ApplicationMaster</code>.
093   * This url if contains scheme then that will be used by resource manager
094   * web application proxy otherwise it will default to http.
095   * @return <em>tracking URL</em>for the <code>ApplicationMaster</code>
096   */
097  @Public
098  @Stable
099  public abstract String getTrackingUrl();
100
101  /**
102   * Set the <em>final tracking URL</em>for the <code>ApplicationMaster</code>.
103   * This is the web-URL to which ResourceManager or web-application proxy will
104   * redirect client/users once the application is finished and the
105   * <code>ApplicationMaster</code> is gone.
106   * <p>
107   * If the passed url has a scheme then that will be used by the
108   * ResourceManager and web-application proxy, otherwise the scheme will
109   * default to http.
110   * </p>
111   * <p>
112   * Empty, null, "N/A" strings are all valid besides a real URL. In case an url
113   * isn't explicitly passed, it defaults to "N/A" on the ResourceManager.
114   * <p>
115   *
116   * @param url
117   *          <em>tracking URL</em>for the <code>ApplicationMaster</code>
118   */
119  @Public
120  @Stable
121  public abstract void setTrackingUrl(String url);
122
123}