Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.knox.gateway.topology.discovery.cm.model.yarn;

public class YarnSchedulerUIServiceModelGenerator extends YarnUIServiceModelGenerator {
public static final String SERVICE = "YARN-SCHEDULER-UI";
public static final String SERVICE_TYPE = "YARN";
public static final String ROLE_TYPE = "RESOURCEMANAGER";

@Override
public String getService() {
return SERVICE;
}

@Override
public String getServiceType() {
return SERVICE_TYPE;
}

@Override
public String getRoleType() {
return ROLE_TYPE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ org.apache.knox.gateway.topology.discovery.cm.model.yarn.ResourceManagerApiServi
org.apache.knox.gateway.topology.discovery.cm.model.yarn.ResourceManagerUIServiceModelGenerator
org.apache.knox.gateway.topology.discovery.cm.model.yarn.YarnUIServiceModelGenerator
org.apache.knox.gateway.topology.discovery.cm.model.yarn.YarnUIv2ServiceModelGenerator
org.apache.knox.gateway.topology.discovery.cm.model.yarn.YarnSchedulerUIServiceModelGenerator
org.apache.knox.gateway.topology.discovery.cm.model.zeppelin.ZeppelinServiceModelGenerator
org.apache.knox.gateway.topology.discovery.cm.model.zeppelin.ZeppelinUIServiceModelGenerator
org.apache.knox.gateway.topology.discovery.cm.model.zeppelin.ZeppelinWSServiceModelGenerator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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.knox.gateway.topology.discovery.cm.model.yarn;

import com.cloudera.api.swagger.model.ApiConfigList;
import com.cloudera.api.swagger.model.ApiRole;
import com.cloudera.api.swagger.model.ApiService;
import com.cloudera.api.swagger.model.ApiServiceConfig;
import org.apache.knox.gateway.topology.discovery.cm.ServiceModelGenerator;
import org.apache.knox.gateway.topology.discovery.cm.model.AbstractServiceModelGeneratorTest;
import org.junit.Test;

import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class YarnSchedulerUIServiceModelGeneratorTest extends AbstractServiceModelGeneratorTest {

@Test
public void testServiceModelMetadata() throws Exception {
final Map<String, String> serviceConfig = Collections.emptyMap();

final Map<String, String> roleConfig = new HashMap<>();
roleConfig.put(YarnSchedulerUIServiceModelGenerator.RM_HTTP_PORT, "8088");
roleConfig.put(YarnSchedulerUIServiceModelGenerator.RM_HTTPS_PORT, "8090");

validateServiceModel(createServiceModel(serviceConfig, roleConfig), serviceConfig, roleConfig);
}

@Override
protected String getServiceType() {
return YarnSchedulerUIServiceModelGenerator.SERVICE_TYPE;
}

@Override
protected String getRoleType() {
return YarnSchedulerUIServiceModelGenerator.ROLE_TYPE;
}

@Override
protected ServiceModelGenerator newGenerator() {
return new YarnSchedulerUIServiceModelGenerator(){
@Override // To bypass the HDFS ssl_enable check
protected String generateURL(ApiService service, ApiServiceConfig serviceConfig, ApiRole role,
ApiConfigList roleConfig, ApiServiceConfig coreConfig) {

String hostname = role.getHostRef().getHostname();
String port = getRoleConfigValue(roleConfig, YarnSchedulerUIServiceModelGenerator.RM_HTTP_PORT);

return String.format(Locale.getDefault(), "http://%s:%s", hostname, port);
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->
<rules>
<rule dir="IN" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/root" pattern="*://*:*/**/yarn-scheduler-ui/">
Comment thread
Hean-Chhinling marked this conversation as resolved.
<!-- Based path to display the homepage-->
<rewrite template="{$serviceUrl[YARN-SCHEDULER-UI]}/scheduler-ui/"/>
</rule>

<rule dir="IN" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/path" pattern="*://*:*/**/yarn-scheduler-ui/{**}">
<!-- Taking the OUT rewritten rules back. Path only to request from /scheduler-ui/-->
<rewrite template="{$serviceUrl[YARN-SCHEDULER-UI]}/scheduler-ui/{**}"/>
</rule>

<rule dir="IN" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/query" pattern="*://*:*/**/yarn-scheduler-ui/{**}?{**}">
<!-- Taking the OUT rewritten rules back. Query only to request from /scheduler-ui/-->
<rewrite template="{$serviceUrl[YARN-SCHEDULER-UI]}/scheduler-ui/{**}?{**}"/>
</rule>

<rule dir="IN" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/ws-cluster" pattern="*://*:*/**/yarn-scheduler-ui/ws/v1/cluster/{**}">
<!-- Taking the OUT rewritten rules back. Path only to request to RM Rest API-->
<rewrite template="{$serviceUrl[YARN-SCHEDULER-UI]}/ws/v1/cluster/{**}"/>
</rule>

<rule dir="IN" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/ws-cluster-query" pattern="*://*:*/**/yarn-scheduler-ui/ws/v1/cluster/{**}?{**}">
<!-- Taking the OUT rewritten rules back. Query only to request to RM Rest API-->
<rewrite template="{$serviceUrl[YARN-SCHEDULER-UI]}/ws/v1/cluster/{**}?{**}"/>
</rule>

<rule dir="IN" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/conf-query" pattern="*://*:*/**/yarn-scheduler-ui/conf?{**}">
<!---This is for Scheduler UI calling conf?name=hadoop.security.authentication and conf?name=yarn.webapp.scheduler-ui.read-only.enable-->
<rewrite template="{$serviceUrl[YARN-SCHEDULER-UI]}/conf?{**}"/>
</rule>

<rule dir="OUT" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/site-base">
<!-- Rewriting any UI path to put behind knox proxy -->
<rewrite template="{$frontend[path]}/yarn-scheduler-ui/"/>
</rule>

<rule dir="OUT" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/api-cluster">
<!-- Rewriting any RestAPI path to put behind knox proxy -->
<rewrite template="{$frontend[path]}/yarn-scheduler-ui/ws/v1/cluster"/>
</rule>

<rule dir="OUT" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/assets">
<!-- Rewriting relative path link in HTML to put behind KNOX proxy,
E.g.from /assets/root-DBfchZlr.css to /gateway/cdp-proxy/yarn-scheduler-ui/assets/root-DBfchZlr.css
-->
<match pattern="/scheduler-ui/{**}">
<rewrite template="{$frontend[path]}/yarn-scheduler-ui/{**}"/>
</match>
</rule>

<rule flow="OR" dir="OUT" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/api-cluster/wildcard">
<!-- Rewriting Javascript RestAPI link behind KNOX proxy
E.g. from ws/v1/cluster/scheduler-conf to /gateway/cdp-proxy/yarn-scheduler-ui/ws/v1/cluster/scheduler-conf
-->
<match pattern="/ws/v1/cluster/{**}?{**}">
<rewrite template="{$frontend[path]}/yarn-scheduler-ui/ws/v1/cluster/{**}?{**}"/>
</match>

<match pattern="/ws/v1/cluster/{**}">
<rewrite template="{$frontend[path]}/yarn-scheduler-ui/ws/v1/cluster/{**}"/>
</match>
</rule>

<rule dir="OUT" name="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/conf">
<!--Putting the /conf endpoint behind KNOX proxy -->
<rewrite template="{$frontend[path]}/yarn-scheduler-ui/conf"/>
</rule>

<filter name="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/index">
<!--Filter out the link to put back behind knox proxy -->
<content type="*/html">
<apply path="/scheduler-ui" rule="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/site-base"/>
<apply path="/scheduler-ui/.*" rule="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/assets"/>
</content>
<content type="application/javascript">
<apply path="/scheduler-ui" rule="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/site-base"/>
<apply path="/ws/v1/cluster" rule="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/api-cluster"/>
<apply path="/ws/v1/cluster/.*" rule="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/api-cluster/wildcard"/>
<apply path="/conf" rule="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/conf"/>
</content>
<content type="text/css">
<apply path="/scheduler-ui/" rule="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/site-base"/>
</content>
</filter>

</rules>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->

<service role="YARN-SCHEDULER-UI" name="yarn-scheduler-ui" version="1.0.0">
<metadata>
<type>UI</type>
<context>/yarn-scheduler-ui/</context>
<shortDesc>YARN Scheduler UI</shortDesc>
<description>A modern React-based web interface for managing and configuring the YARN Capacity Scheduler.</description>
</metadata>
<routes>
<route path="/yarn-scheduler-ui/">
<rewrite apply="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/root" to="request.url"/>
<rewrite apply="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/index" to="response.body" />
</route>

<route path="/yarn-scheduler-ui/**">
<rewrite apply="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/path" to="request.url"/>
<rewrite apply="YARN-SCHEDULER-UI/yarn-scheduler-ui/outbound/index" to="response.body"/>
</route>

<route path="/yarn-scheduler-ui/ws/v1/cluster/**?**">
<rewrite apply="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/ws-cluster-query" to="request.url"/>
</route>

<route path="/yarn-scheduler-ui/ws/v1/cluster/**">
<rewrite apply="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/ws-cluster" to="request.url"/>
</route>

<route path="/yarn-scheduler-ui/conf?**">
<rewrite apply="YARN-SCHEDULER-UI/yarn-scheduler-ui/inbound/conf-query" to="request.url"/>
</route>
</routes>

<dispatch classname="org.apache.knox.gateway.dispatch.ConfigurableDispatch" ha-classname="org.apache.knox.gateway.rm.dispatch.RMSchedulerUIHaDispatch"/>
</service>
Original file line number Diff line number Diff line change
@@ -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.knox.gateway.rm.dispatch;

import org.apache.knox.gateway.config.Configure;
import org.apache.knox.gateway.ha.provider.HaProvider;
import org.apache.knox.gateway.ha.provider.HaServiceConfig;

public class RMSchedulerUIHaDispatch extends RMHaBaseDispatcher{
private static final String RESOURCE_ROLE = "YARN-SCHEDULER-UI";
private HaProvider haProvider;

public RMSchedulerUIHaDispatch() {
super();
}

@Override
@Configure
public void setHaProvider(HaProvider haProvider) {
this.haProvider = haProvider;
}

@Override
public void init() {
super.init();
if (haProvider != null) {
super.setResourceRole(RESOURCE_ROLE);
HaServiceConfig serviceConfig = haProvider.getHaDescriptor().getServiceConfig(RESOURCE_ROLE);
super.setMaxFailoverAttempts(serviceConfig.getMaxFailoverAttempts());
super.setFailoverSleep(serviceConfig.getFailoverSleep());
super.setHaProvider(haProvider);
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading