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:28:10 +05:30
parent aa4b6fbe75
commit 722ee84194
19 changed files with 293 additions and 71 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.webapp.hamlet2.Hamlet; import org.apache.hadoop.yarn.webapp.hamlet2.Hamlet;
@ -77,15 +81,13 @@ public class AppAttemptBlock extends HtmlBlock {
GetApplicationAttemptReportRequest.newInstance(appAttemptId); GetApplicationAttemptReportRequest.newInstance(appAttemptId);
if (callerUGI == null) { if (callerUGI == null) {
appAttemptReport = appAttemptReport =
appBaseProt.getApplicationAttemptReport(request) getApplicationAttemptReport(request);
.getApplicationAttemptReport();
} else { } else {
appAttemptReport = callerUGI.doAs( appAttemptReport = callerUGI.doAs(
new PrivilegedExceptionAction<ApplicationAttemptReport> () { new PrivilegedExceptionAction<ApplicationAttemptReport> () {
@Override @Override
public ApplicationAttemptReport run() throws Exception { public ApplicationAttemptReport run() throws Exception {
return appBaseProt.getApplicationAttemptReport(request) return getApplicationAttemptReport(request);
.getApplicationAttemptReport();
} }
}); });
} }
@ -108,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);
} }
}); });
} }
@ -190,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;
@ -49,6 +51,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;
@ -114,8 +117,7 @@ public class AppBlock extends HtmlBlock {
new PrivilegedExceptionAction<ApplicationReport> () { new PrivilegedExceptionAction<ApplicationReport> () {
@Override @Override
public ApplicationReport run() throws Exception { public ApplicationReport run() throws Exception {
return appBaseProt.getApplicationReport(request) return getApplicationReport(request);
.getApplicationReport();
} }
}); });
} }
@ -190,8 +192,7 @@ public class AppBlock extends HtmlBlock {
ApplicationAttemptReport>>() { ApplicationAttemptReport>>() {
@Override @Override
public Collection<ApplicationAttemptReport> run() throws Exception { public Collection<ApplicationAttemptReport> run() throws Exception {
return appBaseProt.getApplicationAttempts(request) return getApplicationAttemptsReport(request);
.getApplicationAttemptList();
} }
}); });
} catch (Exception e) { } catch (Exception e) {
@ -301,7 +302,7 @@ 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 = callerUGI.doAs(
new PrivilegedExceptionAction<ContainerReport>() { new PrivilegedExceptionAction<ContainerReport>() {
@ -310,8 +311,7 @@ public class AppBlock extends HtmlBlock {
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());
} }
@ -364,6 +364,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.Times; import org.apache.hadoop.yarn.util.Times;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock; import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
@ -70,15 +72,13 @@ 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 = callerUGI.doAs(
new PrivilegedExceptionAction<ContainerReport> () { new PrivilegedExceptionAction<ContainerReport> () {
@Override @Override
public ContainerReport run() throws Exception { public ContainerReport run() throws Exception {
return appBaseProt.getContainerReport(request) return getContainerReport(request);
.getContainerReport();
} }
}); });
} }
@ -126,4 +126,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,13 +156,13 @@ 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);
} }
}); });
} }
@ -220,7 +222,7 @@ 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 = callerUGI.doAs(
new PrivilegedExceptionAction<ApplicationReport> () { new PrivilegedExceptionAction<ApplicationReport> () {
@ -228,7 +230,7 @@ public class WebServices {
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);
} }
}); });
} }
@ -251,8 +253,7 @@ public class WebServices {
GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest request =
GetApplicationAttemptsRequest.newInstance(id); GetApplicationAttemptsRequest.newInstance(id);
appAttemptReports = appAttemptReports =
appBaseProt.getApplicationAttempts(request) getApplicationAttemptsReport(request);
.getApplicationAttemptList();
} else { } else {
appAttemptReports = callerUGI.doAs( appAttemptReports = callerUGI.doAs(
new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>> () { new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>> () {
@ -260,8 +261,7 @@ public class WebServices {
public Collection<ApplicationAttemptReport> run() throws Exception { public Collection<ApplicationAttemptReport> run() throws Exception {
GetApplicationAttemptsRequest request = GetApplicationAttemptsRequest request =
GetApplicationAttemptsRequest.newInstance(id); GetApplicationAttemptsRequest.newInstance(id);
return appBaseProt.getApplicationAttempts(request) return getApplicationAttemptsReport(request);
.getApplicationAttemptList();
} }
}); });
} }
@ -292,8 +292,7 @@ public class WebServices {
GetApplicationAttemptReportRequest request = GetApplicationAttemptReportRequest request =
GetApplicationAttemptReportRequest.newInstance(aaid); GetApplicationAttemptReportRequest.newInstance(aaid);
appAttempt = appAttempt =
appBaseProt.getApplicationAttemptReport(request) getApplicationAttemptReport(request);
.getApplicationAttemptReport();
} else { } else {
appAttempt = callerUGI.doAs( appAttempt = callerUGI.doAs(
new PrivilegedExceptionAction<ApplicationAttemptReport> () { new PrivilegedExceptionAction<ApplicationAttemptReport> () {
@ -301,8 +300,7 @@ public class WebServices {
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();
} }
}); });
} }
@ -327,14 +325,14 @@ public class WebServices {
if (callerUGI == null) { if (callerUGI == null) {
GetContainersRequest request = GetContainersRequest.newInstance(aaid); GetContainersRequest request = GetContainersRequest.newInstance(aaid);
containerReports = containerReports =
appBaseProt.getContainers(request).getContainerList(); getContainersReport(request);
} else { } else {
containerReports = callerUGI.doAs( containerReports = callerUGI.doAs(
new PrivilegedExceptionAction<Collection<ContainerReport>> () { 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 = GetContainersRequest.newInstance(aaid);
return appBaseProt.getContainers(request).getContainerList(); return getContainersReport(request);
} }
}); });
} }
@ -366,7 +364,7 @@ public class WebServices {
GetContainerReportRequest request = GetContainerReportRequest request =
GetContainerReportRequest.newInstance(cid); GetContainerReportRequest.newInstance(cid);
container = container =
appBaseProt.getContainerReport(request).getContainerReport(); getContainerReport(request);
} else { } else {
container = callerUGI.doAs( container = callerUGI.doAs(
new PrivilegedExceptionAction<ContainerReport> () { new PrivilegedExceptionAction<ContainerReport> () {
@ -374,7 +372,7 @@ public class WebServices {
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);
} }
}); });
} }
@ -516,4 +514,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;
@ -47,9 +50,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;
} }
@ -193,4 +195,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,47 @@
/**
* 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;
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

@ -72,7 +72,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;
@ -95,10 +100,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;
@ -223,7 +230,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 =
@ -2404,4 +2412,46 @@ 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);
} }