@Override public RefreshQueuesResponse refreshQueues(RefreshQueuesRequest request) throws YarnException, StandbyException { String argName = "refreshQueues"; final String msg = "refresh queues."; UserGroupInformation user = checkAcls(argName); checkRMStatus(user.getShortUserName(), argName, msg); RefreshQueuesResponse response = recordFactory.newRecordInstance(RefreshQueuesResponse.class); try { refreshQueues(); RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService"); return response; } catch (IOException ioe) { throw logAndWrapException(ioe, user.getShortUserName(), argName, msg); } }
@Override public RefreshQueuesResponse refreshQueues(RefreshQueuesRequest request) throws YarnException, StandbyException { final String operation = "refreshQueues"; final String msg = "refresh queues."; UserGroupInformation user = checkAcls(operation); checkRMStatus(user.getShortUserName(), operation, msg); RefreshQueuesResponse response = recordFactory.newRecordInstance(RefreshQueuesResponse.class); try { if (isSchedulerMutable()) { throw new IOException("Scheduler configuration is mutable. " + operation + " is not allowed in this scenario."); } refreshQueues(); RMAuditLogger.logSuccess(user.getShortUserName(), operation, "AdminService"); return response; } catch (IOException ioe) { throw logAndWrapException(ioe, user.getShortUserName(), operation, msg); } }
@VisibleForTesting void refreshAll() throws ServiceFailedException { try { checkAcls("refreshAll"); refreshQueues(); refreshNodes(); refreshSuperUserGroupsConfiguration(); refreshUserToGroupsMappings(); if (getConfig().getBoolean( CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, false)) { refreshServiceAcls(); } } catch (Exception ex) { throw new ServiceFailedException(ex.getMessage()); } }
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 (Exception ex) { throw new ServiceFailedException(ex.getMessage()); } }
@VisibleForTesting void refreshAll() throws ServiceFailedException { try { checkAcls("refreshAll"); if (isSchedulerMutable()) { try { ((MutableConfScheduler) rm.getRMContext().getScheduler()) .getMutableConfProvider().reloadConfigurationFromStore(); } catch (Exception e) { throw new IOException("Failed to refresh configuration:", e); } } refreshQueues(); refreshNodes(); refreshSuperUserGroupsConfiguration(); refreshUserToGroupsMappings(); if (getConfig().getBoolean( CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, false)) { refreshServiceAcls(); } refreshClusterMaxPriority(); } catch (Exception ex) { throw new ServiceFailedException("RefreshAll operation failed", ex); } }
@Test public void testAdminRefreshQueuesWithMutableSchedulerConfiguration() { configuration.set(YarnConfiguration.SCHEDULER_CONFIGURATION_STORE_CLASS, YarnConfiguration.MEMORY_CONFIGURATION_STORE); try { rm = new MockRM(configuration); rm.init(configuration); rm.start(); } catch (Exception ex) { fail("Should not get any exceptions"); } try { rm.adminService.refreshQueues(RefreshQueuesRequest.newInstance()); fail("Expected exception while calling refreshQueues when scheduler" + " configuration is mutable."); } catch (Exception ex) { assertTrue(ex.getMessage().endsWith("Scheduler configuration is " + "mutable. refreshQueues is not allowed in this scenario.")); } }
@Override public Void run() throws Exception { MutableConfigurationProvider provider = ((MutableConfScheduler) scheduler).getMutableConfProvider(); if (!provider.getAclMutationPolicy().isMutationAllowed(callerUGI, mutationInfo)) { throw new org.apache.hadoop.security.AccessControlException("User" + " is not admin of all modified queues."); } provider.logAndApplyMutation(callerUGI, mutationInfo); try { rm.getRMContext().getRMAdminService().refreshQueues(); } catch (IOException | YarnException e) { provider.confirmPendingMutation(false); throw e; } provider.confirmPendingMutation(true); return null; } });
@Test public void testAdminRefreshQueuesWithLocalConfigurationProvider() throws IOException, YarnException { rm = new MockRM(configuration); rm.init(configuration); rm.start(); CapacityScheduler cs = (CapacityScheduler) rm.getRMContext().getScheduler(); int maxAppsBefore = cs.getConfiguration().getMaximumSystemApplications(); try { rm.adminService.refreshQueues(RefreshQueuesRequest.newInstance()); Assert.assertEquals(maxAppsBefore, cs.getConfiguration() .getMaximumSystemApplications()); } catch (Exception ex) { fail("Using localConfigurationProvider. Should not get any exception."); } }
@Test public void testAdminRefreshQueuesWithLocalConfigurationProvider() throws IOException, YarnException { rm = new MockRM(configuration); rm.init(configuration); rm.start(); CapacityScheduler cs = (CapacityScheduler) rm.getRMContext().getScheduler(); int maxAppsBefore = cs.getConfiguration().getMaximumSystemApplications(); try { rm.adminService.refreshQueues(RefreshQueuesRequest.newInstance()); Assert.assertEquals(maxAppsBefore, cs.getConfiguration() .getMaximumSystemApplications()); } catch (Exception ex) { fail("Using localConfigurationProvider. Should not get any exception."); } }
@Test public void testAdminRefreshQueuesWithFileSystemBasedConfigurationProvider() throws IOException, YarnException { configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS, "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider"); //upload default configurations uploadDefaultConfiguration(); try { rm = new MockRM(configuration); rm.init(configuration); rm.start(); } catch(Exception ex) { fail("Should not get any exceptions"); } CapacityScheduler cs = (CapacityScheduler) rm.getRMContext().getScheduler(); int maxAppsBefore = cs.getConfiguration().getMaximumSystemApplications(); CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(); csConf.set("yarn.scheduler.capacity.maximum-applications", "5000"); uploadConfiguration(csConf, "capacity-scheduler.xml"); rm.adminService.refreshQueues(RefreshQueuesRequest.newInstance()); int maxAppsAfter = cs.getConfiguration().getMaximumSystemApplications(); Assert.assertEquals(maxAppsAfter, 5000); Assert.assertTrue(maxAppsAfter != maxAppsBefore); }
@Test public void testAdminRefreshQueuesWithFileSystemBasedConfigurationProvider() throws IOException, YarnException { configuration.set(YarnConfiguration.RM_CONFIGURATION_PROVIDER_CLASS, "org.apache.hadoop.yarn.FileSystemBasedConfigurationProvider"); //upload default configurations uploadDefaultConfiguration(); try { rm = new MockRM(configuration); rm.init(configuration); rm.start(); } catch(Exception ex) { fail("Should not get any exceptions"); } CapacityScheduler cs = (CapacityScheduler) rm.getRMContext().getScheduler(); int maxAppsBefore = cs.getConfiguration().getMaximumSystemApplications(); CapacitySchedulerConfiguration csConf = new CapacitySchedulerConfiguration(); csConf.set(CapacitySchedulerConfiguration.MAXIMUM_SYSTEM_APPLICATIONS, "5000"); uploadConfiguration(csConf, "capacity-scheduler.xml"); rm.adminService.refreshQueues(RefreshQueuesRequest.newInstance()); int maxAppsAfter = cs.getConfiguration().getMaximumSystemApplications(); Assert.assertEquals(maxAppsAfter, 5000); Assert.assertTrue(maxAppsAfter != maxAppsBefore); }
uploadConfiguration(csConf, "capacity-scheduler.xml"); rm1.adminService.refreshQueues(RefreshQueuesRequest.newInstance());
uploadConfiguration(csConf, "capacity-scheduler.xml"); rm1.adminService.refreshQueues(RefreshQueuesRequest.newInstance());