Example usage for org.apache.hadoop.mapred JobClient getQueueAclsForCurrentUser

List of usage examples for org.apache.hadoop.mapred JobClient getQueueAclsForCurrentUser

Introduction

In this page you can find the example usage for org.apache.hadoop.mapred JobClient getQueueAclsForCurrentUser.

Prototype

public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException 

Source Link

Document

Gets the Queue ACLs for current user

Usage

From source file:org.pentaho.hadoop.shim.common.ConfigurationProxy.java

License:Apache License

/**
 * Submit job for the current configuration provided by this implementation.
 *
 * @return RunningJob implementation//from  ww w. j  a  va 2 s  . c o  m
 */
@Override
public RunningJob submit() throws IOException, ClassNotFoundException, InterruptedException {
    JobClient jobClient = createJobClient();
    if (YarnQueueAclsVerifier.verify(jobClient.getQueueAclsForCurrentUser())) {
        return new RunningJobProxy(jobClient.submitJob(this));
    } else {
        throw new YarnQueueAclsException(
                BaseMessages.getString(ConfigurationProxy.class, "ConfigurationProxy.UserHasNoPermissions",
                        UserGroupInformation.getCurrentUser().getUserName()));
    }
}

From source file:org.pentaho.hadoop.shim.common.ConfigurationProxyTest.java

License:Apache License

@Test(expected = YarnQueueAclsException.class)
public void testSubmitWhenUserHasNoPermissionsToSubmitJobInQueueShouldRaiseYarnQueueAclsException()
        throws IOException, InterruptedException, ClassNotFoundException {
    Mockito.spy(YarnQueueAclsVerifier.class);
    ConfigurationProxy configurationProxy = Mockito.mock(ConfigurationProxy.class);
    JobClient jobClient = Mockito.mock(JobClient.class);

    Mockito.when(configurationProxy.createJobClient()).thenReturn(jobClient);
    Mockito.when(configurationProxy.submit()).thenCallRealMethod();
    Mockito.when(jobClient.getQueueAclsForCurrentUser())
            .thenReturn(new MockQueueAclsInfo[] {
                    new MockQueueAclsInfo(StringUtils.EMPTY, new String[] { "ANOTHER_RIGHTS" }),
                    new MockQueueAclsInfo(StringUtils.EMPTY, new String[] {}) });

    configurationProxy.submit();//from  w w  w .  j  ava 2  s.com
}

From source file:org.pentaho.hadoop.shim.common.ConfigurationProxyTest.java

License:Apache License

@Test
public void testSubmitWhenUserHasPermissionsToSubmitJobInQueueShouldExecuteSuccessfully()
        throws IOException, InterruptedException, ClassNotFoundException {
    Mockito.spy(YarnQueueAclsVerifier.class);
    ConfigurationProxy configurationProxy = Mockito.mock(ConfigurationProxy.class);
    JobClient jobClient = Mockito.mock(JobClient.class);
    RunningJob runningJob = Mockito.mock(RunningJob.class);

    Mockito.when(configurationProxy.createJobClient()).thenReturn(jobClient);
    Mockito.when(configurationProxy.submit()).thenCallRealMethod();
    Mockito.when(jobClient.getQueueAclsForCurrentUser())
            .thenReturn(new MockQueueAclsInfo[] {
                    new MockQueueAclsInfo(StringUtils.EMPTY, new String[] { "SUBMIT_APPLICATIONS" }),
                    new MockQueueAclsInfo(StringUtils.EMPTY, new String[] {}) });
    Mockito.when(jobClient.submitJob(Mockito.any(JobConf.class))).thenReturn(runningJob);

    Assert.assertNotNull(configurationProxy.submit());
}