-
Notifications
You must be signed in to change notification settings - Fork 268
KNOX-3249: Integrate new yarn scheduler-ui into KNOX homepage #1178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5758156
KNOX-3249: Integrate new yarn scheduler-ui into KNOX homepage
Hean-Chhinling b81e6ed
KNOX-3249: change the scheduler-ui logo
Hean-Chhinling 509e998
KNOX-3249: Change the path to yarn-scheduler-ui, add rules comments a…
Hean-Chhinling 138b559
KNOX-3249: Add unit test for ModelGenerator
Hean-Chhinling a536842
KNOX-3249: change file or directory names to yarn-scheduler-ui
Hean-Chhinling c0eb196
KNOX-3249: Change the image name to yarn-scheduler-ui
Hean-Chhinling ba055c5
KNOX-3249: Update to handle High Availability mode
Hean-Chhinling 2f8871e
KNOX-3249: add the missing license file
Hean-Chhinling File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...e/knox/gateway/topology/discovery/cm/model/yarn/YarnSchedulerUIServiceModelGenerator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...ox/gateway/topology/discovery/cm/model/yarn/YarnSchedulerUIServiceModelGeneratorTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| }; | ||
| } | ||
| } |
103 changes: 103 additions & 0 deletions
103
gateway-service-definitions/src/main/resources/services/yarn-scheduler-ui/1.0.0/rewrite.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/"> | ||
| <!-- 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> | ||
51 changes: 51 additions & 0 deletions
51
gateway-service-definitions/src/main/resources/services/yarn-scheduler-ui/1.0.0/service.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
47 changes: 47 additions & 0 deletions
47
...service-rm/src/main/java/org/apache/knox/gateway/rm/dispatch/RMSchedulerUIHaDispatch.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.