diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java index fad5d966ff..d1d49ec4e5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java @@ -987,6 +987,52 @@ public class FederationInterceptorREST extends AbstractRESTRequestInterceptor { return metrics; } + /** + * The YARN Router will forward to the respective YARN RM in which the AM is + * running. + *
+ * Possible failure: + *
+ * Client: identical behavior as {@code RMWebServices}. + *
+ * Router: the Client will timeout and resubmit the request. + *
+ * ResourceManager: the Router will timeout and the call will fail. + *
+ * State Store: the Router will timeout and it will retry depending on the
+ * FederationFacade settings - if the failure happened before the select
+ * operation.
+ */
+ @Override
+ public AppState getAppState(HttpServletRequest hsr, String appId)
+ throws AuthorizationException {
+
+ ApplicationId applicationId = null;
+ try {
+ applicationId = ApplicationId.fromString(appId);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+
+ SubClusterInfo subClusterInfo = null;
+ SubClusterId subClusterId = null;
+ try {
+ subClusterId =
+ federationFacade.getApplicationHomeSubCluster(applicationId);
+ if (subClusterId == null) {
+ return null;
+ }
+ subClusterInfo = federationFacade.getSubCluster(subClusterId);
+ } catch (YarnException e) {
+ return null;
+ }
+
+ DefaultRequestInterceptorREST interceptor =
+ getOrCreateInterceptorForSubCluster(subClusterId,
+ subClusterInfo.getRMWebServiceAddress());
+ return interceptor.getAppState(hsr, appId);
+ }
+
@Override
public ClusterInfo get() {
return getClusterInfo();
@@ -1025,12 +1071,6 @@ public class FederationInterceptorREST extends AbstractRESTRequestInterceptor {
throw new NotImplementedException();
}
- @Override
- public AppState getAppState(HttpServletRequest hsr, String appId)
- throws AuthorizationException {
- throw new NotImplementedException();
- }
-
@Override
public NodeToLabelsInfo getNodeToLabels(HttpServletRequest hsr)
throws IOException {
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/MockDefaultRequestInterceptorREST.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/MockDefaultRequestInterceptorREST.java
index 9f54582650..63de9ac18b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/MockDefaultRequestInterceptorREST.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/webapp/MockDefaultRequestInterceptorREST.java
@@ -61,6 +61,7 @@ public class MockDefaultRequestInterceptorREST
// down e.g. network issue, failover.
private boolean isRunning = true;
private HashSet