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.oozie.util; 020 021import java.io.IOException; 022import java.util.Date; 023import java.util.Map; 024 025import org.apache.oozie.client.rest.RestConstants; 026import org.apache.oozie.command.CommandException; 027import org.apache.oozie.service.ConfigurationService; 028import org.apache.oozie.service.Services; 029import org.apache.oozie.service.XLogService; 030 031public class XLogErrorStreamer extends XLogStreamer { 032 033 public static final String STREAM_BUFFER_LEN = CONF_PREFIX + "error.buffer.len"; 034 035 public XLogErrorStreamer(XLogFilter logFilter, Map<String, String[]> requestParameters) { 036 super(logFilter, Services.get().get(XLogService.class).getOozieErrorLogPath(), Services.get() 037 .get(XLogService.class).getOozieErrorLogName(), Services.get().get(XLogService.class) 038 .getOozieErrorLogRotation()); 039 this.requestParam = requestParameters; 040 bufferLen = ConfigurationService.getInt(STREAM_BUFFER_LEN, 2048); 041 } 042 043 public XLogErrorStreamer(Map<String, String[]> requestParameters) throws CommandException { 044 this(new XLogFilter(new XLogUserFilterParam(requestParameters)), requestParameters); 045 } 046 047 @Override 048 protected void calculateAndValidateDateRange(Date startTime, Date endTime) throws IOException { 049 logFilter.calculateAndCheckDates(startTime, endTime); 050 // no validate and truncating 051 } 052 053 @Override 054 public boolean isLogEnabled() { 055 return Services.get().get(XLogService.class).isErrorLogEnabled(); 056 } 057 058 @Override 059 public String getLogType() { 060 return RestConstants.JOB_SHOW_ERROR_LOG; 061 } 062 063 @Override 064 public String getLogDisableMessage() { 065 return "Error Log is disabled!!"; 066 } 067}