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 019 package org.apache.hadoop.mapred.jobcontrol; 020 021 import java.util.ArrayList; 022 import java.util.Collection; 023 import java.util.List; 024 025 import org.apache.hadoop.classification.InterfaceAudience; 026 import org.apache.hadoop.classification.InterfaceStability; 027 import org.apache.hadoop.mapreduce.lib.jobcontrol.ControlledJob; 028 029 /** 030 *@deprecated Use 031 *{@link org.apache.hadoop.mapreduce.lib.jobcontrol.JobControl} instead 032 **/ 033 @Deprecated 034 @InterfaceAudience.Public 035 @InterfaceStability.Stable 036 public class JobControl extends 037 org.apache.hadoop.mapreduce.lib.jobcontrol.JobControl { 038 039 /** 040 * Construct a job control for a group of jobs. 041 * @param groupName a name identifying this group 042 */ 043 public JobControl(String groupName) { 044 super(groupName); 045 } 046 047 static ArrayList<Job> castToJobList(List<ControlledJob> cjobs) { 048 ArrayList<Job> ret = new ArrayList<Job>(); 049 for (ControlledJob job : cjobs) { 050 ret.add((Job)job); 051 } 052 return ret; 053 } 054 055 /** 056 * @return the jobs in the waiting state 057 */ 058 public ArrayList<Job> getWaitingJobs() { 059 return castToJobList(super.getWaitingJobList()); 060 } 061 062 /** 063 * @return the jobs in the running state 064 */ 065 public ArrayList<Job> getRunningJobs() { 066 return castToJobList(super.getRunningJobList()); 067 } 068 069 /** 070 * @return the jobs in the ready state 071 */ 072 public ArrayList<Job> getReadyJobs() { 073 return castToJobList(super.getReadyJobsList()); 074 } 075 076 /** 077 * @return the jobs in the success state 078 */ 079 public ArrayList<Job> getSuccessfulJobs() { 080 return castToJobList(super.getSuccessfulJobList()); 081 } 082 083 public ArrayList<Job> getFailedJobs() { 084 return castToJobList(super.getFailedJobList()); 085 } 086 087 /** 088 * Add a collection of jobs 089 * 090 * @param jobs 091 */ 092 public void addJobs(Collection <Job> jobs) { 093 for (Job job : jobs) { 094 addJob(job); 095 } 096 } 097 098 /** 099 * @return the thread state 100 */ 101 public int getState() { 102 ThreadState state = super.getThreadState(); 103 if (state == ThreadState.RUNNING) { 104 return 0; 105 } 106 if (state == ThreadState.SUSPENDED) { 107 return 1; 108 } 109 if (state == ThreadState.STOPPED) { 110 return 2; 111 } 112 if (state == ThreadState.STOPPING) { 113 return 3; 114 } 115 if (state == ThreadState.READY ) { 116 return 4; 117 } 118 return -1; 119 } 120 121 }