下面列出了怎么用org.apache.hadoop.mapreduce.QueueAclsInfo的API类实例代码及写法,或者点击链接到github查看源代码。
@Test( expected = YarnQueueAclsException.class )
public void testSubmitWhenUserHasNoPermissionsToSubmitJobInQueueShouldRaiseYarnQueueAclsException()
throws IOException, InterruptedException, ClassNotFoundException {
Mockito.spy( YarnQueueAclsVerifier.class );
ConfigurationProxyV2 configurationProxyV2 = Mockito.mock( ConfigurationProxyV2.class );
Cluster cluster = Mockito.mock( Cluster.class );
Job job = Mockito.mock( Job.class );
Mockito.when( configurationProxyV2.getJob() ).thenReturn( job );
Mockito.when( configurationProxyV2.createClusterDescription( Mockito.any( Configuration.class ) ) )
.thenReturn( cluster );
Mockito.when( configurationProxyV2.submit() ).thenCallRealMethod();
Mockito.when( cluster.getQueueAclsForCurrentUser() ).thenReturn( new QueueAclsInfo[] {
new QueueAclsInfo( StringUtils.EMPTY, new String[] {
"ANOTHER_RIGHTS"
} ),
new QueueAclsInfo( StringUtils.EMPTY, new String[] {} )
} );
configurationProxyV2.submit();
}
@Test
public void testSubmitWhenUserHasPermissionsToSubmitJobInQueueShouldExecuteSuccessfully()
throws IOException, InterruptedException, ClassNotFoundException {
Mockito.spy( YarnQueueAclsVerifier.class );
ConfigurationProxyV2 configurationProxyV2 = Mockito.mock( ConfigurationProxyV2.class );
Cluster cluster = Mockito.mock( Cluster.class );
Job job = Mockito.mock( Job.class );
Mockito.when( configurationProxyV2.getJob() ).thenReturn( job );
Mockito.when( configurationProxyV2.createClusterDescription( Mockito.any( Configuration.class ) ) )
.thenReturn( cluster );
Mockito.when( configurationProxyV2.submit() ).thenCallRealMethod();
Mockito.when( cluster.getQueueAclsForCurrentUser() ).thenReturn( new QueueAclsInfo[] {
new QueueAclsInfo( StringUtils.EMPTY, new String[] {
"SUBMIT_APPLICATIONS"
} ),
new QueueAclsInfo( StringUtils.EMPTY, new String[] {} )
} );
Assert.assertNotNull( configurationProxyV2.submit() );
}
public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException,
InterruptedException {
try {
return TypeConverter.fromYarnQueueUserAclsInfo(client
.getQueueAclsInfo());
} catch (YarnException e) {
throw new IOException(e);
}
}
public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException,
InterruptedException {
try {
return TypeConverter.fromYarnQueueUserAclsInfo(client
.getQueueAclsInfo());
} catch (YarnException e) {
throw new IOException(e);
}
}
@Test
public void testVerifyWhenUserHasNoPermissionsForSubmitInAnyQueueShouldReturnFalse() throws Exception {
assertFalse( YarnQueueAclsVerifier.verify( new QueueAclsInfo[] {
new QueueAclsInfo( StringUtils.EMPTY, new String[] {
"ANOTHER_RIGHTS"
} ),
new QueueAclsInfo( StringUtils.EMPTY, new String[] {} )
} ) );
}
@Test
public void testVerifyWhenUserHasPermissionsForSubmitInAnyQueueShouldReturnTrue() throws Exception {
assertTrue( YarnQueueAclsVerifier.verify( new QueueAclsInfo[] {
new QueueAclsInfo( StringUtils.EMPTY, new String[] {
"SUBMIT_APPLICATIONS"
} ),
new QueueAclsInfo( StringUtils.EMPTY, new String[] {} )
} ) );
}
public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException,
InterruptedException {
try {
return TypeConverter.fromYarnQueueUserAclsInfo(
client.getQueueAclsInfo());
} catch (YarnException e) {
throw new IOException(e);
}
}
public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException,
InterruptedException {
try {
return TypeConverter.fromYarnQueueUserAclsInfo(
client.getQueueAclsInfo());
} catch (YarnException e) {
throw new IOException(e);
}
}
@Override
public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException,
InterruptedException {
return resMgrDelegate.getQueueAclsForCurrentUser();
}
@Override
public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException,
InterruptedException {
return resMgrDelegate.getQueueAclsForCurrentUser();
}
/** {@inheritDoc} */
@Override public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException, InterruptedException {
return new QueueAclsInfo[0];
}
@Override
public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException,
InterruptedException {
throw new UnsupportedOperationException();
}
public static boolean verify( QueueAclsInfo[] queueAclsInfos ) throws IOException, InterruptedException {
return queueAclsInfos != null && Arrays.stream( queueAclsInfos ).map( QueueAclsInfo::getOperations )
.flatMap( Arrays::stream ).anyMatch( Predicate.isEqual( QueueACL.SUBMIT_APPLICATIONS.toString() ) );
}
@Override
public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException,
InterruptedException {
return resMgrDelegate.getQueueAclsForCurrentUser();
}
@Override
public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException,
InterruptedException {
return resMgrDelegate.getQueueAclsForCurrentUser();
}
/**
* Gets the Queue ACLs for current user
* @return array of QueueAclsInfo object for current user.
* @throws IOException
*/
public QueueAclsInfo[] getQueueAclsForCurrentUser()
throws IOException, InterruptedException;
/**
* Gets the Queue ACLs for current user
* @return array of QueueAclsInfo object for current user.
* @throws IOException
*/
public QueueAclsInfo[] getQueueAclsForCurrentUser()
throws IOException, InterruptedException;