private void refreshAll() throws ServiceFailedException { try { refreshQueues(RefreshQueuesRequest.newInstance()); refreshNodes(RefreshNodesRequest.newInstance()); refreshSuperUserGroupsConfiguration(RefreshSuperUserGroupsConfigurationRequest.newInstance()); refreshUserToGroupsMappings(RefreshUserToGroupsMappingsRequest.newInstance()); if (getConfig() .getBoolean(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, false)) { refreshServiceAcls(RefreshServiceAclsRequest.newInstance()); } } catch (YarnException ex) { throw new ServiceFailedException(ex.getMessage()); } catch (IOException ex) { throw new ServiceFailedException(ex.getMessage()); } }
@Test public void testServiceAclsRefreshWithLocalConfigurationProvider() { configuration.setBoolean(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, true); ResourceManager resourceManager = null; try { resourceManager = new ResourceManager(); resourceManager.init(configuration); resourceManager.start(); resourceManager.adminService.refreshServiceAcls(RefreshServiceAclsRequest.newInstance()); } catch (Exception ex) { fail("Using localConfigurationProvider. Should not get any exception."); } finally { if (resourceManager != null) { resourceManager.stop(); } } }
@Test public void testServiceAclsRefreshWithFileSystemBasedConfigurationProvider() throws IOException, YarnException { configuration.setBoolean(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, true); configuration.set( YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS, "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider"); ResourceManager resourceManager = null; try { // upload default configurations uploadDefaultConfiguration(); Configuration conf = new Configuration(); conf.setBoolean(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, true); uploadConfiguration(conf, "core-site.xml"); try { resourceManager = new ResourceManager(); resourceManager.init(configuration); resourceManager.start(); } catch (Exception ex) { fail("Should not get any exceptions"); } String aclsString = "alice,bob users,wheel"; Configuration newConf = new Configuration(); newConf.set("security.applicationclient.protocol.acl", aclsString); uploadConfiguration(newConf, "hadoop-policy.xml"); resourceManager.adminService.refreshServiceAcls(RefreshServiceAclsRequest.newInstance()); // verify service Acls refresh for AdminService ServiceAuthorizationManager adminServiceServiceManager = resourceManager.adminService.getServer().getServiceAuthorizationManager(); verifyServiceACLsRefresh( adminServiceServiceManager, org.apache.hadoop.yarn.api.ApplicationClientProtocolPB.class, aclsString); // verify service ACLs refresh for ClientRMService ServiceAuthorizationManager clientRMServiceServiceManager = resourceManager .getRMContext() .getClientRMService() .getServer() .getServiceAuthorizationManager(); verifyServiceACLsRefresh( clientRMServiceServiceManager, org.apache.hadoop.yarn.api.ApplicationClientProtocolPB.class, aclsString); // verify service ACLs refresh for ApplicationMasterService ServiceAuthorizationManager appMasterService = resourceManager .getRMContext() .getApplicationMasterService() .getServer() .getServiceAuthorizationManager(); verifyServiceACLsRefresh( appMasterService, org.apache.hadoop.yarn.api.ApplicationClientProtocolPB.class, aclsString); // verify service ACLs refresh for ResourceTrackerService ServiceAuthorizationManager RTService = resourceManager .getRMContext() .getResourceTrackerService() .getServer() .getServiceAuthorizationManager(); verifyServiceACLsRefresh( RTService, org.apache.hadoop.yarn.api.ApplicationClientProtocolPB.class, aclsString); } finally { if (resourceManager != null) { resourceManager.stop(); } } }