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

@ -382,11 +382,11 @@ public class AdminService extends CompositeService implements
@Override
public RefreshQueuesResponse refreshQueues(RefreshQueuesRequest request)
throws YarnException, StandbyException {
String argName = "refreshQueues";
final String operation = "refreshQueues";
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 =
recordFactory.newRecordInstance(RefreshQueuesResponse.class);
@ -397,22 +397,22 @@ public class AdminService extends CompositeService implements
if (rSystem != null) {
rSystem.reinitialize(getConfig(), rmContext);
}
RMAuditLogger.logSuccess(user.getShortUserName(), argName,
RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
return response;
} catch (IOException ioe) {
throw logAndWrapException(ioe, user.getShortUserName(), argName, msg);
throw logAndWrapException(ioe, user.getShortUserName(), operation, msg);
}
}
@Override
public RefreshNodesResponse refreshNodes(RefreshNodesRequest request)
throws YarnException, StandbyException {
String argName = "refreshNodes";
final String operation = "refreshNodes";
final String msg = "refresh nodes.";
UserGroupInformation user = checkAcls("refreshNodes");
checkRMStatus(user.getShortUserName(), argName, msg);
checkRMStatus(user.getShortUserName(), operation, msg);
try {
Configuration conf =
@ -429,11 +429,11 @@ public class AdminService extends CompositeService implements
rmContext.getNodesListManager().refreshNodesForcefully();
break;
}
RMAuditLogger.logSuccess(user.getShortUserName(), argName,
RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
return recordFactory.newRecordInstance(RefreshNodesResponse.class);
} 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(
RefreshSuperUserGroupsConfigurationRequest request)
throws YarnException, IOException {
String argName = "refreshSuperUserGroupsConfiguration";
UserGroupInformation user = checkAcls(argName);
final String operation = "refreshSuperUserGroupsConfiguration";
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
// configurations in yarn-site.xml
@ -455,7 +456,7 @@ public class AdminService extends CompositeService implements
RMServerUtils.processRMProxyUsersConf(conf);
ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
RMAuditLogger.logSuccess(user.getShortUserName(),
argName, "AdminService");
operation, "AdminService");
return recordFactory.newRecordInstance(
RefreshSuperUserGroupsConfigurationResponse.class);
@ -465,16 +466,17 @@ public class AdminService extends CompositeService implements
public RefreshUserToGroupsMappingsResponse refreshUserToGroupsMappings(
RefreshUserToGroupsMappingsRequest request)
throws YarnException, IOException {
String argName = "refreshUserToGroupsMappings";
UserGroupInformation user = checkAcls(argName);
final String operation = "refreshUserToGroupsMappings";
UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, "refresh user-groups.");
checkRMStatus(user.getShortUserName(), operation, "refresh user-groups.");
Groups.getUserToGroupsMappingService(
getConfiguration(new Configuration(false),
YarnConfiguration.CORE_SITE_CONFIGURATION_FILE)).refresh();
RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService");
RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
return recordFactory.newRecordInstance(
RefreshUserToGroupsMappingsResponse.class);
@ -488,18 +490,18 @@ public class AdminService extends CompositeService implements
private RefreshAdminAclsResponse refreshAdminAcls(boolean checkRMHAState)
throws YarnException, IOException {
String argName = "refreshAdminAcls";
UserGroupInformation user = checkAcls(argName);
final String operation = "refreshAdminAcls";
UserGroupInformation user = checkAcls(operation);
if (checkRMHAState) {
checkRMStatus(user.getShortUserName(), argName, "refresh Admin ACLs.");
checkRMStatus(user.getShortUserName(), operation, "refresh Admin ACLs.");
}
Configuration conf =
getConfiguration(new Configuration(false),
YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
authorizer.setAdmins(getAdminAclList(conf), UserGroupInformation
.getCurrentUser());
RMAuditLogger.logSuccess(user.getShortUserName(), argName,
RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
return recordFactory.newRecordInstance(RefreshAdminAclsResponse.class);
@ -517,10 +519,10 @@ public class AdminService extends CompositeService implements
") not enabled."));
}
String argName = "refreshServiceAcls";
UserGroupInformation user = checkAcls(argName);
final String operation = "refreshServiceAcls";
UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, "refresh Service ACLs.");
checkRMStatus(user.getShortUserName(), operation, "refresh Service ACLs.");
PolicyProvider policyProvider = RMPolicyProvider.getInstance();
Configuration conf =
@ -534,7 +536,8 @@ public class AdminService extends CompositeService implements
rmContext.getResourceTrackerService().refreshServiceAcls(
conf, policyProvider);
RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService");
RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
return recordFactory.newRecordInstance(RefreshServiceAclsResponse.class);
}
@ -554,10 +557,10 @@ public class AdminService extends CompositeService implements
@Override
public UpdateNodeResourceResponse updateNodeResource(
UpdateNodeResourceRequest request) throws YarnException, IOException {
String argName = "updateNodeResource";
UserGroupInformation user = checkAcls(argName);
final String operation = "updateNodeResource";
UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, "update node resource.");
checkRMStatus(user.getShortUserName(), operation, "update node resource.");
Map<NodeId, ResourceOption> nodeResourceMap = request.getNodeResourceMap();
Set<NodeId> nodeIds = nodeResourceMap.keySet();
@ -598,7 +601,7 @@ public class AdminService extends CompositeService implements
}
}
if (allSuccess) {
RMAuditLogger.logSuccess(user.getShortUserName(), argName,
RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
}
UpdateNodeResourceResponse response =
@ -610,11 +613,11 @@ public class AdminService extends CompositeService implements
public RefreshNodesResourcesResponse refreshNodesResources(
RefreshNodesResourcesRequest request)
throws YarnException, StandbyException {
String argName = "refreshNodesResources";
UserGroupInformation user = checkAcls(argName);
final String operation = "refreshNodesResources";
UserGroupInformation user = checkAcls(operation);
final String msg = "refresh nodes.";
checkRMStatus(user.getShortUserName(), argName, msg);
checkRMStatus(user.getShortUserName(), operation, msg);
RefreshNodesResourcesResponse response =
recordFactory.newRecordInstance(RefreshNodesResourcesResponse.class);
@ -645,11 +648,11 @@ public class AdminService extends CompositeService implements
// refresh dynamic resource in ResourceTrackerService
this.rmContext.getResourceTrackerService().
updateDynamicResourceConfiguration(newConf);
RMAuditLogger.logSuccess(user.getShortUserName(), argName,
RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
return response;
} 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
public AddToClusterNodeLabelsResponse addToClusterNodeLabels(AddToClusterNodeLabelsRequest request)
throws YarnException, IOException {
String argName = "addToClusterNodeLabels";
final String operation = "addToClusterNodeLabels";
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 =
recordFactory.newRecordInstance(AddToClusterNodeLabelsResponse.class);
try {
rmContext.getNodeLabelManager().addToCluserNodeLabels(request.getNodeLabels());
RMAuditLogger
.logSuccess(user.getShortUserName(), argName, "AdminService");
.logSuccess(user.getShortUserName(), operation, "AdminService");
return response;
} catch (IOException ioe) {
throw logAndWrapException(ioe, user.getShortUserName(), argName, msg);
throw logAndWrapException(ioe, user.getShortUserName(), operation, msg);
}
}
@Override
public RemoveFromClusterNodeLabelsResponse removeFromClusterNodeLabels(
RemoveFromClusterNodeLabelsRequest request) throws YarnException, IOException {
String operation = "removeFromClusterNodeLabels";
final String operation = "removeFromClusterNodeLabels";
final String msg = "remove labels.";
UserGroupInformation user = checkAcls(operation);
@ -741,7 +744,7 @@ public class AdminService extends CompositeService implements
@Override
public ReplaceLabelsOnNodeResponse replaceLabelsOnNode(
ReplaceLabelsOnNodeRequest request) throws YarnException, IOException {
String operation = "replaceLabelsOnNode";
final String operation = "replaceLabelsOnNode";
final String msg = "set node to labels.";
try {
@ -789,15 +792,16 @@ public class AdminService extends CompositeService implements
public CheckForDecommissioningNodesResponse checkForDecommissioningNodes(
CheckForDecommissioningNodesRequest checkForDecommissioningNodesRequest)
throws IOException, YarnException {
String argName = "checkForDecommissioningNodes";
final String operation = "checkForDecommissioningNodes";
final String msg = "check for decommissioning nodes.";
UserGroupInformation user = checkAcls("checkForDecommissioningNodes");
checkRMStatus(user.getShortUserName(), argName, msg);
checkRMStatus(user.getShortUserName(), operation, msg);
Set<NodeId> decommissioningNodes = rmContext.getNodesListManager()
.checkForDecommissioningNodes();
RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService");
RMAuditLogger.logSuccess(user.getShortUserName(), operation,
"AdminService");
CheckForDecommissioningNodesResponse response = recordFactory
.newRecordInstance(CheckForDecommissioningNodesResponse.class);
response.setDecommissioningNodes(decommissioningNodes);
@ -808,11 +812,11 @@ public class AdminService extends CompositeService implements
public RefreshClusterMaxPriorityResponse refreshClusterMaxPriority(
RefreshClusterMaxPriorityRequest request) throws YarnException,
IOException {
String argName = "refreshClusterMaxPriority";
String msg = "refresh cluster max priority";
UserGroupInformation user = checkAcls(argName);
final String operation = "refreshClusterMaxPriority";
final String msg = "refresh cluster max priority";
UserGroupInformation user = checkAcls(operation);
checkRMStatus(user.getShortUserName(), argName, msg);
checkRMStatus(user.getShortUserName(), operation, msg);
try {
Configuration conf =
getConfiguration(new Configuration(false),
@ -821,11 +825,11 @@ public class AdminService extends CompositeService implements
rmContext.getScheduler().setClusterMaxPriority(conf);
RMAuditLogger
.logSuccess(user.getShortUserName(), argName, "AdminService");
.logSuccess(user.getShortUserName(), operation, "AdminService");
return recordFactory
.newRecordInstance(RefreshClusterMaxPriorityResponse.class);
} catch (YarnException e) {
throw logAndWrapException(e, user.getShortUserName(), argName, msg);
throw logAndWrapException(e, user.getShortUserName(), operation, msg);
}
}