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 package org.apache.hadoop.mapred; 019 020 import java.util.ArrayList; 021 import java.util.List; 022 import java.util.Properties; 023 024 import org.apache.hadoop.classification.InterfaceAudience; 025 import org.apache.hadoop.classification.InterfaceStability; 026 import org.apache.hadoop.mapreduce.QueueInfo; 027 import org.apache.hadoop.mapreduce.QueueState; 028 029 /** 030 * Class that contains the information regarding the Job Queues which are 031 * maintained by the Hadoop Map/Reduce framework. 032 */ 033 @InterfaceAudience.Public 034 @InterfaceStability.Stable 035 public class JobQueueInfo extends QueueInfo { 036 037 /** 038 * Default constructor for Job Queue Info. 039 * 040 */ 041 public JobQueueInfo() { 042 super(); 043 } 044 045 /** 046 * Construct a new JobQueueInfo object using the queue name and the 047 * scheduling information passed. 048 * 049 * @param queueName Name of the job queue 050 * @param schedulingInfo Scheduling Information associated with the job 051 * queue 052 */ 053 public JobQueueInfo(String queueName, String schedulingInfo) { 054 super(queueName, schedulingInfo); 055 } 056 057 JobQueueInfo(QueueInfo queue) { 058 this(queue.getQueueName(), queue.getSchedulingInfo()); 059 setQueueState(queue.getState().getStateName()); 060 setQueueChildren(queue.getQueueChildren()); 061 setProperties(queue.getProperties()); 062 setJobStatuses(queue.getJobStatuses()); 063 } 064 065 /** 066 * Set the queue name of the JobQueueInfo 067 * 068 * @param queueName Name of the job queue. 069 */ 070 @InterfaceAudience.Private 071 public void setQueueName(String queueName) { 072 super.setQueueName(queueName); 073 } 074 075 /** 076 * Set the scheduling information associated to particular job queue 077 * 078 * @param schedulingInfo 079 */ 080 @InterfaceAudience.Private 081 public void setSchedulingInfo(String schedulingInfo) { 082 super.setSchedulingInfo(schedulingInfo); 083 } 084 085 /** 086 * Set the state of the queue 087 * @param state state of the queue. 088 */ 089 @InterfaceAudience.Private 090 public void setQueueState(String state) { 091 super.setState(QueueState.getState(state)); 092 } 093 094 /** 095 * Use getState() instead 096 */ 097 @Deprecated 098 public String getQueueState() { 099 return super.getState().toString(); 100 } 101 102 @InterfaceAudience.Private 103 public void setChildren(List<JobQueueInfo> children) { 104 List<QueueInfo> list = new ArrayList<QueueInfo>(); 105 for (JobQueueInfo q : children) { 106 list.add(q); 107 } 108 super.setQueueChildren(list); 109 } 110 111 public List<JobQueueInfo> getChildren() { 112 List<JobQueueInfo> list = new ArrayList<JobQueueInfo>(); 113 for (QueueInfo q : super.getQueueChildren()) { 114 list.add((JobQueueInfo)q); 115 } 116 return list; 117 } 118 119 @InterfaceAudience.Private 120 public void setProperties(Properties props) { 121 super.setProperties(props); 122 } 123 124 /** 125 * Add a child {@link JobQueueInfo} to this {@link JobQueueInfo}. Modify the 126 * fully-qualified name of the child {@link JobQueueInfo} to reflect the 127 * hierarchy. 128 * 129 * Only for testing. 130 * 131 * @param child 132 */ 133 void addChild(JobQueueInfo child) { 134 List<JobQueueInfo> children = getChildren(); 135 children.add(child); 136 setChildren(children); 137 } 138 139 /** 140 * Remove the child from this {@link JobQueueInfo}. This also resets the 141 * queue-name of the child from a fully-qualified name to a simple queue name. 142 * 143 * Only for testing. 144 * 145 * @param child 146 */ 147 void removeChild(JobQueueInfo child) { 148 List<JobQueueInfo> children = getChildren(); 149 children.remove(child); 150 setChildren(children); 151 } 152 153 @InterfaceAudience.Private 154 public void setJobStatuses(org.apache.hadoop.mapreduce.JobStatus[] stats) { 155 super.setJobStatuses(stats); 156 } 157 158 }