|
@@ -47,7 +47,6 @@ import org.apache.hadoop.security.authorize.AccessControlList;
|
|
|
import org.apache.hadoop.security.authorize.PolicyProvider;
|
|
|
import org.apache.hadoop.security.authorize.ProxyUsers;
|
|
|
import org.apache.hadoop.service.CompositeService;
|
|
|
-import org.apache.hadoop.yarn.api.records.DecommissionType;
|
|
|
import org.apache.hadoop.yarn.api.records.NodeId;
|
|
|
import org.apache.hadoop.yarn.api.records.ResourceOption;
|
|
|
import org.apache.hadoop.yarn.conf.HAUtil;
|
|
@@ -319,15 +318,7 @@ public class AdminService extends CompositeService implements
|
|
|
|
|
|
UserGroupInformation user = checkAccess("transitionToActive");
|
|
|
checkHaStateChange(reqInfo);
|
|
|
- try {
|
|
|
- rm.transitionToActive();
|
|
|
- } catch (Exception e) {
|
|
|
- RMAuditLogger.logFailure(user.getShortUserName(), "transitionToActive",
|
|
|
- "", "RM",
|
|
|
- "Exception transitioning to active");
|
|
|
- throw new ServiceFailedException(
|
|
|
- "Error when transitioning to Active mode", e);
|
|
|
- }
|
|
|
+
|
|
|
try {
|
|
|
// call all refresh*s for active RM to get the updated configurations.
|
|
|
refreshAll();
|
|
@@ -337,10 +328,22 @@ public class AdminService extends CompositeService implements
|
|
|
.getDispatcher()
|
|
|
.getEventHandler()
|
|
|
.handle(
|
|
|
- new RMFatalEvent(RMFatalEventType.TRANSITION_TO_ACTIVE_FAILED, e));
|
|
|
+ new RMFatalEvent(RMFatalEventType.TRANSITION_TO_ACTIVE_FAILED,
|
|
|
+ e));
|
|
|
throw new ServiceFailedException(
|
|
|
- "Error on refreshAll during transistion to Active", e);
|
|
|
+ "Error on refreshAll during transition to Active", e);
|
|
|
}
|
|
|
+
|
|
|
+ try {
|
|
|
+ rm.transitionToActive();
|
|
|
+ } catch (Exception e) {
|
|
|
+ RMAuditLogger.logFailure(user.getShortUserName(), "transitionToActive",
|
|
|
+ "", "RM",
|
|
|
+ "Exception transitioning to active");
|
|
|
+ throw new ServiceFailedException(
|
|
|
+ "Error when transitioning to Active mode", e);
|
|
|
+ }
|
|
|
+
|
|
|
RMAuditLogger.logSuccess(user.getShortUserName(), "transitionToActive",
|
|
|
"RM");
|
|
|
}
|
|
@@ -408,12 +411,7 @@ public class AdminService extends CompositeService implements
|
|
|
RefreshQueuesResponse response =
|
|
|
recordFactory.newRecordInstance(RefreshQueuesResponse.class);
|
|
|
try {
|
|
|
- rmContext.getScheduler().reinitialize(getConfig(), this.rmContext);
|
|
|
- // refresh the reservation system
|
|
|
- ReservationSystem rSystem = rmContext.getReservationSystem();
|
|
|
- if (rSystem != null) {
|
|
|
- rSystem.reinitialize(getConfig(), rmContext);
|
|
|
- }
|
|
|
+ refreshQueues();
|
|
|
RMAuditLogger.logSuccess(user.getShortUserName(), operation,
|
|
|
"AdminService");
|
|
|
return response;
|
|
@@ -422,6 +420,15 @@ public class AdminService extends CompositeService implements
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void refreshQueues() throws IOException, YarnException {
|
|
|
+ rmContext.getScheduler().reinitialize(getConfig(), this.rmContext);
|
|
|
+ // refresh the reservation system
|
|
|
+ ReservationSystem rSystem = rmContext.getReservationSystem();
|
|
|
+ if (rSystem != null) {
|
|
|
+ rSystem.reinitialize(getConfig(), rmContext);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public RefreshNodesResponse refreshNodes(RefreshNodesRequest request)
|
|
|
throws YarnException, StandbyException {
|
|
@@ -454,6 +461,13 @@ public class AdminService extends CompositeService implements
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void refreshNodes() throws IOException, YarnException {
|
|
|
+ Configuration conf =
|
|
|
+ getConfiguration(new Configuration(false),
|
|
|
+ YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
|
|
|
+ rmContext.getNodesListManager().refreshNodes(conf);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public RefreshSuperUserGroupsConfigurationResponse refreshSuperUserGroupsConfiguration(
|
|
|
RefreshSuperUserGroupsConfigurationRequest request)
|
|
@@ -464,6 +478,16 @@ public class AdminService extends CompositeService implements
|
|
|
checkRMStatus(user.getShortUserName(), operation,
|
|
|
"refresh super-user-groups.");
|
|
|
|
|
|
+ refreshSuperUserGroupsConfiguration();
|
|
|
+ RMAuditLogger.logSuccess(user.getShortUserName(),
|
|
|
+ operation, "AdminService");
|
|
|
+
|
|
|
+ return recordFactory.newRecordInstance(
|
|
|
+ RefreshSuperUserGroupsConfigurationResponse.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void refreshSuperUserGroupsConfiguration()
|
|
|
+ throws IOException, YarnException {
|
|
|
// Accept hadoop common configs in core-site.xml as well as RM specific
|
|
|
// configurations in yarn-site.xml
|
|
|
Configuration conf =
|
|
@@ -472,11 +496,6 @@ public class AdminService extends CompositeService implements
|
|
|
YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
|
|
|
RMServerUtils.processRMProxyUsersConf(conf);
|
|
|
ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
|
|
|
- RMAuditLogger.logSuccess(user.getShortUserName(),
|
|
|
- operation, "AdminService");
|
|
|
-
|
|
|
- return recordFactory.newRecordInstance(
|
|
|
- RefreshSuperUserGroupsConfigurationResponse.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -488,10 +507,7 @@ public class AdminService extends CompositeService implements
|
|
|
|
|
|
checkRMStatus(user.getShortUserName(), operation, "refresh user-groups.");
|
|
|
|
|
|
- Groups.getUserToGroupsMappingService(
|
|
|
- getConfiguration(new Configuration(false),
|
|
|
- YarnConfiguration.CORE_SITE_CONFIGURATION_FILE)).refresh();
|
|
|
-
|
|
|
+ refreshUserToGroupsMappings();
|
|
|
RMAuditLogger.logSuccess(user.getShortUserName(), operation,
|
|
|
"AdminService");
|
|
|
|
|
@@ -499,6 +515,12 @@ public class AdminService extends CompositeService implements
|
|
|
RefreshUserToGroupsMappingsResponse.class);
|
|
|
}
|
|
|
|
|
|
+ private void refreshUserToGroupsMappings() throws IOException, YarnException {
|
|
|
+ Groups.getUserToGroupsMappingService(
|
|
|
+ getConfiguration(new Configuration(false),
|
|
|
+ YarnConfiguration.CORE_SITE_CONFIGURATION_FILE)).refresh();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public RefreshAdminAclsResponse refreshAdminAcls(
|
|
|
RefreshAdminAclsRequest request) throws YarnException, IOException {
|
|
@@ -541,6 +563,14 @@ public class AdminService extends CompositeService implements
|
|
|
|
|
|
checkRMStatus(user.getShortUserName(), operation, "refresh Service ACLs.");
|
|
|
|
|
|
+ refreshServiceAcls();
|
|
|
+ RMAuditLogger.logSuccess(user.getShortUserName(), operation,
|
|
|
+ "AdminService");
|
|
|
+
|
|
|
+ return recordFactory.newRecordInstance(RefreshServiceAclsResponse.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void refreshServiceAcls() throws IOException, YarnException {
|
|
|
PolicyProvider policyProvider = RMPolicyProvider.getInstance();
|
|
|
Configuration conf =
|
|
|
getConfiguration(new Configuration(false),
|
|
@@ -552,11 +582,6 @@ public class AdminService extends CompositeService implements
|
|
|
conf, policyProvider);
|
|
|
rmContext.getResourceTrackerService().refreshServiceAcls(
|
|
|
conf, policyProvider);
|
|
|
-
|
|
|
- RMAuditLogger.logSuccess(user.getShortUserName(), operation,
|
|
|
- "AdminService");
|
|
|
-
|
|
|
- return recordFactory.newRecordInstance(RefreshServiceAclsResponse.class);
|
|
|
}
|
|
|
|
|
|
private synchronized void refreshServiceAcls(Configuration configuration,
|
|
@@ -691,18 +716,17 @@ public class AdminService extends CompositeService implements
|
|
|
@VisibleForTesting
|
|
|
void refreshAll() throws ServiceFailedException {
|
|
|
try {
|
|
|
- refreshQueues(RefreshQueuesRequest.newInstance());
|
|
|
- refreshNodes(RefreshNodesRequest.newInstance(DecommissionType.NORMAL));
|
|
|
- refreshSuperUserGroupsConfiguration(
|
|
|
- RefreshSuperUserGroupsConfigurationRequest.newInstance());
|
|
|
- refreshUserToGroupsMappings(
|
|
|
- RefreshUserToGroupsMappingsRequest.newInstance());
|
|
|
+ checkAcls("refreshAll");
|
|
|
+ refreshQueues();
|
|
|
+ refreshNodes();
|
|
|
+ refreshSuperUserGroupsConfiguration();
|
|
|
+ refreshUserToGroupsMappings();
|
|
|
if (getConfig().getBoolean(
|
|
|
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION,
|
|
|
false)) {
|
|
|
- refreshServiceAcls(RefreshServiceAclsRequest.newInstance());
|
|
|
+ refreshServiceAcls();
|
|
|
}
|
|
|
- refreshClusterMaxPriority(RefreshClusterMaxPriorityRequest.newInstance());
|
|
|
+ refreshClusterMaxPriority();
|
|
|
} catch (Exception ex) {
|
|
|
throw new ServiceFailedException(ex.getMessage());
|
|
|
}
|
|
@@ -839,11 +863,7 @@ public class AdminService extends CompositeService implements
|
|
|
|
|
|
checkRMStatus(user.getShortUserName(), operation, msg);
|
|
|
try {
|
|
|
- Configuration conf =
|
|
|
- getConfiguration(new Configuration(false),
|
|
|
- YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
|
|
|
-
|
|
|
- rmContext.getScheduler().setClusterMaxPriority(conf);
|
|
|
+ refreshClusterMaxPriority();
|
|
|
|
|
|
RMAuditLogger
|
|
|
.logSuccess(user.getShortUserName(), operation, "AdminService");
|
|
@@ -854,6 +874,14 @@ public class AdminService extends CompositeService implements
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void refreshClusterMaxPriority() throws IOException, YarnException {
|
|
|
+ Configuration conf =
|
|
|
+ getConfiguration(new Configuration(false),
|
|
|
+ YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
|
|
|
+
|
|
|
+ rmContext.getScheduler().setClusterMaxPriority(conf);
|
|
|
+ }
|
|
|
+
|
|
|
public String getHAZookeeperConnectionState() {
|
|
|
if (!rmContext.isHAEnabled()) {
|
|
|
return "ResourceManager HA is not enabled.";
|