@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); }
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()]); }
@Override public List<QueueUserACLInfo> getQueueUserAclInfo(UserGroupInformation user) { List<QueueUserACLInfo> userAcls = new ArrayList<QueueUserACLInfo>(); // Add queue acls userAcls.add(getUserAclInfo(user)); // Add children queue acls readLock.lock(); try { for (FSQueue child : childQueues) { userAcls.addAll(child.getQueueUserAclInfo(user)); } } finally { readLock.unlock(); } return userAcls; }
@Override public List<QueueUserACLInfo> getQueueUserAclInfo(UserGroupInformation user) { QueueUserACLInfo userAclInfo = recordFactory.newRecordInstance(QueueUserACLInfo.class); List<QueueACL> operations = new ArrayList<QueueACL>(); for (QueueACL operation : QueueACL.values()) { Map<QueueACL, AccessControlList> acls = queueMgr.getQueueAcls(getName()); if (acls.get(operation).isUserAllowed(user)) { operations.add(operation); } } userAclInfo.setQueueName(getQueueName()); userAclInfo.setUserAcls(operations); return Collections.singletonList(userAclInfo); }
@Override public void setUserAclsInfoList(List<QueueUserACLInfo> queueUserAclsList) { if (queueUserAclsList == null) { builder.clearQueueUserAcls(); } this.queueUserAclsInfoList = queueUserAclsList; }
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)); } }
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); }
@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); }
@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); }
@Override public List<QueueUserACLInfo> getQueueUserAclInfo() { UserGroupInformation user; try { user = UserGroupInformation.getCurrentUser(); } catch (IOException ioe) { return new ArrayList<QueueUserACLInfo>(); } return queueMgr.getRootQueue().getQueueUserAclInfo(user); }
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; }
@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; }
@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; }
@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); }
@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); } }
private int getQueueCount(List<QueueUserACLInfo> queueInformation, String queueName) { int result = 0; for (QueueUserACLInfo queueUserACLInfo : queueInformation) { if (queueName.equals(queueUserACLInfo.getQueueName())) { result++; } } return result; }
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; }
public boolean hasQueueACL(List<QueueUserACLInfo> aclInfos, QueueACL acl) { for (QueueUserACLInfo aclInfo : aclInfos) { if (aclInfo.getUserAcls().contains(acl)) { return true; } } return false; }