Java Code Examples for org.apache.hadoop.yarn.api.records.QueueUserACLInfo

The following examples show how to use org.apache.hadoop.yarn.api.records.QueueUserACLInfo. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   Source File: LeafQueue.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public synchronized List<QueueUserACLInfo> 
getQueueUserAclInfo(UserGroupInformation user) {
  QueueUserACLInfo userAclInfo = 
    recordFactory.newRecordInstance(QueueUserACLInfo.class);
  List<QueueACL> operations = new ArrayList<QueueACL>();
  for (QueueACL operation : QueueACL.values()) {
    if (hasAccess(operation, user)) {
      operations.add(operation);
    }
  }

  userAclInfo.setQueueName(getQueueName());
  userAclInfo.setUserAcls(operations);
  return Collections.singletonList(userAclInfo);
}
 
Example 2
Source Project: hadoop   Source File: TypeConverter.java    License: Apache License 2.0 6 votes vote down vote up
public static QueueAclsInfo[] fromYarnQueueUserAclsInfo(
    List<QueueUserACLInfo> userAcls) {
  List<QueueAclsInfo> acls = new ArrayList<QueueAclsInfo>();
  for (QueueUserACLInfo aclInfo : userAcls) {
    List<String> operations = new ArrayList<String>();
    for (QueueACL qAcl : aclInfo.getUserAcls()) {
      operations.add(qAcl.toString());
    }

    QueueAclsInfo acl =
      new QueueAclsInfo(aclInfo.getQueueName(),
          operations.toArray(new String[operations.size()]));
    acls.add(acl);
  }
  return acls.toArray(new QueueAclsInfo[acls.size()]);
}
 
Example 3
Source Project: big-c   Source File: LeafQueue.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public synchronized List<QueueUserACLInfo> 
getQueueUserAclInfo(UserGroupInformation user) {
  QueueUserACLInfo userAclInfo = 
    recordFactory.newRecordInstance(QueueUserACLInfo.class);
  List<QueueACL> operations = new ArrayList<QueueACL>();
  for (QueueACL operation : QueueACL.values()) {
    if (hasAccess(operation, user)) {
      operations.add(operation);
    }
  }

  userAclInfo.setQueueName(getQueueName());
  userAclInfo.setUserAcls(operations);
  return Collections.singletonList(userAclInfo);
}
 
Example 4
Source Project: big-c   Source File: TypeConverter.java    License: Apache License 2.0 6 votes vote down vote up
public static QueueAclsInfo[] fromYarnQueueUserAclsInfo(
    List<QueueUserACLInfo> userAcls) {
  List<QueueAclsInfo> acls = new ArrayList<QueueAclsInfo>();
  for (QueueUserACLInfo aclInfo : userAcls) {
    List<String> operations = new ArrayList<String>();
    for (QueueACL qAcl : aclInfo.getUserAcls()) {
      operations.add(qAcl.toString());
    }

    QueueAclsInfo acl =
      new QueueAclsInfo(aclInfo.getQueueName(),
          operations.toArray(new String[operations.size()]));
    acls.add(acl);
  }
  return acls.toArray(new QueueAclsInfo[acls.size()]);
}
 
Example 5
Source Project: hadoop   Source File: GetQueueUserAclsInfoResponsePBImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setUserAclsInfoList(List<QueueUserACLInfo> queueUserAclsList) {
  if (queueUserAclsList == null) {
    builder.clearQueueUserAcls();
  }
  this.queueUserAclsInfoList = queueUserAclsList;
}
 
Example 6
Source Project: hadoop   Source File: GetQueueUserAclsInfoResponsePBImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void initLocalQueueUserAclsList() {
  if (this.queueUserAclsInfoList != null) {
    return;
  }
  GetQueueUserAclsInfoResponseProtoOrBuilder p = viaProto ? proto : builder;
  List<QueueUserACLInfoProto> list = p.getQueueUserAclsList();
  queueUserAclsInfoList = new ArrayList<QueueUserACLInfo>();

  for (QueueUserACLInfoProto a : list) {
    queueUserAclsInfoList.add(convertFromProtoFormat(a));
  }
}
 
Example 7
Source Project: hadoop   Source File: GetQueueUserAclsInfoResponsePBImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void addLocalQueueUserACLInfosToProto() {
  maybeInitBuilder();
  builder.clearQueueUserAcls();
  if (queueUserAclsInfoList == null)
    return;
  Iterable<QueueUserACLInfoProto> iterable = new Iterable<QueueUserACLInfoProto>() {
    @Override
    public Iterator<QueueUserACLInfoProto> iterator() {
      return new Iterator<QueueUserACLInfoProto>() {

        Iterator<QueueUserACLInfo> iter = queueUserAclsInfoList.iterator();

        @Override
        public boolean hasNext() {
          return iter.hasNext();
        }

        @Override
        public QueueUserACLInfoProto next() {
          return convertToProtoFormat(iter.next());
        }

        @Override
        public void remove() {
          throw new UnsupportedOperationException();

        }
      };

    }
  };
  builder.addAllQueueUserAcls(iterable);
}
 
Example 8
Source Project: hadoop   Source File: FifoScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<QueueUserACLInfo> getQueueUserAclInfo(
    UserGroupInformation unused) {
  QueueUserACLInfo queueUserAclInfo = 
    recordFactory.newRecordInstance(QueueUserACLInfo.class);
  queueUserAclInfo.setQueueName(DEFAULT_QUEUE_NAME);
  queueUserAclInfo.setUserAcls(Arrays.asList(QueueACL.values()));
  return Collections.singletonList(queueUserAclInfo);
}
 
Example 9
Source Project: hadoop   Source File: FSLeafQueue.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<QueueUserACLInfo> getQueueUserAclInfo(UserGroupInformation user) {
  QueueUserACLInfo userAclInfo =
    recordFactory.newRecordInstance(QueueUserACLInfo.class);
  List<QueueACL> operations = new ArrayList<QueueACL>();
  for (QueueACL operation : QueueACL.values()) {
    if (hasAccess(operation, user)) {
      operations.add(operation);
    }
  }

  userAclInfo.setQueueName(getQueueName());
  userAclInfo.setUserAcls(operations);
  return Collections.singletonList(userAclInfo);
}
 
Example 10
Source Project: hadoop   Source File: FairScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<QueueUserACLInfo> getQueueUserAclInfo() {
  UserGroupInformation user;
  try {
    user = UserGroupInformation.getCurrentUser();
  } catch (IOException ioe) {
    return new ArrayList<QueueUserACLInfo>();
  }

  return queueMgr.getRootQueue().getQueueUserAclInfo(user);
}
 
Example 11
Source Project: hadoop   Source File: FSParentQueue.java    License: Apache License 2.0 5 votes vote down vote up
private synchronized QueueUserACLInfo getUserAclInfo(
    UserGroupInformation user) {
  QueueUserACLInfo userAclInfo = 
    recordFactory.newRecordInstance(QueueUserACLInfo.class);
  List<QueueACL> operations = new ArrayList<QueueACL>();
  for (QueueACL operation : QueueACL.values()) {
    if (hasAccess(operation, user)) {
      operations.add(operation);
    } 
  }

  userAclInfo.setQueueName(getQueueName());
  userAclInfo.setUserAcls(operations);
  return userAclInfo;
}
 
Example 12
Source Project: hadoop   Source File: FSParentQueue.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public synchronized List<QueueUserACLInfo> getQueueUserAclInfo(
    UserGroupInformation user) {
  List<QueueUserACLInfo> userAcls = new ArrayList<QueueUserACLInfo>();
  
  // Add queue acls
  userAcls.add(getUserAclInfo(user));
  
  // Add children queue acls
  for (FSQueue child : childQueues) {
    userAcls.addAll(child.getQueueUserAclInfo(user));
  }
 
  return userAcls;
}
 
Example 13
Source Project: hadoop   Source File: ParentQueue.java    License: Apache License 2.0 5 votes vote down vote up
private synchronized QueueUserACLInfo getUserAclInfo(
    UserGroupInformation user) {
  QueueUserACLInfo userAclInfo = 
    recordFactory.newRecordInstance(QueueUserACLInfo.class);
  List<QueueACL> operations = new ArrayList<QueueACL>();
  for (QueueACL operation : QueueACL.values()) {
    if (hasAccess(operation, user)) {
      operations.add(operation);
    } 
  }

  userAclInfo.setQueueName(getQueueName());
  userAclInfo.setUserAcls(operations);
  return userAclInfo;
}
 
Example 14
Source Project: hadoop   Source File: ParentQueue.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public synchronized List<QueueUserACLInfo> getQueueUserAclInfo(
    UserGroupInformation user) {
  List<QueueUserACLInfo> userAcls = new ArrayList<QueueUserACLInfo>();
  
  // Add parent queue acls
  userAcls.add(getUserAclInfo(user));
  
  // Add children queue acls
  for (CSQueue child : childQueues) {
    userAcls.addAll(child.getQueueUserAclInfo(user));
  }
 
  return userAcls;
}
 
Example 15
Source Project: hadoop   Source File: CapacityScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Lock(Lock.NoLock.class)
public List<QueueUserACLInfo> getQueueUserAclInfo() {
  UserGroupInformation user = null;
  try {
    user = UserGroupInformation.getCurrentUser();
  } catch (IOException ioe) {
    // should never happen
    return new ArrayList<QueueUserACLInfo>();
  }

  return root.getQueueUserAclInfo(user);
}
 
Example 16
Source Project: hadoop   Source File: TestCapacityScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCapacitySchedulerInfo() throws Exception {
  QueueInfo queueInfo = resourceManager.getResourceScheduler().getQueueInfo("a", true, true);
  Assert.assertEquals(queueInfo.getQueueName(), "a");
  Assert.assertEquals(queueInfo.getChildQueues().size(), 2);

  List<QueueUserACLInfo> userACLInfo = resourceManager.getResourceScheduler().getQueueUserAclInfo();
  Assert.assertNotNull(userACLInfo);
  for (QueueUserACLInfo queueUserACLInfo : userACLInfo) {
    Assert.assertEquals(getQueueCount(userACLInfo, queueUserACLInfo.getQueueName()), 1);
  }

}
 
Example 17
Source Project: hadoop   Source File: TestCapacityScheduler.java    License: Apache License 2.0 5 votes vote down vote up
private int getQueueCount(List<QueueUserACLInfo> queueInformation, String queueName) {
  int result = 0;
  for (QueueUserACLInfo queueUserACLInfo : queueInformation) {
    if (queueName.equals(queueUserACLInfo.getQueueName())) {
      result++;
    }
  }
  return result;
}
 
Example 18
Source Project: hadoop   Source File: TestParentQueue.java    License: Apache License 2.0 5 votes vote down vote up
public boolean hasQueueACL(List<QueueUserACLInfo> aclInfos, QueueACL acl, String qName) {
  for (QueueUserACLInfo aclInfo : aclInfos) {
    if (aclInfo.getQueueName().equals(qName)) {
      if (aclInfo.getUserAcls().contains(acl)) {
        return true;
      }
    }
  }    
  return false;
}
 
Example 19
Source Project: hadoop   Source File: TestLeafQueue.java    License: Apache License 2.0 5 votes vote down vote up
public boolean hasQueueACL(List<QueueUserACLInfo> aclInfos, QueueACL acl) {
  for (QueueUserACLInfo aclInfo : aclInfos) {
    if (aclInfo.getUserAcls().contains(acl)) {
      return true;
    }
  }    
  return false;
}
 
Example 20
Source Project: hadoop   Source File: YarnClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<QueueUserACLInfo> getQueueAclsInfo() throws YarnException,
    IOException {
  GetQueueUserAclsInfoRequest request =
      Records.newRecord(GetQueueUserAclsInfoRequest.class);
  return rmClient.getQueueUserAcls(request).getUserAclsInfoList();
}
 
Example 21
Source Project: hadoop   Source File: TestApplicationClientProtocolOnHA.java    License: Apache License 2.0 5 votes vote down vote up
@Test(timeout = 15000)
public void testGetQueueUserAclsOnHA() throws Exception {
  List<QueueUserACLInfo> queueUserAclsList = client.getQueueAclsInfo();
  Assert.assertTrue(queueUserAclsList != null
      && !queueUserAclsList.isEmpty());
  Assert.assertEquals(cluster.createFakeQueueUserACLInfoList(),
      queueUserAclsList);
}
 
Example 22
Source Project: hadoop   Source File: ProtocolHATestBase.java    License: Apache License 2.0 5 votes vote down vote up
public List<QueueUserACLInfo> createFakeQueueUserACLInfoList() {
  List<QueueACL> queueACL = new ArrayList<QueueACL>();
  queueACL.add(QueueACL.SUBMIT_APPLICATIONS);
  QueueUserACLInfo info = QueueUserACLInfo.newInstance("root", queueACL);
  List<QueueUserACLInfo> infos = new ArrayList<QueueUserACLInfo>();
  infos.add(info);
  return infos;
}
 
Example 23
Source Project: hadoop   Source File: GetQueueUserAclsInfoResponse.java    License: Apache License 2.0 5 votes vote down vote up
@Private
@Unstable
public static GetQueueUserAclsInfoResponse newInstance(
    List<QueueUserACLInfo> queueUserAclsList) {
  GetQueueUserAclsInfoResponse response =
      Records.newRecord(GetQueueUserAclsInfoResponse.class);
  response.setUserAclsInfoList(queueUserAclsList);
  return response;
}
 
Example 24
Source Project: big-c   Source File: GetQueueUserAclsInfoResponsePBImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setUserAclsInfoList(List<QueueUserACLInfo> queueUserAclsList) {
  if (queueUserAclsList == null) {
    builder.clearQueueUserAcls();
  }
  this.queueUserAclsInfoList = queueUserAclsList;
}
 
Example 25
Source Project: big-c   Source File: GetQueueUserAclsInfoResponsePBImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void initLocalQueueUserAclsList() {
  if (this.queueUserAclsInfoList != null) {
    return;
  }
  GetQueueUserAclsInfoResponseProtoOrBuilder p = viaProto ? proto : builder;
  List<QueueUserACLInfoProto> list = p.getQueueUserAclsList();
  queueUserAclsInfoList = new ArrayList<QueueUserACLInfo>();

  for (QueueUserACLInfoProto a : list) {
    queueUserAclsInfoList.add(convertFromProtoFormat(a));
  }
}
 
Example 26
Source Project: big-c   Source File: GetQueueUserAclsInfoResponsePBImpl.java    License: Apache License 2.0 5 votes vote down vote up
private void addLocalQueueUserACLInfosToProto() {
  maybeInitBuilder();
  builder.clearQueueUserAcls();
  if (queueUserAclsInfoList == null)
    return;
  Iterable<QueueUserACLInfoProto> iterable = new Iterable<QueueUserACLInfoProto>() {
    @Override
    public Iterator<QueueUserACLInfoProto> iterator() {
      return new Iterator<QueueUserACLInfoProto>() {

        Iterator<QueueUserACLInfo> iter = queueUserAclsInfoList.iterator();

        @Override
        public boolean hasNext() {
          return iter.hasNext();
        }

        @Override
        public QueueUserACLInfoProto next() {
          return convertToProtoFormat(iter.next());
        }

        @Override
        public void remove() {
          throw new UnsupportedOperationException();

        }
      };

    }
  };
  builder.addAllQueueUserAcls(iterable);
}
 
Example 27
Source Project: big-c   Source File: FifoScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<QueueUserACLInfo> getQueueUserAclInfo(
    UserGroupInformation unused) {
  QueueUserACLInfo queueUserAclInfo = 
    recordFactory.newRecordInstance(QueueUserACLInfo.class);
  queueUserAclInfo.setQueueName(DEFAULT_QUEUE_NAME);
  queueUserAclInfo.setUserAcls(Arrays.asList(QueueACL.values()));
  return Collections.singletonList(queueUserAclInfo);
}
 
Example 28
Source Project: big-c   Source File: FSLeafQueue.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<QueueUserACLInfo> getQueueUserAclInfo(UserGroupInformation user) {
  QueueUserACLInfo userAclInfo =
    recordFactory.newRecordInstance(QueueUserACLInfo.class);
  List<QueueACL> operations = new ArrayList<QueueACL>();
  for (QueueACL operation : QueueACL.values()) {
    if (hasAccess(operation, user)) {
      operations.add(operation);
    }
  }

  userAclInfo.setQueueName(getQueueName());
  userAclInfo.setUserAcls(operations);
  return Collections.singletonList(userAclInfo);
}
 
Example 29
Source Project: big-c   Source File: FairScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<QueueUserACLInfo> getQueueUserAclInfo() {
  UserGroupInformation user;
  try {
    user = UserGroupInformation.getCurrentUser();
  } catch (IOException ioe) {
    return new ArrayList<QueueUserACLInfo>();
  }

  return queueMgr.getRootQueue().getQueueUserAclInfo(user);
}
 
Example 30
Source Project: big-c   Source File: FSParentQueue.java    License: Apache License 2.0 5 votes vote down vote up
private synchronized QueueUserACLInfo getUserAclInfo(
    UserGroupInformation user) {
  QueueUserACLInfo userAclInfo = 
    recordFactory.newRecordInstance(QueueUserACLInfo.class);
  List<QueueACL> operations = new ArrayList<QueueACL>();
  for (QueueACL operation : QueueACL.values()) {
    if (hasAccess(operation, user)) {
      operations.add(operation);
    } 
  }

  userAclInfo.setQueueName(getQueueName());
  userAclInfo.setUserAcls(operations);
  return userAclInfo;
}