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.mapreduce.v2.hs;
020
021import java.util.Map;
022
023import org.apache.hadoop.mapreduce.v2.api.records.JobId;
024import org.apache.hadoop.mapreduce.v2.api.records.JobState;
025import org.apache.hadoop.mapreduce.v2.app.job.Job;
026import org.apache.hadoop.mapreduce.v2.hs.webapp.dao.JobsInfo;
027import org.apache.hadoop.classification.InterfaceAudience;
028import org.apache.hadoop.classification.InterfaceStability;
029
030/**
031 * Provides an API to query jobs that have finished.
032 * 
033 * For those implementing this API be aware that there is no feedback when
034 * files are removed from HDFS.  You may rely on HistoryFileManager to help
035 * you know when that has happened if you have not made a complete backup of
036 * the data stored on HDFS.
037 */
038@InterfaceAudience.Public
039@InterfaceStability.Unstable
040public interface HistoryStorage {
041  
042  /**
043   * Give the Storage a reference to a class that can be used to interact with
044   * history files.
045   * @param hsManager the class that is used to interact with history files.
046   */
047  void setHistoryFileManager(HistoryFileManager hsManager);
048  
049  /**
050   * Look for a set of partial jobs.
051   * @param offset the offset into the list of jobs.
052   * @param count the maximum number of jobs to return.
053   * @param user only return jobs for the given user.
054   * @param queue only return jobs for in the given queue.
055   * @param sBegin only return Jobs that started on or after the given time.
056   * @param sEnd only return Jobs that started on or before the given time.
057   * @param fBegin only return Jobs that ended on or after the given time.
058   * @param fEnd only return Jobs that ended on or before the given time.
059   * @param jobState only return Jobs that are in the given job state.
060   * @return The list of filtered jobs.
061   */
062  JobsInfo getPartialJobs(Long offset, Long count, String user, 
063      String queue, Long sBegin, Long sEnd, Long fBegin, Long fEnd, 
064      JobState jobState);
065  
066  /**
067   * Get all of the cached jobs.  This only returns partial jobs and is here for
068   * legacy reasons.
069   * @return all of the cached jobs
070   */
071  Map<JobId, Job> getAllPartialJobs();
072  
073  /**
074   * Get a fully parsed job.
075   * @param jobId the id of the job
076   * @return the job, or null if it is not found.
077   */
078  Job getFullJob(JobId jobId);
079}