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 */
018package org.apache.hadoop.mapreduce;
019
020import java.io.DataInput;
021import java.io.DataOutput;
022import java.io.IOException;
023
024import org.apache.hadoop.classification.InterfaceAudience;
025import org.apache.hadoop.classification.InterfaceStability;
026import org.apache.hadoop.io.Text;
027import org.apache.hadoop.io.Writable;
028import org.apache.hadoop.io.WritableUtils;
029import org.apache.hadoop.util.StringInterner;
030
031/**
032 *  Class to encapsulate Queue ACLs for a particular
033 *  user.
034 * 
035 */
036@InterfaceAudience.Public
037@InterfaceStability.Evolving
038public class QueueAclsInfo implements Writable {
039
040  private String queueName;
041  private String[] operations;
042  /**
043   * Default constructor for QueueAclsInfo.
044   * 
045   */
046  public QueueAclsInfo() {
047    
048  }
049
050  /**
051   * Construct a new QueueAclsInfo object using the queue name and the
052   * queue operations array
053   * 
054   * @param queueName Name of the job queue
055   * @param operations
056   */
057  public QueueAclsInfo(String queueName, String[] operations) {
058    this.queueName = queueName;
059    this.operations = operations;    
060  }
061
062  /**
063   * Get queue name.
064   * 
065   * @return name
066   */
067  public String getQueueName() {
068    return queueName;
069  }
070
071  protected void setQueueName(String queueName) {
072    this.queueName = queueName;
073  }
074
075  /**
076   * Get opearations allowed on queue.
077   * 
078   * @return array of String
079   */
080  public String[] getOperations() {
081    return operations;
082  }
083
084  @Override
085  public void readFields(DataInput in) throws IOException {
086    queueName = StringInterner.weakIntern(Text.readString(in));
087    operations = WritableUtils.readStringArray(in);
088  }
089
090  @Override
091  public void write(DataOutput out) throws IOException {
092    Text.writeString(out, queueName);
093    WritableUtils.writeStringArray(out, operations);
094  }
095}