|
@@ -1360,7 +1360,24 @@ public class FederationInterceptorREST extends AbstractRESTRequestInterceptor {
|
|
|
|
|
|
@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 {
|
|
|
+ SubClusterInfo subClusterInfo = getHomeSubClusterInfoByAppId(appId);
|
|
|
+
|
|
|
+ DefaultRequestInterceptorREST interceptor = getOrCreateInterceptorForSubCluster(
|
|
|
+ subClusterInfo.getSubClusterId(), subClusterInfo.getRMWebServiceAddress());
|
|
|
+ return interceptor.getAppAttempts(hsr, appId);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ RouterServerUtil.logAndThrowRunTimeException(e,
|
|
|
+ "Unable to get the AppAttempt appId: %s.", appId);
|
|
|
+ } catch (YarnException e) {
|
|
|
+ RouterServerUtil.logAndThrowRunTimeException("getContainer Failed.", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1372,7 +1389,28 @@ public class FederationInterceptorREST extends AbstractRESTRequestInterceptor {
|
|
|
@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 {
|
|
|
+ SubClusterInfo subClusterInfo = getHomeSubClusterInfoByAppId(appId);
|
|
|
+
|
|
|
+ DefaultRequestInterceptorREST interceptor = getOrCreateInterceptorForSubCluster(
|
|
|
+ subClusterInfo.getSubClusterId(), subClusterInfo.getRMWebServiceAddress());
|
|
|
+ return interceptor.getAppAttempt(req, res, appId, appAttemptId);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ RouterServerUtil.logAndThrowRunTimeException(e,
|
|
|
+ "Unable to get the AppAttempt appId: %s, appAttemptId: %s.", appId, appAttemptId);
|
|
|
+ } catch (YarnException e) {
|
|
|
+ RouterServerUtil.logAndThrowRunTimeException("getContainer Failed.", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1423,13 +1461,7 @@ public class FederationInterceptorREST extends AbstractRESTRequestInterceptor {
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- ApplicationId applicationId = ApplicationId.fromString(appId);
|
|
|
- SubClusterInfo subClusterInfo = getHomeSubClusterInfoByAppId(applicationId);
|
|
|
-
|
|
|
- if (subClusterInfo == null) {
|
|
|
- RouterServerUtil.logAndThrowRunTimeException("Unable to get subCluster by applicationId = " +
|
|
|
- applicationId, null);
|
|
|
- }
|
|
|
+ SubClusterInfo subClusterInfo = getHomeSubClusterInfoByAppId(appId);
|
|
|
|
|
|
DefaultRequestInterceptorREST interceptor = getOrCreateInterceptorForSubCluster(
|
|
|
subClusterInfo.getSubClusterId(), subClusterInfo.getRMWebServiceAddress());
|
|
@@ -1483,12 +1515,7 @@ public class FederationInterceptorREST extends AbstractRESTRequestInterceptor {
|
|
|
ContainerId containerIdObj = ContainerId.fromString(containerId);
|
|
|
ApplicationId applicationId = containerIdObj.getApplicationAttemptId().getApplicationId();
|
|
|
|
|
|
- SubClusterInfo subClusterInfo = getHomeSubClusterInfoByAppId(applicationId);
|
|
|
-
|
|
|
- if (subClusterInfo == null) {
|
|
|
- RouterServerUtil.logAndThrowRunTimeException("Unable to get subCluster by applicationId = " +
|
|
|
- applicationId, null);
|
|
|
- }
|
|
|
+ SubClusterInfo subClusterInfo = getHomeSubClusterInfoByAppId(applicationId.toString());
|
|
|
|
|
|
DefaultRequestInterceptorREST interceptor = getOrCreateInterceptorForSubCluster(
|
|
|
subClusterInfo.getSubClusterId(), subClusterInfo.getRMWebServiceAddress());
|
|
@@ -1556,24 +1583,26 @@ public class FederationInterceptorREST extends AbstractRESTRequestInterceptor {
|
|
|
/**
|
|
|
* get the HomeSubCluster according to ApplicationId.
|
|
|
*
|
|
|
- * @param applicationId applicationId
|
|
|
+ * @param appId applicationId
|
|
|
* @return HomeSubCluster
|
|
|
* @throws YarnException on failure
|
|
|
*/
|
|
|
- private SubClusterInfo getHomeSubClusterInfoByAppId(ApplicationId applicationId) throws YarnException {
|
|
|
+ private SubClusterInfo getHomeSubClusterInfoByAppId(String appId)
|
|
|
+ throws YarnException {
|
|
|
SubClusterInfo subClusterInfo = null;
|
|
|
- SubClusterId subClusterId = null;
|
|
|
try {
|
|
|
- subClusterId = federationFacade.getApplicationHomeSubCluster(applicationId);
|
|
|
+ ApplicationId applicationId = ApplicationId.fromString(appId);
|
|
|
+ SubClusterId subClusterId = federationFacade.getApplicationHomeSubCluster(applicationId);
|
|
|
if (subClusterId == null) {
|
|
|
- RouterServerUtil.logAndThrowException("Can't get HomeSubCluster by applicationId "
|
|
|
- + applicationId, null);
|
|
|
+ RouterServerUtil.logAndThrowException(null,
|
|
|
+ "Can't get HomeSubCluster by applicationId %s", applicationId);
|
|
|
}
|
|
|
subClusterInfo = federationFacade.getSubCluster(subClusterId);
|
|
|
+ return subClusterInfo;
|
|
|
} catch (YarnException e) {
|
|
|
- RouterServerUtil.logAndThrowException("Get HomeSubClusterInfo by applicationId "
|
|
|
- + applicationId + " failed.", e);
|
|
|
+ RouterServerUtil.logAndThrowException(e,
|
|
|
+ "Get HomeSubClusterInfo by applicationId %s failed.", appId);
|
|
|
}
|
|
|
- return subClusterInfo;
|
|
|
+ throw new YarnException("Unable to get subCluster by applicationId = " + appId);
|
|
|
}
|
|
|
}
|