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