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.records;
020
021import org.apache.hadoop.classification.InterfaceAudience.Public;
022import org.apache.hadoop.classification.InterfaceStability.Evolving;
023import org.apache.hadoop.classification.InterfaceStability.Unstable;
024import org.apache.hadoop.yarn.util.Records;
025
026/**
027 * <p><code>LogAggregationContext</code> represents all of the
028 * information needed by the <code>NodeManager</code> to handle
029 * the logs for an application.</p>
030 *
031 * <p>It includes details such as:
032 *   <ul>
033 *     <li>includePattern. It uses Java Regex to filter the log files
034 *     which match the defined include pattern and those log files
035 *     will be uploaded when the application finishes. </li>
036 *     <li>excludePattern. It uses Java Regex to filter the log files
037 *     which match the defined exclude pattern and those log files
038 *     will not be uploaded when application finishes. If the log file
039 *     name matches both the include and the exclude pattern, this file
040 *     will be excluded eventually</li>
041 *     <li>rolledLogsIncludePattern. It uses Java Regex to filter the log files
042 *     which match the defined include pattern and those log files
043 *     will be aggregated in a rolling fashion.</li>
044 *     <li>rolledLogsExcludePattern. It uses Java Regex to filter the log files
045 *     which match the defined exclude pattern and those log files
046 *     will not be aggregated in a rolling fashion. If the log file
047 *     name matches both the include and the exclude pattern, this file
048 *     will be excluded eventually</li>
049 *   </ul>
050 * </p>
051 *
052 * @see ApplicationSubmissionContext
053 */
054
055@Evolving
056@Public
057public abstract class LogAggregationContext {
058
059  @Public
060  @Unstable
061  public static LogAggregationContext newInstance(String includePattern,
062      String excludePattern) {
063    LogAggregationContext context = Records.newRecord(LogAggregationContext.class);
064    context.setIncludePattern(includePattern);
065    context.setExcludePattern(excludePattern);
066    return context;
067  }
068
069  @Public
070  @Unstable
071  public static LogAggregationContext newInstance(String includePattern,
072      String excludePattern, String rolledLogsIncludePattern,
073      String rolledLogsExcludePattern) {
074    LogAggregationContext context =
075        Records.newRecord(LogAggregationContext.class);
076    context.setIncludePattern(includePattern);
077    context.setExcludePattern(excludePattern);
078    context.setRolledLogsIncludePattern(rolledLogsIncludePattern);
079    context.setRolledLogsExcludePattern(rolledLogsExcludePattern);
080    return context;
081  }
082
083  /**
084   * Get include pattern. This includePattern only takes affect
085   * on logs that exist at the time of application finish.
086   *
087   * @return include pattern
088   */
089  @Public
090  @Unstable
091  public abstract String getIncludePattern();
092
093  /**
094   * Set include pattern. This includePattern only takes affect
095   * on logs that exist at the time of application finish.
096   *
097   * @param includePattern
098   */
099  @Public
100  @Unstable
101  public abstract void setIncludePattern(String includePattern);
102
103  /**
104   * Get exclude pattern. This excludePattern only takes affect
105   * on logs that exist at the time of application finish.
106   *
107   * @return exclude pattern
108   */
109  @Public
110  @Unstable
111  public abstract String getExcludePattern();
112
113  /**
114   * Set exclude pattern. This excludePattern only takes affect
115   * on logs that exist at the time of application finish.
116   *
117   * @param excludePattern
118   */
119  @Public
120  @Unstable
121  public abstract void setExcludePattern(String excludePattern);
122
123  /**
124   * Get include pattern in a rolling fashion.
125   * 
126   * @return include pattern
127   */
128  @Public
129  @Unstable
130  public abstract String getRolledLogsIncludePattern();
131
132  /**
133   * Set include pattern in a rolling fashion.
134   * 
135   * @param rolledLogsIncludePattern
136   */
137  @Public
138  @Unstable
139  public abstract void setRolledLogsIncludePattern(
140      String rolledLogsIncludePattern);
141
142  /**
143   * Get exclude pattern for aggregation in a rolling fashion.
144   * 
145   * @return exclude pattern
146   */
147  @Public
148  @Unstable
149  public abstract String getRolledLogsExcludePattern();
150
151  /**
152   * Set exclude pattern for in a rolling fashion.
153   * 
154   * @param rolledLogsExcludePattern
155   */
156  @Public
157  @Unstable
158  public abstract void setRolledLogsExcludePattern(
159      String rolledLogsExcludePattern);
160}