YARN-4883. Make consistent operation name in AdminService. Contributed by Kai Sasaki.

(cherry picked from commit c63afdbe14)
(cherry picked from commit 2bf5c4eb1a)
This commit is contained in:
Akira Ajisaka 2016-07-20 16:51:01 -07:00
parent 35885e9540
commit 66f3056090
1 changed files with 65 additions and 61 deletions

View File

@ -115,7 +115,7 @@ public class AdminService extends CompositeService implements
private YarnAuthorizationProvider authorizer; private YarnAuthorizationProvider authorizer;
private final RecordFactory recordFactory = private final RecordFactory recordFactory =
RecordFactoryProvider.getRecordFactory(null); RecordFactoryProvider.getRecordFactory(null);
private UserGroupInformation daemonUser; private UserGroupInformation daemonUser;
@ -382,11 +382,11 @@ public class AdminService extends CompositeService implements
@Override @Override
public RefreshQueuesResponse refreshQueues(RefreshQueuesRequest request) public RefreshQueuesResponse refreshQueues(RefreshQueuesRequest request)
throws YarnException, StandbyException { throws YarnException, StandbyException {
String argName = "refreshQueues"; final String operation = "refreshQueues";
final String msg = "refresh queues."; final String msg = "refresh queues.";
UserGroupInformation user = checkAcls(argName); UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, msg); checkRMStatus(user.getShortUserName(), operation, msg);
RefreshQueuesResponse response = RefreshQueuesResponse response =
recordFactory.newRecordInstance(RefreshQueuesResponse.class); recordFactory.newRecordInstance(RefreshQueuesResponse.class);
@ -397,22 +397,22 @@ public class AdminService extends CompositeService implements
if (rSystem != null) { if (rSystem != null) {
rSystem.reinitialize(getConfig(), rmContext); rSystem.reinitialize(getConfig(), rmContext);
} }
RMAuditLogger.logSuccess(user.getShortUserName(), argName, RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService"); "AdminService");
return response; return response;
} catch (IOException ioe) { } catch (IOException ioe) {
throw logAndWrapException(ioe, user.getShortUserName(), argName, msg); throw logAndWrapException(ioe, user.getShortUserName(), operation, msg);
} }
} }
@Override @Override
public RefreshNodesResponse refreshNodes(RefreshNodesRequest request) public RefreshNodesResponse refreshNodes(RefreshNodesRequest request)
throws YarnException, StandbyException { throws YarnException, StandbyException {
String argName = "refreshNodes"; final String operation = "refreshNodes";
final String msg = "refresh nodes."; final String msg = "refresh nodes.";
UserGroupInformation user = checkAcls("refreshNodes"); UserGroupInformation user = checkAcls("refreshNodes");
checkRMStatus(user.getShortUserName(), argName, msg); checkRMStatus(user.getShortUserName(), operation, msg);
try { try {
Configuration conf = Configuration conf =
@ -429,11 +429,11 @@ public class AdminService extends CompositeService implements
rmContext.getNodesListManager().refreshNodesForcefully(); rmContext.getNodesListManager().refreshNodesForcefully();
break; break;
} }
RMAuditLogger.logSuccess(user.getShortUserName(), argName, RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService"); "AdminService");
return recordFactory.newRecordInstance(RefreshNodesResponse.class); return recordFactory.newRecordInstance(RefreshNodesResponse.class);
} catch (IOException ioe) { } catch (IOException ioe) {
throw logAndWrapException(ioe, user.getShortUserName(), argName, msg); throw logAndWrapException(ioe, user.getShortUserName(), operation, msg);
} }
} }
@ -441,10 +441,11 @@ public class AdminService extends CompositeService implements
public RefreshSuperUserGroupsConfigurationResponse refreshSuperUserGroupsConfiguration( public RefreshSuperUserGroupsConfigurationResponse refreshSuperUserGroupsConfiguration(
RefreshSuperUserGroupsConfigurationRequest request) RefreshSuperUserGroupsConfigurationRequest request)
throws YarnException, IOException { throws YarnException, IOException {
String argName = "refreshSuperUserGroupsConfiguration"; final String operation = "refreshSuperUserGroupsConfiguration";
UserGroupInformation user = checkAcls(argName); UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, "refresh super-user-groups."); checkRMStatus(user.getShortUserName(), operation,
"refresh super-user-groups.");
// Accept hadoop common configs in core-site.xml as well as RM specific // Accept hadoop common configs in core-site.xml as well as RM specific
// configurations in yarn-site.xml // configurations in yarn-site.xml
@ -455,8 +456,8 @@ public class AdminService extends CompositeService implements
RMServerUtils.processRMProxyUsersConf(conf); RMServerUtils.processRMProxyUsersConf(conf);
ProxyUsers.refreshSuperUserGroupsConfiguration(conf); ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
RMAuditLogger.logSuccess(user.getShortUserName(), RMAuditLogger.logSuccess(user.getShortUserName(),
argName, "AdminService"); operation, "AdminService");
return recordFactory.newRecordInstance( return recordFactory.newRecordInstance(
RefreshSuperUserGroupsConfigurationResponse.class); RefreshSuperUserGroupsConfigurationResponse.class);
} }
@ -465,16 +466,17 @@ public class AdminService extends CompositeService implements
public RefreshUserToGroupsMappingsResponse refreshUserToGroupsMappings( public RefreshUserToGroupsMappingsResponse refreshUserToGroupsMappings(
RefreshUserToGroupsMappingsRequest request) RefreshUserToGroupsMappingsRequest request)
throws YarnException, IOException { throws YarnException, IOException {
String argName = "refreshUserToGroupsMappings"; final String operation = "refreshUserToGroupsMappings";
UserGroupInformation user = checkAcls(argName); UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, "refresh user-groups."); checkRMStatus(user.getShortUserName(), operation, "refresh user-groups.");
Groups.getUserToGroupsMappingService( Groups.getUserToGroupsMappingService(
getConfiguration(new Configuration(false), getConfiguration(new Configuration(false),
YarnConfiguration.CORE_SITE_CONFIGURATION_FILE)).refresh(); YarnConfiguration.CORE_SITE_CONFIGURATION_FILE)).refresh();
RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService"); RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
return recordFactory.newRecordInstance( return recordFactory.newRecordInstance(
RefreshUserToGroupsMappingsResponse.class); RefreshUserToGroupsMappingsResponse.class);
@ -488,18 +490,18 @@ public class AdminService extends CompositeService implements
private RefreshAdminAclsResponse refreshAdminAcls(boolean checkRMHAState) private RefreshAdminAclsResponse refreshAdminAcls(boolean checkRMHAState)
throws YarnException, IOException { throws YarnException, IOException {
String argName = "refreshAdminAcls"; final String operation = "refreshAdminAcls";
UserGroupInformation user = checkAcls(argName); UserGroupInformation user = checkAcls(operation);
if (checkRMHAState) { if (checkRMHAState) {
checkRMStatus(user.getShortUserName(), argName, "refresh Admin ACLs."); checkRMStatus(user.getShortUserName(), operation, "refresh Admin ACLs.");
} }
Configuration conf = Configuration conf =
getConfiguration(new Configuration(false), getConfiguration(new Configuration(false),
YarnConfiguration.YARN_SITE_CONFIGURATION_FILE); YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
authorizer.setAdmins(getAdminAclList(conf), UserGroupInformation authorizer.setAdmins(getAdminAclList(conf), UserGroupInformation
.getCurrentUser()); .getCurrentUser());
RMAuditLogger.logSuccess(user.getShortUserName(), argName, RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService"); "AdminService");
return recordFactory.newRecordInstance(RefreshAdminAclsResponse.class); return recordFactory.newRecordInstance(RefreshAdminAclsResponse.class);
@ -509,18 +511,18 @@ public class AdminService extends CompositeService implements
public RefreshServiceAclsResponse refreshServiceAcls( public RefreshServiceAclsResponse refreshServiceAcls(
RefreshServiceAclsRequest request) throws YarnException, IOException { RefreshServiceAclsRequest request) throws YarnException, IOException {
if (!getConfig().getBoolean( if (!getConfig().getBoolean(
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION,
false)) { false)) {
throw RPCUtil.getRemoteException( throw RPCUtil.getRemoteException(
new IOException("Service Authorization (" + new IOException("Service Authorization (" +
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION + CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION +
") not enabled.")); ") not enabled."));
} }
String argName = "refreshServiceAcls"; final String operation = "refreshServiceAcls";
UserGroupInformation user = checkAcls(argName); UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, "refresh Service ACLs."); checkRMStatus(user.getShortUserName(), operation, "refresh Service ACLs.");
PolicyProvider policyProvider = RMPolicyProvider.getInstance(); PolicyProvider policyProvider = RMPolicyProvider.getInstance();
Configuration conf = Configuration conf =
@ -534,7 +536,8 @@ public class AdminService extends CompositeService implements
rmContext.getResourceTrackerService().refreshServiceAcls( rmContext.getResourceTrackerService().refreshServiceAcls(
conf, policyProvider); conf, policyProvider);
RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService"); RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
return recordFactory.newRecordInstance(RefreshServiceAclsResponse.class); return recordFactory.newRecordInstance(RefreshServiceAclsResponse.class);
} }
@ -554,14 +557,14 @@ public class AdminService extends CompositeService implements
@Override @Override
public UpdateNodeResourceResponse updateNodeResource( public UpdateNodeResourceResponse updateNodeResource(
UpdateNodeResourceRequest request) throws YarnException, IOException { UpdateNodeResourceRequest request) throws YarnException, IOException {
String argName = "updateNodeResource"; final String operation = "updateNodeResource";
UserGroupInformation user = checkAcls(argName); UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, "update node resource."); checkRMStatus(user.getShortUserName(), operation, "update node resource.");
Map<NodeId, ResourceOption> nodeResourceMap = request.getNodeResourceMap(); Map<NodeId, ResourceOption> nodeResourceMap = request.getNodeResourceMap();
Set<NodeId> nodeIds = nodeResourceMap.keySet(); Set<NodeId> nodeIds = nodeResourceMap.keySet();
// verify nodes are all valid first. // verify nodes are all valid first.
// if any invalid nodes, throw exception instead of partially updating // if any invalid nodes, throw exception instead of partially updating
// valid nodes. // valid nodes.
for (NodeId nodeId : nodeIds) { for (NodeId nodeId : nodeIds) {
@ -574,7 +577,7 @@ public class AdminService extends CompositeService implements
+ "on an unrecognized node: " + nodeId); + "on an unrecognized node: " + nodeId);
} }
} }
// do resource update on each node. // do resource update on each node.
// Notice: it is still possible to have invalid NodeIDs as nodes decommission // Notice: it is still possible to have invalid NodeIDs as nodes decommission
// may happen just at the same time. This time, only log and skip absent // may happen just at the same time. This time, only log and skip absent
@ -584,7 +587,7 @@ public class AdminService extends CompositeService implements
ResourceOption newResourceOption = entry.getValue(); ResourceOption newResourceOption = entry.getValue();
NodeId nodeId = entry.getKey(); NodeId nodeId = entry.getKey();
RMNode node = this.rmContext.getRMNodes().get(nodeId); RMNode node = this.rmContext.getRMNodes().get(nodeId);
if (node == null) { if (node == null) {
LOG.warn("Resource update get failed on an unrecognized node: " + nodeId); LOG.warn("Resource update get failed on an unrecognized node: " + nodeId);
allSuccess = false; allSuccess = false;
@ -598,10 +601,10 @@ public class AdminService extends CompositeService implements
} }
} }
if (allSuccess) { if (allSuccess) {
RMAuditLogger.logSuccess(user.getShortUserName(), argName, RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService"); "AdminService");
} }
UpdateNodeResourceResponse response = UpdateNodeResourceResponse response =
UpdateNodeResourceResponse.newInstance(); UpdateNodeResourceResponse.newInstance();
return response; return response;
} }
@ -610,11 +613,11 @@ public class AdminService extends CompositeService implements
public RefreshNodesResourcesResponse refreshNodesResources( public RefreshNodesResourcesResponse refreshNodesResources(
RefreshNodesResourcesRequest request) RefreshNodesResourcesRequest request)
throws YarnException, StandbyException { throws YarnException, StandbyException {
String argName = "refreshNodesResources"; final String operation = "refreshNodesResources";
UserGroupInformation user = checkAcls(argName); UserGroupInformation user = checkAcls(operation);
final String msg = "refresh nodes."; final String msg = "refresh nodes.";
checkRMStatus(user.getShortUserName(), argName, msg); checkRMStatus(user.getShortUserName(), operation, msg);
RefreshNodesResourcesResponse response = RefreshNodesResourcesResponse response =
recordFactory.newRecordInstance(RefreshNodesResourcesResponse.class); recordFactory.newRecordInstance(RefreshNodesResourcesResponse.class);
@ -645,11 +648,11 @@ public class AdminService extends CompositeService implements
// refresh dynamic resource in ResourceTrackerService // refresh dynamic resource in ResourceTrackerService
this.rmContext.getResourceTrackerService(). this.rmContext.getResourceTrackerService().
updateDynamicResourceConfiguration(newConf); updateDynamicResourceConfiguration(newConf);
RMAuditLogger.logSuccess(user.getShortUserName(), argName, RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService"); "AdminService");
return response; return response;
} catch (IOException ioe) { } catch (IOException ioe) {
throw logAndWrapException(ioe, user.getShortUserName(), argName, msg); throw logAndWrapException(ioe, user.getShortUserName(), operation, msg);
} }
} }
@ -698,28 +701,28 @@ public class AdminService extends CompositeService implements
@Override @Override
public AddToClusterNodeLabelsResponse addToClusterNodeLabels(AddToClusterNodeLabelsRequest request) public AddToClusterNodeLabelsResponse addToClusterNodeLabels(AddToClusterNodeLabelsRequest request)
throws YarnException, IOException { throws YarnException, IOException {
String argName = "addToClusterNodeLabels"; final String operation = "addToClusterNodeLabels";
final String msg = "add labels."; final String msg = "add labels.";
UserGroupInformation user = checkAcls(argName); UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, msg); checkRMStatus(user.getShortUserName(), operation, msg);
AddToClusterNodeLabelsResponse response = AddToClusterNodeLabelsResponse response =
recordFactory.newRecordInstance(AddToClusterNodeLabelsResponse.class); recordFactory.newRecordInstance(AddToClusterNodeLabelsResponse.class);
try { try {
rmContext.getNodeLabelManager().addToCluserNodeLabels(request.getNodeLabels()); rmContext.getNodeLabelManager().addToCluserNodeLabels(request.getNodeLabels());
RMAuditLogger RMAuditLogger
.logSuccess(user.getShortUserName(), argName, "AdminService"); .logSuccess(user.getShortUserName(), operation, "AdminService");
return response; return response;
} catch (IOException ioe) { } catch (IOException ioe) {
throw logAndWrapException(ioe, user.getShortUserName(), argName, msg); throw logAndWrapException(ioe, user.getShortUserName(), operation, msg);
} }
} }
@Override @Override
public RemoveFromClusterNodeLabelsResponse removeFromClusterNodeLabels( public RemoveFromClusterNodeLabelsResponse removeFromClusterNodeLabels(
RemoveFromClusterNodeLabelsRequest request) throws YarnException, IOException { RemoveFromClusterNodeLabelsRequest request) throws YarnException, IOException {
String operation = "removeFromClusterNodeLabels"; final String operation = "removeFromClusterNodeLabels";
final String msg = "remove labels."; final String msg = "remove labels.";
UserGroupInformation user = checkAcls(operation); UserGroupInformation user = checkAcls(operation);
@ -741,7 +744,7 @@ public class AdminService extends CompositeService implements
@Override @Override
public ReplaceLabelsOnNodeResponse replaceLabelsOnNode( public ReplaceLabelsOnNodeResponse replaceLabelsOnNode(
ReplaceLabelsOnNodeRequest request) throws YarnException, IOException { ReplaceLabelsOnNodeRequest request) throws YarnException, IOException {
String operation = "replaceLabelsOnNode"; final String operation = "replaceLabelsOnNode";
final String msg = "set node to labels."; final String msg = "set node to labels.";
try { try {
@ -789,15 +792,16 @@ public class AdminService extends CompositeService implements
public CheckForDecommissioningNodesResponse checkForDecommissioningNodes( public CheckForDecommissioningNodesResponse checkForDecommissioningNodes(
CheckForDecommissioningNodesRequest checkForDecommissioningNodesRequest) CheckForDecommissioningNodesRequest checkForDecommissioningNodesRequest)
throws IOException, YarnException { throws IOException, YarnException {
String argName = "checkForDecommissioningNodes"; final String operation = "checkForDecommissioningNodes";
final String msg = "check for decommissioning nodes."; final String msg = "check for decommissioning nodes.";
UserGroupInformation user = checkAcls("checkForDecommissioningNodes"); UserGroupInformation user = checkAcls("checkForDecommissioningNodes");
checkRMStatus(user.getShortUserName(), argName, msg); checkRMStatus(user.getShortUserName(), operation, msg);
Set<NodeId> decommissioningNodes = rmContext.getNodesListManager() Set<NodeId> decommissioningNodes = rmContext.getNodesListManager()
.checkForDecommissioningNodes(); .checkForDecommissioningNodes();
RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService"); RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
CheckForDecommissioningNodesResponse response = recordFactory CheckForDecommissioningNodesResponse response = recordFactory
.newRecordInstance(CheckForDecommissioningNodesResponse.class); .newRecordInstance(CheckForDecommissioningNodesResponse.class);
response.setDecommissioningNodes(decommissioningNodes); response.setDecommissioningNodes(decommissioningNodes);
@ -808,11 +812,11 @@ public class AdminService extends CompositeService implements
public RefreshClusterMaxPriorityResponse refreshClusterMaxPriority( public RefreshClusterMaxPriorityResponse refreshClusterMaxPriority(
RefreshClusterMaxPriorityRequest request) throws YarnException, RefreshClusterMaxPriorityRequest request) throws YarnException,
IOException { IOException {
String argName = "refreshClusterMaxPriority"; final String operation = "refreshClusterMaxPriority";
String msg = "refresh cluster max priority"; final String msg = "refresh cluster max priority";
UserGroupInformation user = checkAcls(argName); UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, msg); checkRMStatus(user.getShortUserName(), operation, msg);
try { try {
Configuration conf = Configuration conf =
getConfiguration(new Configuration(false), getConfiguration(new Configuration(false),
@ -821,11 +825,11 @@ public class AdminService extends CompositeService implements
rmContext.getScheduler().setClusterMaxPriority(conf); rmContext.getScheduler().setClusterMaxPriority(conf);
RMAuditLogger RMAuditLogger
.logSuccess(user.getShortUserName(), argName, "AdminService"); .logSuccess(user.getShortUserName(), operation, "AdminService");
return recordFactory return recordFactory
.newRecordInstance(RefreshClusterMaxPriorityResponse.class); .newRecordInstance(RefreshClusterMaxPriorityResponse.class);
} catch (YarnException e) { } catch (YarnException e) {
throw logAndWrapException(e, user.getShortUserName(), argName, msg); throw logAndWrapException(e, user.getShortUserName(), operation, msg);
} }
} }