YARN-7163. RMContext need not to be injected to webapp and other Always Running services. Contributed by Rohith Sharma K S.

This commit is contained in:
Sunil G 2017-09-11 10:34:59 +05:30
parent 2c051dbe9e
commit 23dc6ef8b0
19 changed files with 380 additions and 157 deletions

View File

@ -19,8 +19,11 @@ package org.apache.hadoop.yarn.server.webapp;
import static org.apache.hadoop.yarn.util.StringHelper.join; import static org.apache.hadoop.yarn.util.StringHelper.join;
import static org.apache.hadoop.yarn.webapp.YarnWebParams.APPLICATION_ATTEMPT_ID; import static org.apache.hadoop.yarn.webapp.YarnWebParams.APPLICATION_ATTEMPT_ID;
import java.io.IOException;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -34,6 +37,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerReport; import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState; import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo; import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo; import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.util.ConverterUtils;
@ -77,18 +81,15 @@ public class AppAttemptBlock extends HtmlBlock {
final GetApplicationAttemptReportRequest request = final GetApplicationAttemptReportRequest request =
GetApplicationAttemptReportRequest.newInstance(appAttemptId); GetApplicationAttemptReportRequest.newInstance(appAttemptId);
if (callerUGI == null) { if (callerUGI == null) {
appAttemptReport = appAttemptReport = getApplicationAttemptReport(request);
appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
} else { } else {
appAttemptReport = callerUGI.doAs( appAttemptReport = callerUGI
new PrivilegedExceptionAction<ApplicationAttemptReport> () { .doAs(new PrivilegedExceptionAction<ApplicationAttemptReport>() {
@Override @Override
public ApplicationAttemptReport run() throws Exception { public ApplicationAttemptReport run() throws Exception {
return appBaseProt.getApplicationAttemptReport(request) return getApplicationAttemptReport(request);
.getApplicationAttemptReport(); }
} });
});
} }
} catch (Exception e) { } catch (Exception e) {
String message = String message =
@ -109,13 +110,13 @@ public class AppAttemptBlock extends HtmlBlock {
final GetContainersRequest request = final GetContainersRequest request =
GetContainersRequest.newInstance(appAttemptId); GetContainersRequest.newInstance(appAttemptId);
if (callerUGI == null) { if (callerUGI == null) {
containers = appBaseProt.getContainers(request).getContainerList(); containers = getContainers(request);
} else { } else {
containers = callerUGI.doAs( containers = callerUGI.doAs(
new PrivilegedExceptionAction<Collection<ContainerReport>> () { new PrivilegedExceptionAction<Collection<ContainerReport>> () {
@Override @Override
public Collection<ContainerReport> run() throws Exception { public Collection<ContainerReport> run() throws Exception {
return appBaseProt.getContainers(request).getContainerList(); return getContainers(request);
} }
}); });
} }
@ -191,6 +192,18 @@ public class AppAttemptBlock extends HtmlBlock {
tbody._()._(); tbody._()._();
} }
protected List<ContainerReport> getContainers(
final GetContainersRequest request) throws YarnException, IOException {
return appBaseProt.getContainers(request).getContainerList();
}
protected ApplicationAttemptReport getApplicationAttemptReport(
final GetApplicationAttemptReportRequest request)
throws YarnException, IOException {
return appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
}
protected void generateOverview(ApplicationAttemptReport appAttemptReport, protected void generateOverview(ApplicationAttemptReport appAttemptReport,
Collection<ContainerReport> containers, AppAttemptInfo appAttempt, Collection<ContainerReport> containers, AppAttemptInfo appAttempt,
String node) { String node) {

View File

@ -22,8 +22,10 @@ import static org.apache.hadoop.yarn.util.StringHelper.join;
import static org.apache.hadoop.yarn.webapp.YarnWebParams.APPLICATION_ID; import static org.apache.hadoop.yarn.webapp.YarnWebParams.APPLICATION_ID;
import static org.apache.hadoop.yarn.webapp.YarnWebParams.WEB_UI_TYPE; import static org.apache.hadoop.yarn.webapp.YarnWebParams.WEB_UI_TYPE;
import java.io.IOException;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
@ -48,6 +50,7 @@ import org.apache.hadoop.yarn.api.records.LogAggregationStatus;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException; 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.AppAttemptInfo;
import org.apache.hadoop.yarn.server.webapp.dao.AppInfo; import org.apache.hadoop.yarn.server.webapp.dao.AppInfo;
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo; import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
@ -109,14 +112,13 @@ public class AppBlock extends HtmlBlock {
appReport = appReport =
appBaseProt.getApplicationReport(request).getApplicationReport(); appBaseProt.getApplicationReport(request).getApplicationReport();
} else { } else {
appReport = callerUGI.doAs( appReport =
new PrivilegedExceptionAction<ApplicationReport> () { callerUGI.doAs(new PrivilegedExceptionAction<ApplicationReport>() {
@Override @Override
public ApplicationReport run() throws Exception { public ApplicationReport run() throws Exception {
return appBaseProt.getApplicationReport(request) return getApplicationReport(request);
.getApplicationReport(); }
} });
});
} }
} catch (Exception e) { } catch (Exception e) {
String message = "Failed to read the application " + appID + "."; String message = "Failed to read the application " + appID + ".";
@ -245,17 +247,16 @@ public class AppBlock extends HtmlBlock {
final GetApplicationAttemptsRequest request = final GetApplicationAttemptsRequest request =
GetApplicationAttemptsRequest.newInstance(appID); GetApplicationAttemptsRequest.newInstance(appID);
if (callerUGI == null) { if (callerUGI == null) {
attempts = appBaseProt.getApplicationAttempts(request) attempts = getApplicationAttemptsReport(request);
.getApplicationAttemptList();
} else { } else {
attempts = callerUGI.doAs( attempts = callerUGI.doAs(
new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>> () { new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>>() {
@Override @Override
public Collection<ApplicationAttemptReport> run() throws Exception { public Collection<ApplicationAttemptReport> run()
return appBaseProt.getApplicationAttempts(request) throws Exception {
.getApplicationAttemptList(); return getApplicationAttemptsReport(request);
} }
}); });
} }
} catch (Exception e) { } catch (Exception e) {
String message = String message =
@ -292,24 +293,23 @@ public class AppBlock extends HtmlBlock {
appAttemptReport.getAMContainerId()); appAttemptReport.getAMContainerId());
if (callerUGI == null) { if (callerUGI == null) {
containerReport = containerReport =
appBaseProt.getContainerReport(request).getContainerReport(); getContainerReport(request);
} else { } else {
containerReport = callerUGI.doAs( containerReport =
new PrivilegedExceptionAction<ContainerReport>() { callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() {
@Override @Override
public ContainerReport run() throws Exception { public ContainerReport run() throws Exception {
ContainerReport report = null; ContainerReport report = null;
if (request.getContainerId() != null) { if (request.getContainerId() != null) {
try { try {
report = appBaseProt.getContainerReport(request) report = getContainerReport(request);
.getContainerReport(); } catch (ContainerNotFoundException ex) {
} catch (ContainerNotFoundException ex) { LOG.warn(ex.getMessage());
LOG.warn(ex.getMessage()); }
} }
} return report;
return report; }
} });
});
} }
} catch (Exception e) { } catch (Exception e) {
String message = String message =
@ -355,6 +355,26 @@ public class AppBlock extends HtmlBlock {
tbody._()._(); tbody._()._();
} }
protected ContainerReport getContainerReport(
final GetContainerReportRequest request)
throws YarnException, IOException {
return appBaseProt.getContainerReport(request).getContainerReport();
}
protected List<ApplicationAttemptReport> getApplicationAttemptsReport(
final GetApplicationAttemptsRequest request)
throws YarnException, IOException {
return appBaseProt.getApplicationAttempts(request)
.getApplicationAttemptList();
}
protected ApplicationReport getApplicationReport(
final GetApplicationReportRequest request)
throws YarnException, IOException {
return appBaseProt.getApplicationReport(request).getApplicationReport();
}
private String clarifyAppState(YarnApplicationState state) { private String clarifyAppState(YarnApplicationState state) {
String ret = state.toString(); String ret = state.toString();
switch (state) { switch (state) {

View File

@ -30,6 +30,7 @@ import java.io.IOException;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import java.util.Collection; import java.util.Collection;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.math.LongRange; import org.apache.commons.lang.math.LongRange;
@ -110,20 +111,24 @@ public class AppsBlock extends HtmlBlock {
new LongRange(appStartedTimeBegain, appStartedTimeEnd)); new LongRange(appStartedTimeBegain, appStartedTimeEnd));
if (callerUGI == null) { if (callerUGI == null) {
appReports = appBaseProt.getApplications(request).getApplicationList(); appReports = getApplicationReport(request);
} else { } else {
appReports = appReports =
callerUGI callerUGI
.doAs(new PrivilegedExceptionAction<Collection<ApplicationReport>>() { .doAs(new PrivilegedExceptionAction<Collection<ApplicationReport>>() {
@Override @Override
public Collection<ApplicationReport> run() throws Exception { public Collection<ApplicationReport> run() throws Exception {
return appBaseProt.getApplications(request) return getApplicationReport(request);
.getApplicationList();
} }
}); });
} }
} }
protected List<ApplicationReport> getApplicationReport(
final GetApplicationsRequest request) throws YarnException, IOException {
return appBaseProt.getApplications(request).getApplicationList();
}
@Override @Override
public void render(Block html) { public void render(Block html) {
setTitle("Applications"); setTitle("Applications");

View File

@ -20,6 +20,7 @@ package org.apache.hadoop.yarn.server.webapp;
import static org.apache.hadoop.yarn.util.StringHelper.join; import static org.apache.hadoop.yarn.util.StringHelper.join;
import static org.apache.hadoop.yarn.webapp.YarnWebParams.CONTAINER_ID; import static org.apache.hadoop.yarn.webapp.YarnWebParams.CONTAINER_ID;
import java.io.IOException;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -30,6 +31,7 @@ import org.apache.hadoop.yarn.api.ApplicationBaseProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest;
import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerReport; import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo; import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
import org.apache.hadoop.yarn.util.ConverterUtils; import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.util.Times; import org.apache.hadoop.yarn.util.Times;
@ -71,17 +73,15 @@ public class ContainerBlock extends HtmlBlock {
final GetContainerReportRequest request = final GetContainerReportRequest request =
GetContainerReportRequest.newInstance(containerId); GetContainerReportRequest.newInstance(containerId);
if (callerUGI == null) { if (callerUGI == null) {
containerReport = appBaseProt.getContainerReport(request) containerReport = getContainerReport(request);
.getContainerReport();
} else { } else {
containerReport = callerUGI.doAs( containerReport =
new PrivilegedExceptionAction<ContainerReport> () { callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() {
@Override @Override
public ContainerReport run() throws Exception { public ContainerReport run() throws Exception {
return appBaseProt.getContainerReport(request) return getContainerReport(request);
.getContainerReport(); }
} });
});
} }
} catch (Exception e) { } catch (Exception e) {
String message = "Failed to read the container " + containerid + "."; String message = "Failed to read the container " + containerid + ".";
@ -127,4 +127,10 @@ public class ContainerBlock extends HtmlBlock {
html._(InfoBlock.class); html._(InfoBlock.class);
} }
protected ContainerReport getContainerReport(
final GetContainerReportRequest request)
throws YarnException, IOException {
return appBaseProt.getContainerReport(request).getContainerReport();
}
} }

View File

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

View File

@ -34,6 +34,7 @@ import org.apache.hadoop.security.token.delegation.DelegationKey;
import org.apache.hadoop.util.ExitUtil; import org.apache.hadoop.util.ExitUtil;
import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier;
import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState; import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore.RMState;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.Recoverable; import org.apache.hadoop.yarn.server.resourcemanager.recovery.Recoverable;
@ -52,7 +53,7 @@ public class RMDelegationTokenSecretManager extends
private static final Log LOG = LogFactory private static final Log LOG = LogFactory
.getLog(RMDelegationTokenSecretManager.class); .getLog(RMDelegationTokenSecretManager.class);
protected final RMContext rmContext; private final ResourceManager rm;
/** /**
* Create a secret manager * Create a secret manager
@ -73,7 +74,7 @@ public class RMDelegationTokenSecretManager extends
RMContext rmContext) { RMContext rmContext) {
super(delegationKeyUpdateInterval, delegationTokenMaxLifetime, super(delegationKeyUpdateInterval, delegationTokenMaxLifetime,
delegationTokenRenewInterval, delegationTokenRemoverScanInterval); delegationTokenRenewInterval, delegationTokenRemoverScanInterval);
this.rmContext = rmContext; this.rm = rmContext.getResourceManager();
} }
@Override @Override
@ -85,7 +86,7 @@ public class RMDelegationTokenSecretManager extends
protected void storeNewMasterKey(DelegationKey newKey) { protected void storeNewMasterKey(DelegationKey newKey) {
try { try {
LOG.info("storing master key with keyID " + newKey.getKeyId()); LOG.info("storing master key with keyID " + newKey.getKeyId());
rmContext.getStateStore().storeRMDTMasterKey(newKey); rm.getRMContext().getStateStore().storeRMDTMasterKey(newKey);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error in storing master key with KeyID: " + newKey.getKeyId()); LOG.error("Error in storing master key with KeyID: " + newKey.getKeyId());
ExitUtil.terminate(1, e); ExitUtil.terminate(1, e);
@ -96,7 +97,7 @@ public class RMDelegationTokenSecretManager extends
protected void removeStoredMasterKey(DelegationKey key) { protected void removeStoredMasterKey(DelegationKey key) {
try { try {
LOG.info("removing master key with keyID " + key.getKeyId()); LOG.info("removing master key with keyID " + key.getKeyId());
rmContext.getStateStore().removeRMDTMasterKey(key); rm.getRMContext().getStateStore().removeRMDTMasterKey(key);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error in removing master key with KeyID: " + key.getKeyId()); LOG.error("Error in removing master key with KeyID: " + key.getKeyId());
ExitUtil.terminate(1, e); ExitUtil.terminate(1, e);
@ -109,7 +110,8 @@ public class RMDelegationTokenSecretManager extends
try { try {
LOG.info("storing RMDelegation token with sequence number: " LOG.info("storing RMDelegation token with sequence number: "
+ identifier.getSequenceNumber()); + identifier.getSequenceNumber());
rmContext.getStateStore().storeRMDelegationToken(identifier, renewDate); rm.getRMContext().getStateStore().storeRMDelegationToken(identifier,
renewDate);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error in storing RMDelegationToken with sequence number: " LOG.error("Error in storing RMDelegationToken with sequence number: "
+ identifier.getSequenceNumber()); + identifier.getSequenceNumber());
@ -123,7 +125,7 @@ public class RMDelegationTokenSecretManager extends
try { try {
LOG.info("updating RMDelegation token with sequence number: " LOG.info("updating RMDelegation token with sequence number: "
+ id.getSequenceNumber()); + id.getSequenceNumber());
rmContext.getStateStore().updateRMDelegationToken(id, renewDate); rm.getRMContext().getStateStore().updateRMDelegationToken(id, renewDate);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error in updating persisted RMDelegationToken" + LOG.error("Error in updating persisted RMDelegationToken" +
" with sequence number: " + id.getSequenceNumber()); " with sequence number: " + id.getSequenceNumber());
@ -137,7 +139,7 @@ public class RMDelegationTokenSecretManager extends
try { try {
LOG.info("removing RMDelegation token with sequence number: " LOG.info("removing RMDelegation token with sequence number: "
+ ident.getSequenceNumber()); + ident.getSequenceNumber());
rmContext.getStateStore().removeRMDelegationToken(ident); rm.getRMContext().getStateStore().removeRMDelegationToken(ident);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error in removing RMDelegationToken with sequence number: " LOG.error("Error in removing RMDelegationToken with sequence number: "
+ ident.getSequenceNumber()); + ident.getSequenceNumber());

View File

@ -20,7 +20,6 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp;
import static org.apache.hadoop.yarn.util.StringHelper.join; import static org.apache.hadoop.yarn.util.StringHelper.join;
import org.apache.hadoop.yarn.server.webapp.ContainerBlock;
import org.apache.hadoop.yarn.webapp.SubView; import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.YarnWebParams; import org.apache.hadoop.yarn.webapp.YarnWebParams;
@ -38,7 +37,7 @@ public class ContainerPage extends RmView {
@Override @Override
protected Class<? extends SubView> content() { protected Class<? extends SubView> content() {
return ContainerBlock.class; return RMContainerBlock.class;
} }
} }

View File

@ -23,18 +23,22 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI._INFO_WRAP;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI._ODD; import static org.apache.hadoop.yarn.webapp.view.JQueryUI._ODD;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI._TH; import static org.apache.hadoop.yarn.webapp.view.JQueryUI._TH;
import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ContainerReport; import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.ResourceRequest; import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState; import org.apache.hadoop.yarn.api.records.YarnApplicationAttemptState;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
@ -61,7 +65,7 @@ public class RMAppAttemptBlock extends AppAttemptBlock{
@Inject @Inject
RMAppAttemptBlock(ViewContext ctx, ResourceManager rm, Configuration conf) { RMAppAttemptBlock(ViewContext ctx, ResourceManager rm, Configuration conf) {
super(rm.getClientRMService(), ctx); super(null, ctx);
this.rm = rm; this.rm = rm;
this.conf = conf; this.conf = conf;
} }
@ -275,4 +279,18 @@ public class RMAppAttemptBlock extends AppAttemptBlock{
createContainerLocalityTable(html); createContainerLocalityTable(html);
createResourceRequestsTable(html); createResourceRequestsTable(html);
} }
@Override
protected List<ContainerReport> getContainers(
final GetContainersRequest request) throws YarnException, IOException {
return rm.getClientRMService().getContainers(request).getContainerList();
}
@Override
protected ApplicationAttemptReport getApplicationAttemptReport(
final GetApplicationAttemptReportRequest request)
throws YarnException, IOException {
return rm.getClientRMService().getApplicationAttemptReport(request)
.getApplicationAttemptReport();
}
} }

View File

@ -20,15 +20,23 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI._INFO_WRAP; import static org.apache.hadoop.yarn.webapp.view.JQueryUI._INFO_WRAP;
import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport; import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.api.records.LogAggregationStatus; import org.apache.hadoop.yarn.api.records.LogAggregationStatus;
import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics;
@ -52,7 +60,7 @@ public class RMAppBlock extends AppBlock{
@Inject @Inject
RMAppBlock(ViewContext ctx, Configuration conf, ResourceManager rm) { RMAppBlock(ViewContext ctx, Configuration conf, ResourceManager rm) {
super(rm.getClientRMService(), ctx, conf); super(null, ctx, conf);
this.conf = conf; this.conf = conf;
this.rm = rm; this.rm = rm;
} }
@ -187,4 +195,29 @@ public class RMAppBlock extends AppBlock{
} }
return rmApp.getLogAggregationStatusForAppReport(); return rmApp.getLogAggregationStatusForAppReport();
} }
@Override
protected ContainerReport getContainerReport(
final GetContainerReportRequest request)
throws YarnException, IOException {
return rm.getClientRMService().getContainerReport(request)
.getContainerReport();
}
@Override
protected List<ApplicationAttemptReport> getApplicationAttemptsReport(
final GetApplicationAttemptsRequest request)
throws YarnException, IOException {
return rm.getClientRMService().getApplicationAttempts(request)
.getApplicationAttemptList();
}
@Override
protected ApplicationReport getApplicationReport(
final GetApplicationReportRequest request)
throws YarnException, IOException {
return rm.getClientRMService().getApplicationReport(request)
.getApplicationReport();
}
} }

View File

@ -22,14 +22,17 @@ import static org.apache.hadoop.yarn.util.StringHelper.join;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR;
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR_VALUE; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.C_PROGRESSBAR_VALUE;
import java.io.IOException;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringEscapeUtils;
import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.api.ApplicationBaseProtocol; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
@ -48,9 +51,8 @@ public class RMAppsBlock extends AppsBlock {
private ResourceManager rm; private ResourceManager rm;
@Inject @Inject
RMAppsBlock(ResourceManager rm, ApplicationBaseProtocol appBaseProt, RMAppsBlock(ResourceManager rm, View.ViewContext ctx) {
View.ViewContext ctx) { super(null, ctx);
super(appBaseProt, ctx);
this.rm = rm; this.rm = rm;
} }
@ -194,4 +196,11 @@ public class RMAppsBlock extends AppsBlock {
tbody._()._(); tbody._()._();
} }
@Override
protected List<ApplicationReport> getApplicationReport(
final GetApplicationsRequest request) throws YarnException, IOException {
return rm.getClientRMService().getApplications(request)
.getApplicationList();
}
} }

View File

@ -0,0 +1,50 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.server.resourcemanager.webapp;
import java.io.IOException;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest;
import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
import org.apache.hadoop.yarn.server.webapp.ContainerBlock;
import com.google.inject.Inject;
/**
* RMContainer block to fetch from RM.
*/
public class RMContainerBlock extends ContainerBlock {
private final ResourceManager rm;
@Inject
public RMContainerBlock(ResourceManager resourceManager, ViewContext ctx) {
super(null, ctx);
this.rm = resourceManager;
}
@Override
protected ContainerReport getContainerReport(
final GetContainerReportRequest request)
throws YarnException, IOException {
return rm.getClientRMService().getContainerReport(request)
.getContainerReport();
}
}

View File

@ -23,7 +23,6 @@ import static org.apache.hadoop.yarn.util.StringHelper.pajoin;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState; import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
import org.apache.hadoop.yarn.api.ApplicationBaseProtocol;
import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.util.RMHAUtils; import org.apache.hadoop.yarn.util.RMHAUtils;
import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
@ -55,7 +54,6 @@ public class RMWebApp extends WebApp implements YarnWebParams {
if (rm != null) { if (rm != null) {
bind(ResourceManager.class).toInstance(rm); bind(ResourceManager.class).toInstance(rm);
bind(ApplicationBaseProtocol.class).toInstance(rm.getClientRMService());
} }
route("/", RmController.class); route("/", RmController.class);
route(pajoin("/nodes", NODE_STATE), RmController.class, "nodes"); route(pajoin("/nodes", NODE_STATE), RmController.class, "nodes");

View File

@ -71,7 +71,12 @@ import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthentica
import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenRequest; import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenRequest;
import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.CancelDelegationTokenResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptsRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse;
import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest;
@ -94,10 +99,12 @@ import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest; import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationPriorityRequest;
import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest; import org.apache.hadoop.yarn.api.protocolrecords.UpdateApplicationTimeoutsRequest;
import org.apache.hadoop.yarn.api.records.ApplicationAccessType; import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType; import org.apache.hadoop.yarn.api.records.ApplicationTimeoutType;
import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.NodeLabel; import org.apache.hadoop.yarn.api.records.NodeLabel;
@ -222,7 +229,8 @@ public class RMWebServices extends WebServices implements RMWebServiceProtocol {
@Inject @Inject
public RMWebServices(final ResourceManager rm, Configuration conf) { public RMWebServices(final ResourceManager rm, Configuration conf) {
super(rm.getClientRMService()); // don't inject, always take appBaseRoot from RM.
super(null);
this.rm = rm; this.rm = rm;
this.conf = conf; this.conf = conf;
isCentralizedNodeLabelConfiguration = isCentralizedNodeLabelConfiguration =
@ -2360,4 +2368,47 @@ public class RMWebServices extends WebServices implements RMWebServiceProtocol {
app.getApplicationTimeouts().get(appTimeout.getTimeoutType())); app.getApplicationTimeouts().get(appTimeout.getTimeoutType()));
return Response.status(Status.OK).entity(timeout).build(); return Response.status(Status.OK).entity(timeout).build();
} }
@Override
protected ApplicationReport getApplicationReport(
GetApplicationReportRequest request) throws YarnException, IOException {
return rm.getClientRMService().getApplicationReport(request)
.getApplicationReport();
}
@Override
protected List<ApplicationReport> getApplicationsReport(
final GetApplicationsRequest request) throws YarnException, IOException {
return rm.getClientRMService().getApplications(request)
.getApplicationList();
}
@Override
protected ApplicationAttemptReport getApplicationAttemptReport(
GetApplicationAttemptReportRequest request)
throws YarnException, IOException {
return rm.getClientRMService().getApplicationAttemptReport(request)
.getApplicationAttemptReport();
}
@Override
protected List<ApplicationAttemptReport> getApplicationAttemptsReport(
GetApplicationAttemptsRequest request) throws YarnException, IOException {
return rm.getClientRMService().getApplicationAttempts(request)
.getApplicationAttemptList();
}
@Override
protected ContainerReport getContainerReport(
GetContainerReportRequest request) throws YarnException, IOException {
return rm.getClientRMService().getContainerReport(request)
.getContainerReport();
}
@Override
protected List<ContainerReport> getContainersReport(
GetContainersRequest request) throws YarnException, IOException {
return rm.getClientRMService().getContainers(request).getContainerList();
}
} }

View File

@ -533,8 +533,11 @@ public class TestClientRMTokens {
private static RMDelegationTokenSecretManager private static RMDelegationTokenSecretManager
createRMDelegationTokenSecretManager(long secretKeyInterval, createRMDelegationTokenSecretManager(long secretKeyInterval,
long tokenMaxLifetime, long tokenRenewInterval) { long tokenMaxLifetime, long tokenRenewInterval) {
ResourceManager rm = mock(ResourceManager.class);
RMContext rmContext = mock(RMContext.class); RMContext rmContext = mock(RMContext.class);
when(rmContext.getStateStore()).thenReturn(new NullRMStateStore()); when(rmContext.getStateStore()).thenReturn(new NullRMStateStore());
when(rm.getRMContext()).thenReturn(rmContext);
when(rmContext.getResourceManager()).thenReturn(rm);
RMDelegationTokenSecretManager rmDtSecretManager = RMDelegationTokenSecretManager rmDtSecretManager =
new RMDelegationTokenSecretManager(secretKeyInterval, tokenMaxLifetime, new RMDelegationTokenSecretManager(secretKeyInterval, tokenMaxLifetime,

View File

@ -71,8 +71,11 @@ public class TestTokenClientRMService {
@BeforeClass @BeforeClass
public static void setupSecretManager() throws IOException { public static void setupSecretManager() throws IOException {
ResourceManager rm = mock(ResourceManager.class);
RMContext rmContext = mock(RMContext.class); RMContext rmContext = mock(RMContext.class);
when(rmContext.getStateStore()).thenReturn(new NullRMStateStore()); when(rmContext.getStateStore()).thenReturn(new NullRMStateStore());
when(rm.getRMContext()).thenReturn(rmContext);
when(rmContext.getResourceManager()).thenReturn(rm);
dtsm = dtsm =
new RMDelegationTokenSecretManager(60000, 60000, 60000, 60000, new RMDelegationTokenSecretManager(60000, 60000, 60000, 60000,
rmContext); rmContext);

View File

@ -23,7 +23,6 @@ import static org.mockito.Mockito.when;
import java.io.IOException; import java.io.IOException;
import org.apache.hadoop.yarn.api.ApplicationBaseProtocol;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.Resource;
@ -80,15 +79,13 @@ public class TestAppPage {
try { try {
ResourceManager rm = TestRMWebApp.mockRm(rmContext); ResourceManager rm = TestRMWebApp.mockRm(rmContext);
binder.bind(ResourceManager.class).toInstance(rm); binder.bind(ResourceManager.class).toInstance(rm);
binder.bind(ApplicationBaseProtocol.class).toInstance(
rm.getClientRMService());
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
} }
}); });
AppBlock instance = injector.getInstance(AppBlock.class); AppBlock instance = injector.getInstance(RMAppBlock.class);
instance.set(YarnWebParams.APPLICATION_ID, APP_ID.toString()); instance.set(YarnWebParams.APPLICATION_ID, APP_ID.toString());
instance.render(); instance.render();
} }

View File

@ -32,7 +32,6 @@ import java.util.Map;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.api.ApplicationBaseProtocol;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
@ -103,8 +102,6 @@ public class TestRMWebApp {
try { try {
ResourceManager mockRm = mockRm(3, 1, 2, 8*GiB); ResourceManager mockRm = mockRm(3, 1, 2, 8*GiB);
binder.bind(ResourceManager.class).toInstance(mockRm); binder.bind(ResourceManager.class).toInstance(mockRm);
binder.bind(ApplicationBaseProtocol.class)
.toInstance(mockRm.getClientRMService());
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }

View File

@ -24,7 +24,6 @@ import com.google.inject.Injector;
import com.google.inject.Module; import com.google.inject.Module;
import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.yarn.api.ApplicationBaseProtocol;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.Resource; import org.apache.hadoop.yarn.api.records.Resource;
@ -75,8 +74,6 @@ public class TestRMWebAppFairScheduler {
mockRm(rmContext); mockRm(rmContext);
binder.bind(ResourceManager.class).toInstance binder.bind(ResourceManager.class).toInstance
(mockRmWithFairScheduler); (mockRmWithFairScheduler);
binder.bind(ApplicationBaseProtocol.class).toInstance(
mockRmWithFairScheduler.getClientRMService());
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }
@ -115,9 +112,6 @@ public class TestRMWebAppFairScheduler {
mockRmWithApps(rmContext); mockRmWithApps(rmContext);
binder.bind(ResourceManager.class).toInstance binder.bind(ResourceManager.class).toInstance
(mockRmWithFairScheduler); (mockRmWithFairScheduler);
binder.bind(ApplicationBaseProtocol.class).toInstance(
mockRmWithFairScheduler.getClientRMService());
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }

View File

@ -21,7 +21,6 @@ package org.apache.hadoop.yarn.server.resourcemanager.webapp;
import java.io.IOException; import java.io.IOException;
import org.apache.hadoop.yarn.api.ApplicationBaseProtocol;
import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.server.resourcemanager.RMContext; import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
@ -52,8 +51,6 @@ public class TestRedirectionErrorPage {
try { try {
ResourceManager rm = TestRMWebApp.mockRm(rmContext); ResourceManager rm = TestRMWebApp.mockRm(rmContext);
binder.bind(ResourceManager.class).toInstance(rm); binder.bind(ResourceManager.class).toInstance(rm);
binder.bind(ApplicationBaseProtocol.class).toInstance(
rm.getClientRMService());
} catch (IOException e) { } catch (IOException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} }