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.webapp.YarnWebParams.APPLICATION_ATTEMPT_ID;
import java.io.IOException;
import java.security.PrivilegedExceptionAction;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang.StringEscapeUtils;
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.ContainerReport;
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.ContainerInfo;
import org.apache.hadoop.yarn.util.ConverterUtils;
@ -77,18 +81,15 @@ public class AppAttemptBlock extends HtmlBlock {
final GetApplicationAttemptReportRequest request =
GetApplicationAttemptReportRequest.newInstance(appAttemptId);
if (callerUGI == null) {
appAttemptReport =
appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
appAttemptReport = getApplicationAttemptReport(request);
} else {
appAttemptReport = callerUGI.doAs(
new PrivilegedExceptionAction<ApplicationAttemptReport> () {
@Override
public ApplicationAttemptReport run() throws Exception {
return appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
}
});
appAttemptReport = callerUGI
.doAs(new PrivilegedExceptionAction<ApplicationAttemptReport>() {
@Override
public ApplicationAttemptReport run() throws Exception {
return getApplicationAttemptReport(request);
}
});
}
} catch (Exception e) {
String message =
@ -109,13 +110,13 @@ public class AppAttemptBlock extends HtmlBlock {
final GetContainersRequest request =
GetContainersRequest.newInstance(appAttemptId);
if (callerUGI == null) {
containers = appBaseProt.getContainers(request).getContainerList();
containers = getContainers(request);
} else {
containers = callerUGI.doAs(
new PrivilegedExceptionAction<Collection<ContainerReport>> () {
@Override
public Collection<ContainerReport> run() throws Exception {
return appBaseProt.getContainers(request).getContainerList();
return getContainers(request);
}
});
}
@ -191,6 +192,18 @@ public class AppAttemptBlock extends HtmlBlock {
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,
Collection<ContainerReport> containers, AppAttemptInfo appAttempt,
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.WEB_UI_TYPE;
import java.io.IOException;
import java.security.PrivilegedExceptionAction;
import java.util.Collection;
import java.util.List;
import java.util.Map;
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.conf.YarnConfiguration;
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.AppInfo;
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
@ -109,14 +112,13 @@ public class AppBlock extends HtmlBlock {
appReport =
appBaseProt.getApplicationReport(request).getApplicationReport();
} else {
appReport = callerUGI.doAs(
new PrivilegedExceptionAction<ApplicationReport> () {
@Override
public ApplicationReport run() throws Exception {
return appBaseProt.getApplicationReport(request)
.getApplicationReport();
}
});
appReport =
callerUGI.doAs(new PrivilegedExceptionAction<ApplicationReport>() {
@Override
public ApplicationReport run() throws Exception {
return getApplicationReport(request);
}
});
}
} catch (Exception e) {
String message = "Failed to read the application " + appID + ".";
@ -245,17 +247,16 @@ public class AppBlock extends HtmlBlock {
final GetApplicationAttemptsRequest request =
GetApplicationAttemptsRequest.newInstance(appID);
if (callerUGI == null) {
attempts = appBaseProt.getApplicationAttempts(request)
.getApplicationAttemptList();
attempts = getApplicationAttemptsReport(request);
} else {
attempts = callerUGI.doAs(
new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>> () {
@Override
public Collection<ApplicationAttemptReport> run() throws Exception {
return appBaseProt.getApplicationAttempts(request)
.getApplicationAttemptList();
}
});
new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>>() {
@Override
public Collection<ApplicationAttemptReport> run()
throws Exception {
return getApplicationAttemptsReport(request);
}
});
}
} catch (Exception e) {
String message =
@ -292,24 +293,23 @@ public class AppBlock extends HtmlBlock {
appAttemptReport.getAMContainerId());
if (callerUGI == null) {
containerReport =
appBaseProt.getContainerReport(request).getContainerReport();
getContainerReport(request);
} else {
containerReport = callerUGI.doAs(
new PrivilegedExceptionAction<ContainerReport>() {
@Override
public ContainerReport run() throws Exception {
ContainerReport report = null;
if (request.getContainerId() != null) {
try {
report = appBaseProt.getContainerReport(request)
.getContainerReport();
} catch (ContainerNotFoundException ex) {
LOG.warn(ex.getMessage());
containerReport =
callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() {
@Override
public ContainerReport run() throws Exception {
ContainerReport report = null;
if (request.getContainerId() != null) {
try {
report = getContainerReport(request);
} catch (ContainerNotFoundException ex) {
LOG.warn(ex.getMessage());
}
}
}
return report;
}
});
return report;
}
});
}
} catch (Exception e) {
String message =
@ -355,6 +355,26 @@ public class AppBlock extends HtmlBlock {
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) {
String ret = state.toString();
switch (state) {

View File

@ -30,6 +30,7 @@ import java.io.IOException;
import java.security.PrivilegedExceptionAction;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.math.LongRange;
@ -110,20 +111,24 @@ public class AppsBlock extends HtmlBlock {
new LongRange(appStartedTimeBegain, appStartedTimeEnd));
if (callerUGI == null) {
appReports = appBaseProt.getApplications(request).getApplicationList();
appReports = getApplicationReport(request);
} else {
appReports =
callerUGI
.doAs(new PrivilegedExceptionAction<Collection<ApplicationReport>>() {
@Override
public Collection<ApplicationReport> run() throws Exception {
return appBaseProt.getApplications(request)
.getApplicationList();
return getApplicationReport(request);
}
});
}
}
protected List<ApplicationReport> getApplicationReport(
final GetApplicationsRequest request) throws YarnException, IOException {
return appBaseProt.getApplications(request).getApplicationList();
}
@Override
public void render(Block html) {
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.webapp.YarnWebParams.CONTAINER_ID;
import java.io.IOException;
import java.security.PrivilegedExceptionAction;
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.records.ContainerId;
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.util.ConverterUtils;
import org.apache.hadoop.yarn.util.Times;
@ -71,17 +73,15 @@ public class ContainerBlock extends HtmlBlock {
final GetContainerReportRequest request =
GetContainerReportRequest.newInstance(containerId);
if (callerUGI == null) {
containerReport = appBaseProt.getContainerReport(request)
.getContainerReport();
containerReport = getContainerReport(request);
} else {
containerReport = callerUGI.doAs(
new PrivilegedExceptionAction<ContainerReport> () {
@Override
public ContainerReport run() throws Exception {
return appBaseProt.getContainerReport(request)
.getContainerReport();
}
});
containerReport =
callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() {
@Override
public ContainerReport run() throws Exception {
return getContainerReport(request);
}
});
}
} catch (Exception e) {
String message = "Failed to read the container " + containerid + ".";
@ -127,4 +127,10 @@ public class ContainerBlock extends HtmlBlock {
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;
import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
@ -51,13 +53,13 @@ import org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest;
import org.apache.hadoop.yarn.exceptions.ApplicationAttemptNotFoundException;
import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException;
import org.apache.hadoop.yarn.exceptions.ContainerNotFoundException;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptInfo;
import org.apache.hadoop.yarn.server.webapp.dao.AppAttemptsInfo;
import org.apache.hadoop.yarn.server.webapp.dao.AppInfo;
import org.apache.hadoop.yarn.server.webapp.dao.AppsInfo;
import org.apache.hadoop.yarn.server.webapp.dao.ContainerInfo;
import org.apache.hadoop.yarn.server.webapp.dao.ContainersInfo;
import org.apache.hadoop.yarn.util.ConverterUtils;
import org.apache.hadoop.yarn.webapp.BadRequestException;
import org.apache.hadoop.yarn.webapp.ForbiddenException;
import org.apache.hadoop.yarn.webapp.NotFoundException;
@ -154,15 +156,15 @@ public class WebServices {
if (callerUGI == null) {
// TODO: the request should take the params like what RMWebServices does
// in YARN-1819.
appReports = appBaseProt.getApplications(request).getApplicationList();
appReports = getApplicationsReport(request);
} else {
appReports = callerUGI.doAs(
new PrivilegedExceptionAction<Collection<ApplicationReport>> () {
@Override
public Collection<ApplicationReport> run() throws Exception {
return appBaseProt.getApplications(request).getApplicationList();
}
});
new PrivilegedExceptionAction<Collection<ApplicationReport>>() {
@Override
public Collection<ApplicationReport> run() throws Exception {
return getApplicationsReport(request);
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
@ -220,17 +222,17 @@ public class WebServices {
if (callerUGI == null) {
GetApplicationReportRequest request =
GetApplicationReportRequest.newInstance(id);
app = appBaseProt.getApplicationReport(request).getApplicationReport();
app = getApplicationReport(request);
} else {
app = callerUGI.doAs(
new PrivilegedExceptionAction<ApplicationReport> () {
@Override
public ApplicationReport run() throws Exception {
GetApplicationReportRequest request =
GetApplicationReportRequest.newInstance(id);
return appBaseProt.getApplicationReport(request).getApplicationReport();
}
});
app =
callerUGI.doAs(new PrivilegedExceptionAction<ApplicationReport>() {
@Override
public ApplicationReport run() throws Exception {
GetApplicationReportRequest request =
GetApplicationReportRequest.newInstance(id);
return getApplicationReport(request);
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
@ -250,20 +252,18 @@ public class WebServices {
if (callerUGI == null) {
GetApplicationAttemptsRequest request =
GetApplicationAttemptsRequest.newInstance(id);
appAttemptReports =
appBaseProt.getApplicationAttempts(request)
.getApplicationAttemptList();
appAttemptReports = getApplicationAttemptsReport(request);
} else {
appAttemptReports = callerUGI.doAs(
new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>> () {
@Override
public Collection<ApplicationAttemptReport> run() throws Exception {
GetApplicationAttemptsRequest request =
GetApplicationAttemptsRequest.newInstance(id);
return appBaseProt.getApplicationAttempts(request)
.getApplicationAttemptList();
}
});
new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>>() {
@Override
public Collection<ApplicationAttemptReport> run()
throws Exception {
GetApplicationAttemptsRequest request =
GetApplicationAttemptsRequest.newInstance(id);
return getApplicationAttemptsReport(request);
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
@ -291,20 +291,17 @@ public class WebServices {
if (callerUGI == null) {
GetApplicationAttemptReportRequest request =
GetApplicationAttemptReportRequest.newInstance(aaid);
appAttempt =
appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
appAttempt = getApplicationAttemptReport(request);
} else {
appAttempt = callerUGI.doAs(
new PrivilegedExceptionAction<ApplicationAttemptReport> () {
@Override
public ApplicationAttemptReport run() throws Exception {
GetApplicationAttemptReportRequest request =
GetApplicationAttemptReportRequest.newInstance(aaid);
return appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
}
});
appAttempt = callerUGI
.doAs(new PrivilegedExceptionAction<ApplicationAttemptReport>() {
@Override
public ApplicationAttemptReport run() throws Exception {
GetApplicationAttemptReportRequest request =
GetApplicationAttemptReportRequest.newInstance(aaid);
return getApplicationAttemptReport(request);
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
@ -326,17 +323,17 @@ public class WebServices {
try {
if (callerUGI == null) {
GetContainersRequest request = GetContainersRequest.newInstance(aaid);
containerReports =
appBaseProt.getContainers(request).getContainerList();
containerReports = getContainersReport(request);
} else {
containerReports = callerUGI.doAs(
new PrivilegedExceptionAction<Collection<ContainerReport>> () {
@Override
public Collection<ContainerReport> run() throws Exception {
GetContainersRequest request = GetContainersRequest.newInstance(aaid);
return appBaseProt.getContainers(request).getContainerList();
}
});
containerReports = callerUGI
.doAs(new PrivilegedExceptionAction<Collection<ContainerReport>>() {
@Override
public Collection<ContainerReport> run() throws Exception {
GetContainersRequest request =
GetContainersRequest.newInstance(aaid);
return getContainersReport(request);
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
@ -365,18 +362,17 @@ public class WebServices {
if (callerUGI == null) {
GetContainerReportRequest request =
GetContainerReportRequest.newInstance(cid);
container =
appBaseProt.getContainerReport(request).getContainerReport();
container = getContainerReport(request);
} else {
container = callerUGI.doAs(
new PrivilegedExceptionAction<ContainerReport> () {
@Override
public ContainerReport run() throws Exception {
GetContainerReportRequest request =
GetContainerReportRequest.newInstance(cid);
return appBaseProt.getContainerReport(request).getContainerReport();
}
});
container =
callerUGI.doAs(new PrivilegedExceptionAction<ContainerReport>() {
@Override
public ContainerReport run() throws Exception {
GetContainerReportRequest request =
GetContainerReportRequest.newInstance(cid);
return getContainerReport(request);
}
});
}
} catch (Exception e) {
rewrapAndThrowException(e);
@ -516,4 +512,36 @@ public class WebServices {
}
}
protected ApplicationReport getApplicationReport(
GetApplicationReportRequest request) throws YarnException, IOException {
return appBaseProt.getApplicationReport(request).getApplicationReport();
}
protected List<ApplicationReport> getApplicationsReport(
final GetApplicationsRequest request) throws YarnException, IOException {
return appBaseProt.getApplications(request).getApplicationList();
}
protected ApplicationAttemptReport getApplicationAttemptReport(
GetApplicationAttemptReportRequest request)
throws YarnException, IOException {
return appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
}
protected List<ApplicationAttemptReport> getApplicationAttemptsReport(
GetApplicationAttemptsRequest request) throws YarnException, IOException {
return appBaseProt.getApplicationAttempts(request)
.getApplicationAttemptList();
}
protected ContainerReport getContainerReport(
GetContainerReportRequest request) throws YarnException, IOException {
return appBaseProt.getContainerReport(request).getContainerReport();
}
protected List<ContainerReport> getContainersReport(
GetContainersRequest request) throws YarnException, IOException {
return appBaseProt.getContainers(request).getContainerList();
}
}

View File

@ -34,6 +34,7 @@ import org.apache.hadoop.security.token.delegation.DelegationKey;
import org.apache.hadoop.util.ExitUtil;
import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier;
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.Recoverable;
@ -52,7 +53,7 @@ public class RMDelegationTokenSecretManager extends
private static final Log LOG = LogFactory
.getLog(RMDelegationTokenSecretManager.class);
protected final RMContext rmContext;
private final ResourceManager rm;
/**
* Create a secret manager
@ -73,7 +74,7 @@ public class RMDelegationTokenSecretManager extends
RMContext rmContext) {
super(delegationKeyUpdateInterval, delegationTokenMaxLifetime,
delegationTokenRenewInterval, delegationTokenRemoverScanInterval);
this.rmContext = rmContext;
this.rm = rmContext.getResourceManager();
}
@Override
@ -85,7 +86,7 @@ public class RMDelegationTokenSecretManager extends
protected void storeNewMasterKey(DelegationKey newKey) {
try {
LOG.info("storing master key with keyID " + newKey.getKeyId());
rmContext.getStateStore().storeRMDTMasterKey(newKey);
rm.getRMContext().getStateStore().storeRMDTMasterKey(newKey);
} catch (Exception e) {
LOG.error("Error in storing master key with KeyID: " + newKey.getKeyId());
ExitUtil.terminate(1, e);
@ -96,7 +97,7 @@ public class RMDelegationTokenSecretManager extends
protected void removeStoredMasterKey(DelegationKey key) {
try {
LOG.info("removing master key with keyID " + key.getKeyId());
rmContext.getStateStore().removeRMDTMasterKey(key);
rm.getRMContext().getStateStore().removeRMDTMasterKey(key);
} catch (Exception e) {
LOG.error("Error in removing master key with KeyID: " + key.getKeyId());
ExitUtil.terminate(1, e);
@ -109,7 +110,8 @@ public class RMDelegationTokenSecretManager extends
try {
LOG.info("storing RMDelegation token with sequence number: "
+ identifier.getSequenceNumber());
rmContext.getStateStore().storeRMDelegationToken(identifier, renewDate);
rm.getRMContext().getStateStore().storeRMDelegationToken(identifier,
renewDate);
} catch (Exception e) {
LOG.error("Error in storing RMDelegationToken with sequence number: "
+ identifier.getSequenceNumber());
@ -123,7 +125,7 @@ public class RMDelegationTokenSecretManager extends
try {
LOG.info("updating RMDelegation token with sequence number: "
+ id.getSequenceNumber());
rmContext.getStateStore().updateRMDelegationToken(id, renewDate);
rm.getRMContext().getStateStore().updateRMDelegationToken(id, renewDate);
} catch (Exception e) {
LOG.error("Error in updating persisted RMDelegationToken" +
" with sequence number: " + id.getSequenceNumber());
@ -137,7 +139,7 @@ public class RMDelegationTokenSecretManager extends
try {
LOG.info("removing RMDelegation token with sequence number: "
+ ident.getSequenceNumber());
rmContext.getStateStore().removeRMDelegationToken(ident);
rm.getRMContext().getStateStore().removeRMDelegationToken(ident);
} catch (Exception e) {
LOG.error("Error in removing RMDelegationToken with sequence number: "
+ 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 org.apache.hadoop.yarn.server.webapp.ContainerBlock;
import org.apache.hadoop.yarn.webapp.SubView;
import org.apache.hadoop.yarn.webapp.YarnWebParams;
@ -38,7 +37,7 @@ public class ContainerPage extends RmView {
@Override
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._TH;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
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.ApplicationId;
import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
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.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
@ -61,7 +65,7 @@ public class RMAppAttemptBlock extends AppAttemptBlock{
@Inject
RMAppAttemptBlock(ViewContext ctx, ResourceManager rm, Configuration conf) {
super(rm.getClientRMService(), ctx);
super(null, ctx);
this.rm = rm;
this.conf = conf;
}
@ -275,4 +279,18 @@ public class RMAppAttemptBlock extends AppAttemptBlock{
createContainerLocalityTable(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 java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.hadoop.conf.Configuration;
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.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ContainerReport;
import org.apache.hadoop.yarn.api.records.LogAggregationStatus;
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.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics;
@ -52,7 +60,7 @@ public class RMAppBlock extends AppBlock{
@Inject
RMAppBlock(ViewContext ctx, Configuration conf, ResourceManager rm) {
super(rm.getClientRMService(), ctx, conf);
super(null, ctx, conf);
this.conf = conf;
this.rm = rm;
}
@ -187,4 +195,29 @@ public class RMAppBlock extends AppBlock{
}
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_VALUE;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.StringEscapeUtils;
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.ApplicationReport;
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.rmapp.RMApp;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
@ -48,9 +51,8 @@ public class RMAppsBlock extends AppsBlock {
private ResourceManager rm;
@Inject
RMAppsBlock(ResourceManager rm, ApplicationBaseProtocol appBaseProt,
View.ViewContext ctx) {
super(appBaseProt, ctx);
RMAppsBlock(ResourceManager rm, View.ViewContext ctx) {
super(null, ctx);
this.rm = rm;
}
@ -194,4 +196,11 @@ public class RMAppsBlock extends AppsBlock {
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 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.util.RMHAUtils;
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
@ -55,7 +54,6 @@ public class RMWebApp extends WebApp implements YarnWebParams {
if (rm != null) {
bind(ResourceManager.class).toInstance(rm);
bind(ApplicationBaseProtocol.class).toInstance(rm.getClientRMService());
}
route("/", RmController.class);
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.yarn.api.protocolrecords.CancelDelegationTokenRequest;
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.GetContainerReportRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetContainersRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenRequest;
import org.apache.hadoop.yarn.api.protocolrecords.GetDelegationTokenResponse;
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.UpdateApplicationTimeoutsRequest;
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.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
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.NodeId;
import org.apache.hadoop.yarn.api.records.NodeLabel;
@ -222,7 +229,8 @@ public class RMWebServices extends WebServices implements RMWebServiceProtocol {
@Inject
public RMWebServices(final ResourceManager rm, Configuration conf) {
super(rm.getClientRMService());
// don't inject, always take appBaseRoot from RM.
super(null);
this.rm = rm;
this.conf = conf;
isCentralizedNodeLabelConfiguration =
@ -2360,4 +2368,47 @@ public class RMWebServices extends WebServices implements RMWebServiceProtocol {
app.getApplicationTimeouts().get(appTimeout.getTimeoutType()));
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
createRMDelegationTokenSecretManager(long secretKeyInterval,
long tokenMaxLifetime, long tokenRenewInterval) {
ResourceManager rm = mock(ResourceManager.class);
RMContext rmContext = mock(RMContext.class);
when(rmContext.getStateStore()).thenReturn(new NullRMStateStore());
when(rm.getRMContext()).thenReturn(rmContext);
when(rmContext.getResourceManager()).thenReturn(rm);
RMDelegationTokenSecretManager rmDtSecretManager =
new RMDelegationTokenSecretManager(secretKeyInterval, tokenMaxLifetime,

View File

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

View File

@ -23,7 +23,6 @@ import static org.mockito.Mockito.when;
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.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.Resource;
@ -80,15 +79,13 @@ public class TestAppPage {
try {
ResourceManager rm = TestRMWebApp.mockRm(rmContext);
binder.bind(ResourceManager.class).toInstance(rm);
binder.bind(ApplicationBaseProtocol.class).toInstance(
rm.getClientRMService());
} catch (IOException 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.render();
}

View File

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

View File

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

View File

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