goiri commented on code in PR #4695:
URL: https://github.com/apache/hadoop/pull/4695#discussion_r937307600
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/MockDefaultRequestInterceptorREST.java:
##########
@@ -412,4 +419,50 @@ public Response signalToContainer(String containerId,
String command,
return Response.status(Status.OK).build();
}
+
+ @Override
+ public org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo
getAppAttempt(HttpServletRequest req, HttpServletResponse res,
Review Comment:
We need to specify the whole type? Where is the conflict?
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java:
##########
@@ -1365,7 +1365,30 @@ public Response updateApplicationTimeout(AppTimeoutInfo
appTimeout,
@Override
public AppAttemptsInfo getAppAttempts(HttpServletRequest hsr, String appId) {
- throw new NotImplementedException("Code is not implemented");
+ if (appId == null || appId.isEmpty()) {
+ throw new IllegalArgumentException("Parameter error, the appId is empty
or null.");
+ }
+
+ try {
+ ApplicationId applicationId = ApplicationId.fromString(appId);
+ SubClusterInfo subClusterInfo =
getHomeSubClusterInfoByAppId(applicationId);
Review Comment:
I should've proposed this before but we keep doing this string to
ApplicationId.
We could just have this getHomeSubClusterInfoByAppId() to take a string and
do the transformation there.
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestFederationInterceptorREST.java:
##########
@@ -717,4 +718,37 @@ public void testGetContainer()
appId.toString(), appAttemptId.toString(), "0");
Assert.assertNotNull(containerInfo);
}
+
+ @Test
+ public void testGetAppAttempts()
+ throws IOException, InterruptedException, YarnException {
+ // Submit application to multiSubCluster
+ ApplicationId appId = ApplicationId.newInstance(Time.now(), 1);
+ ApplicationSubmissionContextInfo context = new
ApplicationSubmissionContextInfo();
+ context.setApplicationId(appId.toString());
+
+ Assert.assertNotNull(interceptor.submitApplication(context, null));
+
+ AppAttemptsInfo appAttemptsInfo = interceptor.getAppAttempts(null,
appId.toString());
+ Assert.assertNotNull(appAttemptsInfo);
+ Assert.assertTrue(!appAttemptsInfo.getAttempts().isEmpty());
+ }
+
+ @Test
+ public void testGetAppAttempt()
+ throws IOException, InterruptedException, YarnException {
+ // Submit application to multiSubCluster
+ ApplicationId appId =
ApplicationId.newInstance(System.currentTimeMillis(), 1);
+ ApplicationSubmissionContextInfo context = new
ApplicationSubmissionContextInfo();
+ context.setApplicationId(appId.toString());
+ Assert.assertNotNull(interceptor.submitApplication(context, null));
+ ApplicationAttemptId appAttemptIdExcept =
ApplicationAttemptId.newInstance(appId, 1);
Review Comment:
Except? Expect?
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestFederationInterceptorREST.java:
##########
@@ -717,4 +718,37 @@ public void testGetContainer()
appId.toString(), appAttemptId.toString(), "0");
Assert.assertNotNull(containerInfo);
}
+
+ @Test
+ public void testGetAppAttempts()
+ throws IOException, InterruptedException, YarnException {
+ // Submit application to multiSubCluster
+ ApplicationId appId = ApplicationId.newInstance(Time.now(), 1);
+ ApplicationSubmissionContextInfo context = new
ApplicationSubmissionContextInfo();
+ context.setApplicationId(appId.toString());
+
+ Assert.assertNotNull(interceptor.submitApplication(context, null));
+
+ AppAttemptsInfo appAttemptsInfo = interceptor.getAppAttempts(null,
appId.toString());
+ Assert.assertNotNull(appAttemptsInfo);
+ Assert.assertTrue(!appAttemptsInfo.getAttempts().isEmpty());
Review Comment:
Can we check before the submission too?
It would be nice to check something more specific than not empty.
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java:
##########
@@ -1377,7 +1400,35 @@ public RMQueueAclInfo checkUserAccessToQueue(String
queue, String username,
@Override
public AppAttemptInfo getAppAttempt(HttpServletRequest req,
HttpServletResponse res, String appId, String appAttemptId) {
- throw new NotImplementedException("Code is not implemented");
+
+ if (appId == null || appId.isEmpty()) {
+ throw new IllegalArgumentException("Parameter error, the appId is empty
or null.");
+ }
+ if (appAttemptId == null || appAttemptId.isEmpty()) {
+ throw new IllegalArgumentException("Parameter error, the appAttemptId is
empty or null.");
+ }
+
+ try {
+ ApplicationId applicationId = ApplicationId.fromString(appId);
+ SubClusterInfo subClusterInfo =
getHomeSubClusterInfoByAppId(applicationId);
+
+ if (subClusterInfo == null) {
+ RouterServerUtil.logAndThrowRunTimeException("Unable to get subCluster
by applicationId = "
+ + applicationId, null);
+ }
+
+ DefaultRequestInterceptorREST interceptor =
getOrCreateInterceptorForSubCluster(
+ subClusterInfo.getSubClusterId(),
subClusterInfo.getRMWebServiceAddress());
+ return interceptor.getAppAttempt(req, res, appId, appAttemptId);
+ } catch (IllegalArgumentException e) {
+ String msg = String.format("Unable to get the AppAttempt appId: %s,
appAttemptId: %s.",
+ appId, appAttemptId);
+ RouterServerUtil.logAndThrowRunTimeException(msg, e);
Review Comment:
Could we create a logAndThrowRunTimeException that already does the format?
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/TestFederationInterceptorREST.java:
##########
@@ -717,4 +718,37 @@ public void testGetContainer()
appId.toString(), appAttemptId.toString(), "0");
Assert.assertNotNull(containerInfo);
}
+
+ @Test
+ public void testGetAppAttempts()
+ throws IOException, InterruptedException, YarnException {
+ // Submit application to multiSubCluster
+ ApplicationId appId = ApplicationId.newInstance(Time.now(), 1);
+ ApplicationSubmissionContextInfo context = new
ApplicationSubmissionContextInfo();
+ context.setApplicationId(appId.toString());
+
+ Assert.assertNotNull(interceptor.submitApplication(context, null));
+
+ AppAttemptsInfo appAttemptsInfo = interceptor.getAppAttempts(null,
appId.toString());
+ Assert.assertNotNull(appAttemptsInfo);
+ Assert.assertTrue(!appAttemptsInfo.getAttempts().isEmpty());
+ }
+
+ @Test
+ public void testGetAppAttempt()
+ throws IOException, InterruptedException, YarnException {
+ // Submit application to multiSubCluster
+ ApplicationId appId =
ApplicationId.newInstance(System.currentTimeMillis(), 1);
+ ApplicationSubmissionContextInfo context = new
ApplicationSubmissionContextInfo();
+ context.setApplicationId(appId.toString());
+ Assert.assertNotNull(interceptor.submitApplication(context, null));
+ ApplicationAttemptId appAttemptIdExcept =
ApplicationAttemptId.newInstance(appId, 1);
Review Comment:
Probably create the appId and attemptId one after the other.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]