|
@@ -18,11 +18,13 @@
|
|
|
|
|
|
package org.apache.hadoop.yarn.server.webapp;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.lang.reflect.UndeclaredThrowableException;
|
|
|
import java.security.PrivilegedExceptionAction;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.HashSet;
|
|
|
+import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -51,13 +53,13 @@ import org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest;
|
|
|
import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException;
|
|
|
import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
|
|
|
import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException;
|
|
|
+import org.apache.hadoop.yarn.exceptions.YarnException;
|
|
|
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
|
|
|
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptsInfo;
|
|
|
import org.apache.hadoop.yarn.server.webapp.dao.AppInfo;
|
|
|
import org.apache.hadoop.yarn.server.webapp.dao.AppsInfo;
|
|
|
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
|
|
|
import org.apache.hadoop.yarn.server.webapp.dao.ContainersInfo;
|
|
|
-import org.apache.hadoop.yarn.util.ConverterUtils;
|
|
|
import org.apache.hadoop.yarn.webapp.BadRequestException;
|
|
|
import org.apache.hadoop.yarn.webapp.ForbiddenException;
|
|
|
import org.apache.hadoop.yarn.webapp.NotFoundException;
|
|
@@ -154,15 +156,15 @@ public class WebServices {
|
|
|
if (callerUGI == null) {
|
|
|
// TODO: the request should take the params like what RMWebServices does
|
|
|
// in YARN-1819.
|
|
|
- appReports = appBaseProt.getApplications(request).getApplicationList();
|
|
|
+ appReports = getApplicationsReport(request);
|
|
|
} else {
|
|
|
appReports = callerUGI.doAs(
|
|
|
- new PrivilegedExceptionAction<Collection<ApplicationReport>> () {
|
|
|
- @Override
|
|
|
- public Collection<ApplicationReport> run() throws Exception {
|
|
|
- return appBaseProt.getApplications(request).getApplicationList();
|
|
|
- }
|
|
|
- });
|
|
|
+ new PrivilegedExceptionAction<Collection<ApplicationReport>>() {
|
|
|
+ @Override
|
|
|
+ public Collection<ApplicationReport> run() throws Exception {
|
|
|
+ return getApplicationsReport(request);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
rewrapAndThrowException(e);
|
|
@@ -220,17 +222,17 @@ public class WebServices {
|
|
|
if (callerUGI == null) {
|
|
|
GetApplicationReportRequest request =
|
|
|
GetApplicationReportRequest.newInstance(id);
|
|
|
- app = appBaseProt.getApplicationReport(request).getApplicationReport();
|
|
|
+ app = getApplicationReport(request);
|
|
|
} else {
|
|
|
- app = callerUGI.doAs(
|
|
|
- new PrivilegedExceptionAction<ApplicationReport> () {
|
|
|
- @Override
|
|
|
- public ApplicationReport run() throws Exception {
|
|
|
- GetApplicationReportRequest request =
|
|
|
- GetApplicationReportRequest.newInstance(id);
|
|
|
- return appBaseProt.getApplicationReport(request).getApplicationReport();
|
|
|
- }
|
|
|
- });
|
|
|
+ app =
|
|
|
+ callerUGI.doAs(new PrivilegedExceptionAction<ApplicationReport>() {
|
|
|
+ @Override
|
|
|
+ public ApplicationReport run() throws Exception {
|
|
|
+ GetApplicationReportRequest request =
|
|
|
+ GetApplicationReportRequest.newInstance(id);
|
|
|
+ return getApplicationReport(request);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
rewrapAndThrowException(e);
|
|
@@ -250,20 +252,18 @@ public class WebServices {
|
|
|
if (callerUGI == null) {
|
|
|
GetApplicationAttemptsRequest request =
|
|
|
GetApplicationAttemptsRequest.newInstance(id);
|
|
|
- appAttemptReports =
|
|
|
- appBaseProt.getApplicationAttempts(request)
|
|
|
- .getApplicationAttemptList();
|
|
|
+ appAttemptReports = getApplicationAttemptsReport(request);
|
|
|
} else {
|
|
|
appAttemptReports = callerUGI.doAs(
|
|
|
- new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>> () {
|
|
|
- @Override
|
|
|
- public Collection<ApplicationAttemptReport> run() throws Exception {
|
|
|
- GetApplicationAttemptsRequest request =
|
|
|
- GetApplicationAttemptsRequest.newInstance(id);
|
|
|
- return appBaseProt.getApplicationAttempts(request)
|
|
|
- .getApplicationAttemptList();
|
|
|
- }
|
|
|
- });
|
|
|
+ new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>>() {
|
|
|
+ @Override
|
|
|
+ public Collection<ApplicationAttemptReport> run()
|
|
|
+ throws Exception {
|
|
|
+ GetApplicationAttemptsRequest request =
|
|
|
+ GetApplicationAttemptsRequest.newInstance(id);
|
|
|
+ return getApplicationAttemptsReport(request);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
rewrapAndThrowException(e);
|
|
@@ -291,20 +291,17 @@ public class WebServices {
|
|
|
if (callerUGI == null) {
|
|
|
GetApplicationAttemptReportRequest request =
|
|
|
GetApplicationAttemptReportRequest.newInstance(aaid);
|
|
|
- appAttempt =
|
|
|
- appBaseProt.getApplicationAttemptReport(request)
|
|
|
- .getApplicationAttemptReport();
|
|
|
+ appAttempt = getApplicationAttemptReport(request);
|
|
|
} else {
|
|
|
- appAttempt = callerUGI.doAs(
|
|
|
- new PrivilegedExceptionAction<ApplicationAttemptReport> () {
|
|
|
- @Override
|
|
|
- public ApplicationAttemptReport run() throws Exception {
|
|
|
- GetApplicationAttemptReportRequest request =
|
|
|
- GetApplicationAttemptReportRequest.newInstance(aaid);
|
|
|
- return appBaseProt.getApplicationAttemptReport(request)
|
|
|
- .getApplicationAttemptReport();
|
|
|
- }
|
|
|
- });
|
|
|
+ appAttempt = callerUGI
|
|
|
+ .doAs(new PrivilegedExceptionAction<ApplicationAttemptReport>() {
|
|
|
+ @Override
|
|
|
+ public ApplicationAttemptReport run() throws Exception {
|
|
|
+ GetApplicationAttemptReportRequest request =
|
|
|
+ GetApplicationAttemptReportRequest.newInstance(aaid);
|
|
|
+ return getApplicationAttemptReport(request);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
rewrapAndThrowException(e);
|
|
@@ -326,17 +323,17 @@ public class WebServices {
|
|
|
try {
|
|
|
if (callerUGI == null) {
|
|
|
GetContainersRequest request = GetContainersRequest.newInstance(aaid);
|
|
|
- containerReports =
|
|
|
- appBaseProt.getContainers(request).getContainerList();
|
|
|
+ containerReports = getContainersReport(request);
|
|
|
} else {
|
|
|
- containerReports = callerUGI.doAs(
|
|
|
- new PrivilegedExceptionAction<Collection<ContainerReport>> () {
|
|
|
- @Override
|
|
|
- public Collection<ContainerReport> run() throws Exception {
|
|
|
- GetContainersRequest request = GetContainersRequest.newInstance(aaid);
|
|
|
- return appBaseProt.getContainers(request).getContainerList();
|
|
|
- }
|
|
|
- });
|
|
|
+ containerReports = callerUGI
|
|
|
+ .doAs(new PrivilegedExceptionAction<Collection<ContainerReport>>() {
|
|
|
+ @Override
|
|
|
+ public Collection<ContainerReport> run() throws Exception {
|
|
|
+ GetContainersRequest request =
|
|
|
+ GetContainersRequest.newInstance(aaid);
|
|
|
+ return getContainersReport(request);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
rewrapAndThrowException(e);
|
|
@@ -365,18 +362,17 @@ public class WebServices {
|
|
|
if (callerUGI == null) {
|
|
|
GetContainerReportRequest request =
|
|
|
GetContainerReportRequest.newInstance(cid);
|
|
|
- container =
|
|
|
- appBaseProt.getContainerReport(request).getContainerReport();
|
|
|
+ container = getContainerReport(request);
|
|
|
} else {
|
|
|
- container = callerUGI.doAs(
|
|
|
- new PrivilegedExceptionAction<ContainerReport> () {
|
|
|
- @Override
|
|
|
- public ContainerReport run() throws Exception {
|
|
|
- GetContainerReportRequest request =
|
|
|
- GetContainerReportRequest.newInstance(cid);
|
|
|
- return appBaseProt.getContainerReport(request).getContainerReport();
|
|
|
- }
|
|
|
- });
|
|
|
+ container =
|
|
|
+ callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() {
|
|
|
+ @Override
|
|
|
+ public ContainerReport run() throws Exception {
|
|
|
+ GetContainerReportRequest request =
|
|
|
+ GetContainerReportRequest.newInstance(cid);
|
|
|
+ return getContainerReport(request);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
rewrapAndThrowException(e);
|
|
@@ -516,4 +512,36 @@ public class WebServices {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ protected ApplicationReport getApplicationReport(
|
|
|
+ GetApplicationReportRequest request) throws YarnException, IOException {
|
|
|
+ return appBaseProt.getApplicationReport(request).getApplicationReport();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected List<ApplicationReport> getApplicationsReport(
|
|
|
+ final GetApplicationsRequest request) throws YarnException, IOException {
|
|
|
+ return appBaseProt.getApplications(request).getApplicationList();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected ApplicationAttemptReport getApplicationAttemptReport(
|
|
|
+ GetApplicationAttemptReportRequest request)
|
|
|
+ throws YarnException, IOException {
|
|
|
+ return appBaseProt.getApplicationAttemptReport(request)
|
|
|
+ .getApplicationAttemptReport();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected List<ApplicationAttemptReport> getApplicationAttemptsReport(
|
|
|
+ GetApplicationAttemptsRequest request) throws YarnException, IOException {
|
|
|
+ return appBaseProt.getApplicationAttempts(request)
|
|
|
+ .getApplicationAttemptList();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected ContainerReport getContainerReport(
|
|
|
+ GetContainerReportRequest request) throws YarnException, IOException {
|
|
|
+ return appBaseProt.getContainerReport(request).getContainerReport();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected List<ContainerReport> getContainersReport(
|
|
|
+ GetContainersRequest request) throws YarnException, IOException {
|
|
|
+ return appBaseProt.getContainers(request).getContainerList();
|
|
|
+ }
|
|
|
}
|