MAPREDUCE-7260. Cross origin request support for Job history server web UI. Contributed by Adam Antal
This commit is contained in:
parent
825db8fe2a
commit
7f3e1e0c07
@ -255,6 +255,13 @@ public class JHAdminConfig {
|
|||||||
public static final String MR_HISTORY_XFS_OPTIONS = MR_HISTORY_XFS_PREFIX +
|
public static final String MR_HISTORY_XFS_OPTIONS = MR_HISTORY_XFS_PREFIX +
|
||||||
"xframe-options";
|
"xframe-options";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CORS settings.
|
||||||
|
*/
|
||||||
|
public static final String MR_HISTORY_ENABLE_CORS_FILTER = MR_HISTORY_PREFIX +
|
||||||
|
"webapp.cross-origin.enabled";
|
||||||
|
public static final boolean DEFAULT_MR_HISTORY_ENABLE_CORS_FILTER = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings for .jhist file format.
|
* Settings for .jhist file format.
|
||||||
*/
|
*/
|
||||||
|
@ -75,6 +75,7 @@
|
|||||||
import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
|
import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
|
||||||
import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
|
import org.apache.hadoop.mapreduce.v2.util.MRWebAppUtil;
|
||||||
import org.apache.hadoop.net.NetUtils;
|
import org.apache.hadoop.net.NetUtils;
|
||||||
|
import org.apache.hadoop.security.HttpCrossOriginFilterInitializer;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
|
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
|
||||||
import org.apache.hadoop.security.token.Token;
|
import org.apache.hadoop.security.token.Token;
|
||||||
@ -154,6 +155,9 @@ protected void serviceStart() throws Exception {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected void initializeWebApp(Configuration conf) throws IOException {
|
protected void initializeWebApp(Configuration conf) throws IOException {
|
||||||
webApp = new HsWebApp(history);
|
webApp = new HsWebApp(history);
|
||||||
|
|
||||||
|
setupFilters(conf);
|
||||||
|
|
||||||
InetSocketAddress bindAddress = MRWebAppUtil.getJHSWebBindAddress(conf);
|
InetSocketAddress bindAddress = MRWebAppUtil.getJHSWebBindAddress(conf);
|
||||||
ApplicationClientProtocol appClientProtocol =
|
ApplicationClientProtocol appClientProtocol =
|
||||||
ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class);
|
ClientRMProxy.createRMProxy(conf, ApplicationClientProtocol.class);
|
||||||
@ -196,6 +200,17 @@ public InetSocketAddress getBindAddress() {
|
|||||||
return this.bindAddress;
|
return this.bindAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupFilters(Configuration conf) {
|
||||||
|
boolean enableCorsFilter =
|
||||||
|
conf.getBoolean(JHAdminConfig.MR_HISTORY_ENABLE_CORS_FILTER,
|
||||||
|
JHAdminConfig.DEFAULT_MR_HISTORY_ENABLE_CORS_FILTER);
|
||||||
|
|
||||||
|
if (enableCorsFilter) {
|
||||||
|
conf.setBoolean(HttpCrossOriginFilterInitializer.PREFIX
|
||||||
|
+ HttpCrossOriginFilterInitializer.ENABLED_SUFFIX, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class HSClientProtocolHandler implements HSClientProtocol {
|
private class HSClientProtocolHandler implements HSClientProtocol {
|
||||||
|
|
||||||
private RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
|
private RecordFactory recordFactory = RecordFactoryProvider.getRecordFactory(null);
|
||||||
|
Loading…
Reference in New Issue
Block a user