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