use of org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest in project hadoop by apache.
the class TestResourceMgrDelegate method testGetRootQueues.
/**
* Tests that getRootQueues makes a request for the (recursive) child queues
* @throws IOException
*/
@Test
public void testGetRootQueues() throws IOException, InterruptedException {
final ApplicationClientProtocol applicationsManager = Mockito.mock(ApplicationClientProtocol.class);
GetQueueInfoResponse response = Mockito.mock(GetQueueInfoResponse.class);
org.apache.hadoop.yarn.api.records.QueueInfo queueInfo = Mockito.mock(org.apache.hadoop.yarn.api.records.QueueInfo.class);
Mockito.when(response.getQueueInfo()).thenReturn(queueInfo);
try {
Mockito.when(applicationsManager.getQueueInfo(Mockito.any(GetQueueInfoRequest.class))).thenReturn(response);
} catch (YarnException e) {
throw new IOException(e);
}
ResourceMgrDelegate delegate = new ResourceMgrDelegate(new YarnConfiguration()) {
@Override
protected void serviceStart() throws Exception {
Assert.assertTrue(this.client instanceof YarnClientImpl);
((YarnClientImpl) this.client).setRMClient(applicationsManager);
}
};
delegate.getRootQueues();
ArgumentCaptor<GetQueueInfoRequest> argument = ArgumentCaptor.forClass(GetQueueInfoRequest.class);
try {
Mockito.verify(applicationsManager).getQueueInfo(argument.capture());
} catch (YarnException e) {
throw new IOException(e);
}
Assert.assertTrue("Children of root queue not requested", argument.getValue().getIncludeChildQueues());
Assert.assertTrue("Request wasn't to recurse through children", argument.getValue().getRecursive());
}
use of org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest in project hadoop by apache.
the class TestClientRMService method testGetQueueInfo.
@Test
public void testGetQueueInfo() throws Exception {
YarnScheduler yarnScheduler = mock(YarnScheduler.class);
RMContext rmContext = mock(RMContext.class);
mockRMContext(yarnScheduler, rmContext);
ApplicationACLsManager mockAclsManager = mock(ApplicationACLsManager.class);
QueueACLsManager mockQueueACLsManager = mock(QueueACLsManager.class);
when(mockQueueACLsManager.checkAccess(any(UserGroupInformation.class), any(QueueACL.class), any(RMApp.class), any(String.class), any())).thenReturn(true);
when(mockAclsManager.checkAccess(any(UserGroupInformation.class), any(ApplicationAccessType.class), anyString(), any(ApplicationId.class))).thenReturn(true);
ClientRMService rmService = new ClientRMService(rmContext, yarnScheduler, null, mockAclsManager, mockQueueACLsManager, null);
GetQueueInfoRequest request = recordFactory.newRecordInstance(GetQueueInfoRequest.class);
request.setQueueName("testqueue");
request.setIncludeApplications(true);
GetQueueInfoResponse queueInfo = rmService.getQueueInfo(request);
List<ApplicationReport> applications = queueInfo.getQueueInfo().getApplications();
Assert.assertEquals(2, applications.size());
request.setQueueName("nonexistentqueue");
request.setIncludeApplications(true);
// should not throw exception on nonexistent queue
queueInfo = rmService.getQueueInfo(request);
// Case where user does not have application access
ApplicationACLsManager mockAclsManager1 = mock(ApplicationACLsManager.class);
QueueACLsManager mockQueueACLsManager1 = mock(QueueACLsManager.class);
when(mockQueueACLsManager1.checkAccess(any(UserGroupInformation.class), any(QueueACL.class), any(RMApp.class), any(String.class), any())).thenReturn(false);
when(mockAclsManager1.checkAccess(any(UserGroupInformation.class), any(ApplicationAccessType.class), anyString(), any(ApplicationId.class))).thenReturn(false);
ClientRMService rmService1 = new ClientRMService(rmContext, yarnScheduler, null, mockAclsManager1, mockQueueACLsManager1, null);
request.setQueueName("testqueue");
request.setIncludeApplications(true);
GetQueueInfoResponse queueInfo1 = rmService1.getQueueInfo(request);
List<ApplicationReport> applications1 = queueInfo1.getQueueInfo().getApplications();
Assert.assertEquals(0, applications1.size());
}
use of org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest in project hadoop by apache.
the class YarnClientImpl method getQueueInfoRequest.
private GetQueueInfoRequest getQueueInfoRequest(String queueName, boolean includeApplications, boolean includeChildQueues, boolean recursive) {
GetQueueInfoRequest request = Records.newRecord(GetQueueInfoRequest.class);
request.setQueueName(queueName);
request.setIncludeApplications(includeApplications);
request.setIncludeChildQueues(includeChildQueues);
request.setRecursive(recursive);
return request;
}
use of org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest in project hadoop by apache.
the class YarnClientImpl method getQueueInfo.
@Override
public QueueInfo getQueueInfo(String queueName) throws YarnException, IOException {
GetQueueInfoRequest request = getQueueInfoRequest(queueName, true, false, false);
Records.newRecord(GetQueueInfoRequest.class);
return rmClient.getQueueInfo(request).getQueueInfo();
}
Aggregations