Skip to content

Commit b7b1cf1

Browse files
author
slfan1989
committed
YARN-11239. Fix CheckStyle.
1 parent 94b7edf commit b7b1cf1

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterAuditLogger.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static class AuditConstants {
6565
public static final String GET_NODETOLABELS = "Get NodeToLabels";
6666
public static final String GET_LABELSTONODES = "Get LabelsToNodes";
6767
public static final String GET_CLUSTERNODELABELS = "Get ClusterNodeLabels";
68+
public static final String GET_APPLICATION_ATTEMPT_REPORT = "Get ApplicationAttemptReport";
6869
}
6970

7071
public static void logSuccess(String user, String operation, String target) {

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityResponse;
116116
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
117117
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsResponse;
118+
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
118119
import org.apache.hadoop.yarn.api.records.ApplicationId;
119120
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
120121
import org.apache.hadoop.yarn.api.records.ReservationId;
@@ -166,6 +167,7 @@
166167
import static org.apache.hadoop.yarn.server.router.RouterAuditLogger.AuditConstants.GET_NODETOLABELS;
167168
import static org.apache.hadoop.yarn.server.router.RouterAuditLogger.AuditConstants.GET_LABELSTONODES;
168169
import static org.apache.hadoop.yarn.server.router.RouterAuditLogger.AuditConstants.GET_CLUSTERNODELABELS;
170+
import static org.apache.hadoop.yarn.server.router.RouterAuditLogger.AuditConstants.GET_APPLICATION_ATTEMPT_REPORT;
169171

170172
/**
171173
* Extends the {@code AbstractRequestInterceptorClient} class and provides an
@@ -1319,6 +1321,8 @@ public GetClusterNodeLabelsResponse getClusterNodeLabels(
13191321
}
13201322
long stopTime = clock.getTime();
13211323
routerMetrics.succeededGetClusterNodeLabelsRetrieved(stopTime - startTime);
1324+
RouterAuditLogger.logSuccess(user.getShortUserName(), GET_CLUSTERNODELABELS,
1325+
TARGET_CLIENT_RM_SERVICE);
13221326
// Merge the ClusterNodeLabelsResponse
13231327
return RouterYarnClientUtils.mergeClusterNodeLabelsResponse(nodeLabels);
13241328
}
@@ -1347,9 +1351,11 @@ public GetApplicationAttemptReportResponse getApplicationAttemptReport(
13471351
if (request == null || request.getApplicationAttemptId() == null
13481352
|| request.getApplicationAttemptId().getApplicationId() == null) {
13491353
routerMetrics.incrAppAttemptReportFailedRetrieved();
1350-
RouterServerUtil.logAndThrowException(
1351-
"Missing getApplicationAttemptReport request or applicationId " +
1352-
"or applicationAttemptId information.", null);
1354+
String msg = "Missing getApplicationAttemptReport request or applicationId " +
1355+
"or applicationAttemptId information.";
1356+
RouterAuditLogger.logFailure(user.getShortUserName(), GET_APPLICATION_ATTEMPT_REPORT, UNKNOWN,
1357+
TARGET_CLIENT_RM_SERVICE, msg);
1358+
RouterServerUtil.logAndThrowException(msg, null);
13531359
}
13541360

13551361
long startTime = clock.getTime();
@@ -1359,10 +1365,12 @@ public GetApplicationAttemptReportResponse getApplicationAttemptReport(
13591365
subClusterId = getApplicationHomeSubCluster(applicationId);
13601366
} catch (YarnException e) {
13611367
routerMetrics.incrAppAttemptReportFailedRetrieved();
1362-
RouterServerUtil.logAndThrowException("ApplicationAttempt " +
1363-
request.getApplicationAttemptId() + " belongs to Application " +
1364-
request.getApplicationAttemptId().getApplicationId() +
1365-
" does not exist in FederationStateStore.", e);
1368+
String msgFormat = "ApplicationAttempt %s belongs to " +
1369+
"Application %s does not exist in FederationStateStore.";
1370+
ApplicationAttemptId applicationAttemptId = request.getApplicationAttemptId();
1371+
RouterAuditLogger.logFailure(user.getShortUserName(), GET_APPLICATION_ATTEMPT_REPORT, UNKNOWN,
1372+
TARGET_CLIENT_RM_SERVICE, msgFormat, applicationAttemptId, applicationId);
1373+
RouterServerUtil.logAndThrowException(e, msgFormat, applicationAttemptId, applicationId);
13661374
}
13671375

13681376
ApplicationClientProtocol clientRMProxy =
@@ -1376,6 +1384,8 @@ public GetApplicationAttemptReportResponse getApplicationAttemptReport(
13761384
String msg = String.format(
13771385
"Unable to get the applicationAttempt report for %s to SubCluster %s.",
13781386
request.getApplicationAttemptId(), subClusterId.getId());
1387+
RouterAuditLogger.logFailure(user.getShortUserName(), GET_APPLICATION_ATTEMPT_REPORT, UNKNOWN,
1388+
TARGET_CLIENT_RM_SERVICE, msg);
13791389
RouterServerUtil.logAndThrowException(msg, e);
13801390
}
13811391

@@ -1387,6 +1397,8 @@ public GetApplicationAttemptReportResponse getApplicationAttemptReport(
13871397

13881398
long stopTime = clock.getTime();
13891399
routerMetrics.succeededAppAttemptReportRetrieved(stopTime - startTime);
1400+
RouterAuditLogger.logSuccess(user.getShortUserName(), GET_APPLICATION_ATTEMPT_REPORT,
1401+
TARGET_CLIENT_RM_SERVICE);
13901402
return response;
13911403
}
13921404

0 commit comments

Comments
 (0)