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 @@
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.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.webapp.hamlet2.Hamlet;
@ -77,15 +81,13 @@ protected void render(Block html) {
GetApplicationAttemptReportRequest.newInstance(appAttemptId);
if (callerUGI == null) {
appAttemptReport =
appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
getApplicationAttemptReport(request);
} else {
appAttemptReport = callerUGI.doAs(
new PrivilegedExceptionAction<ApplicationAttemptReport> () {
@Override
public ApplicationAttemptReport run() throws Exception {
return appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
return getApplicationAttemptReport(request);
}
});
}
@ -108,13 +110,13 @@ public ApplicationAttemptReport run() throws Exception {
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);
}
});
}
@ -190,6 +192,18 @@ public Collection<ContainerReport> run() throws Exception {
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.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;
@ -49,6 +51,7 @@
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;
@ -114,8 +117,7 @@ protected void render(Block html) {
new PrivilegedExceptionAction<ApplicationReport> () {
@Override
public ApplicationReport run() throws Exception {
return appBaseProt.getApplicationReport(request)
.getApplicationReport();
return getApplicationReport(request);
}
});
}
@ -190,8 +192,7 @@ public ApplicationReport run() throws Exception {
ApplicationAttemptReport>>() {
@Override
public Collection<ApplicationAttemptReport> run() throws Exception {
return appBaseProt.getApplicationAttempts(request)
.getApplicationAttemptList();
return getApplicationAttemptsReport(request);
}
});
} catch (Exception e) {
@ -301,7 +302,7 @@ protected void generateApplicationTable(Block html,
appAttemptReport.getAMContainerId());
if (callerUGI == null) {
containerReport =
appBaseProt.getContainerReport(request).getContainerReport();
getContainerReport(request);
} else {
containerReport = callerUGI.doAs(
new PrivilegedExceptionAction<ContainerReport>() {
@ -310,8 +311,7 @@ public ContainerReport run() throws Exception {
ContainerReport report = null;
if (request.getContainerId() != null) {
try {
report = appBaseProt.getContainerReport(request)
.getContainerReport();
report = getContainerReport(request);
} catch (ContainerNotFoundException ex) {
LOG.warn(ex.getMessage());
}
@ -364,6 +364,26 @@ public ContainerReport run() throws Exception {
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.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 @@ protected void fetchData() throws YarnException, IOException,
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 @@
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.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.Times;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
@ -70,15 +72,13 @@ protected void render(Block html) {
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();
return getContainerReport(request);
}
});
}
@ -126,4 +126,10 @@ public ContainerReport run() throws Exception {
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.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,13 +156,13 @@ public AppsInfo getApps(HttpServletRequest req, HttpServletResponse res,
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();
return getApplicationsReport(request);
}
});
}
@ -220,7 +222,7 @@ public AppInfo getApp(HttpServletRequest req, HttpServletResponse res,
if (callerUGI == null) {
GetApplicationReportRequest request =
GetApplicationReportRequest.newInstance(id);
app = appBaseProt.getApplicationReport(request).getApplicationReport();
app = getApplicationReport(request);
} else {
app = callerUGI.doAs(
new PrivilegedExceptionAction<ApplicationReport> () {
@ -228,7 +230,7 @@ public AppInfo getApp(HttpServletRequest req, HttpServletResponse res,
public ApplicationReport run() throws Exception {
GetApplicationReportRequest request =
GetApplicationReportRequest.newInstance(id);
return appBaseProt.getApplicationReport(request).getApplicationReport();
return getApplicationReport(request);
}
});
}
@ -251,8 +253,7 @@ public AppAttemptsInfo getAppAttempts(HttpServletRequest req,
GetApplicationAttemptsRequest request =
GetApplicationAttemptsRequest.newInstance(id);
appAttemptReports =
appBaseProt.getApplicationAttempts(request)
.getApplicationAttemptList();
getApplicationAttemptsReport(request);
} else {
appAttemptReports = callerUGI.doAs(
new PrivilegedExceptionAction<Collection<ApplicationAttemptReport>> () {
@ -260,8 +261,7 @@ public AppAttemptsInfo getAppAttempts(HttpServletRequest req,
public Collection<ApplicationAttemptReport> run() throws Exception {
GetApplicationAttemptsRequest request =
GetApplicationAttemptsRequest.newInstance(id);
return appBaseProt.getApplicationAttempts(request)
.getApplicationAttemptList();
return getApplicationAttemptsReport(request);
}
});
}
@ -292,8 +292,7 @@ public AppAttemptInfo getAppAttempt(HttpServletRequest req,
GetApplicationAttemptReportRequest request =
GetApplicationAttemptReportRequest.newInstance(aaid);
appAttempt =
appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
getApplicationAttemptReport(request);
} else {
appAttempt = callerUGI.doAs(
new PrivilegedExceptionAction<ApplicationAttemptReport> () {
@ -301,8 +300,7 @@ public AppAttemptInfo getAppAttempt(HttpServletRequest req,
public ApplicationAttemptReport run() throws Exception {
GetApplicationAttemptReportRequest request =
GetApplicationAttemptReportRequest.newInstance(aaid);
return appBaseProt.getApplicationAttemptReport(request)
.getApplicationAttemptReport();
return getApplicationAttemptReport(request);
}
});
}
@ -327,14 +325,14 @@ public ContainersInfo getContainers(HttpServletRequest req,
if (callerUGI == null) {
GetContainersRequest request = GetContainersRequest.newInstance(aaid);
containerReports =
appBaseProt.getContainers(request).getContainerList();
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();
return getContainersReport(request);
}
});
}
@ -366,7 +364,7 @@ public ContainerInfo getContainer(HttpServletRequest req,
GetContainerReportRequest request =
GetContainerReportRequest.newInstance(cid);
container =
appBaseProt.getContainerReport(request).getContainerReport();
getContainerReport(request);
} else {
container = callerUGI.doAs(
new PrivilegedExceptionAction<ContainerReport> () {
@ -374,7 +372,7 @@ public ContainerInfo getContainer(HttpServletRequest req,
public ContainerReport run() throws Exception {
GetContainerReportRequest request =
GetContainerReportRequest.newInstance(cid);
return appBaseProt.getContainerReport(request).getContainerReport();
return getContainerReport(request);
}
});
}
@ -516,4 +514,36 @@ private static void rewrapAndThrowThrowable(Throwable t) {
}
}
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.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 RMDelegationTokenSecretManager(long delegationKeyUpdateInterval,
RMContext rmContext) {
super(delegationKeyUpdateInterval, delegationTokenMaxLifetime,
delegationTokenRenewInterval, delegationTokenRemoverScanInterval);
this.rmContext = rmContext;
this.rm = rmContext.getResourceManager();
}
@Override
@ -85,7 +86,7 @@ public RMDelegationTokenIdentifier createIdentifier() {
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 @@ protected void storeNewMasterKey(DelegationKey newKey) {
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 @@ protected void storeNewToken(RMDelegationTokenIdentifier identifier,
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 @@ protected void updateStoredToken(RMDelegationTokenIdentifier id,
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 @@ protected void removeStoredToken(RMDelegationTokenIdentifier ident)
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 @@
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 @@ protected void preHead(Page.HTML<__> html) {
@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._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 @@ protected void createTablesForAttemptMetrics(Block html) {
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 @@
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 @@ protected LogAggregationStatus getLogAggregationStatus() {
}
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.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;
@ -47,9 +50,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;
}
@ -193,4 +195,11 @@ protected void renderData(Block html) {
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 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 void setup() {
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

@ -72,7 +72,12 @@
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;
@ -95,10 +100,12 @@
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;
@ -223,7 +230,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 =
@ -2404,4 +2412,46 @@ public Void run() throws IOException, YarnException {
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 @@ private static ResourceScheduler createMockScheduler(Configuration conf) {
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 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 void configure(Binder binder) {
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.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 void configure(Binder binder) {
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.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 void configure(Binder binder) {
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 void configure(Binder binder) {
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 @@
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 void configure(Binder binder) {
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);
}