knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject knox git commit: KNOX-803 - Adding rewrite rules for Map Reduce History Server UI (Shi Wang via lmccay)
Date Fri, 16 Dec 2016 03:03:55 GMT
Repository: knox
Updated Branches:
  refs/heads/master 785ea084a -> de34419d4


KNOX-803 - Adding rewrite rules for Map Reduce History Server UI (Shi Wang via lmccay)

Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/de34419d
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/de34419d
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/de34419d

Branch: refs/heads/master
Commit: de34419d48564049b49451e860bfe8a442e35af6
Parents: 785ea08
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Thu Dec 15 20:09:49 2016 -0500
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Thu Dec 15 20:09:49 2016 -0500

----------------------------------------------------------------------
 .../impl/html/HtmlFilterReaderBaseTest.java     | 30 +++++++++
 .../services/jobhistoryui/2.7.0/rewrite.xml     | 68 ++++++++++++++++----
 2 files changed, 84 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/de34419d/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReaderBaseTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReaderBaseTest.java
b/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReaderBaseTest.java
index c790e89..257a4ca 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReaderBaseTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlFilterReaderBaseTest.java
@@ -350,6 +350,36 @@ public class HtmlFilterReaderBaseTest {
     assertThat( outputXml, is( expectedOutput ) );
   }
 
+  @Test
+  public void testMRJobHistoryUIJavaScriptText() throws IOException, ParserConfigurationException
{
+    Map<String, Map<String, String>> rules = new HashMap<String, Map<String,
String>>();
+    Map<String, String> map = new HashMap<String, String>();
+    map.put( "https?://[^/':,]+:[\\d]+", "https://knoxhost:8443/gateway/nodemanagerui/node?host=knoxhost"
);
+    rules.put( "test-rule", map );
+    String inputXml =
+        "<root>\n" +
+        "  <script type=\"text/javascript\">\n" +
+        "    var appsTableData=[\n" +
+        "      [\"<a href='http://testhost:8042'>/default-rack/node</a>\",\"<a
href='http://testhost:8042'>testhost:8042</a>\"],\n" +
+        "    ]\n" +
+        "  </script>\n" +
+        "</root>\n";
+    StringReader inputReader = new StringReader( inputXml );
+    UrlRewriteFilterContentDescriptor config = new UrlRewriteFilterContentDescriptorImpl();
+    config.addApply("https?://[^/':,]+:[\\d]+", "test-rule");
+    HtmlFilterReaderBase filterReader = new MatchRuleXmlFilterReader( inputReader, rules,
config );
+    String outputXml = new String( IOUtils.toCharArray( filterReader ) );
+    String expectedOutput =
+        "<root>\n" +
+        "  <script type=\"text/javascript\">\n" +
+        "    var appsTableData=[\n" +
+        "      [\"<a href='https://knoxhost:8443/gateway/nodemanagerui/node?host=knoxhost'>/default-rack/node</a>\",\"<a
href='https://knoxhost:8443/gateway/nodemanagerui/node?host=knoxhost'>testhost:8042</a>\"],\n"
+
+        "    ]\n" +
+        "  </script>\n" +
+        "</root>\n";
+    assertThat( outputXml, is( expectedOutput ) );
+  }
+
   public static class XmlRewriteRulesDescriptorDigesterTest {
 
     private static DigesterLoader loader = DigesterLoader.newLoader( new XmlRewriteRulesDigester()
);

http://git-wip-us.apache.org/repos/asf/knox/blob/de34419d/gateway-service-definitions/src/main/resources/services/jobhistoryui/2.7.0/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/jobhistoryui/2.7.0/rewrite.xml
b/gateway-service-definitions/src/main/resources/services/jobhistoryui/2.7.0/rewrite.xml
index 69ce69e..2616881 100644
--- a/gateway-service-definitions/src/main/resources/services/jobhistoryui/2.7.0/rewrite.xml
+++ b/gateway-service-definitions/src/main/resources/services/jobhistoryui/2.7.0/rewrite.xml
@@ -28,6 +28,12 @@
   <rule dir="IN" name="JOBHISTORYUI/jobhistory/inbound/static" pattern="*://*:*/**/jobhistory/static/{**}">
     <rewrite template="{$serviceUrl[JOBHISTORYUI]}/static/{**}"/>
   </rule>
+  <rule dir="IN" name="JOBHISTORYUI/jobhistory/inbound/jobhistory" pattern="*://*:*/**/jobhistory/jobhistory/{**}">
+    <rewrite template="{$serviceUrl[JOBHISTORYUI]}/jobhistory/{**}"/>
+  </rule>
+  <rule dir="IN" name="JOBHISTORYUI/jobhistory/inbound/jobhistory/params" pattern="*://*:*/**/jobhistory/jobhistory/{**}?{**}">
+    <rewrite template="{$serviceUrl[JOBHISTORYUI]}/jobhistory/{**}?{**}"/>
+  </rule>
   <rule dir="IN" name="JOBHISTORYUI/jobhistory/inbound/conf" pattern="*://*:*/**/jobhistory/conf">
     <rewrite template="{$serviceUrl[JOBHISTORYUI]}/conf"/>
   </rule>
@@ -61,14 +67,24 @@
   <rule dir="IN" name="JOBHISTORYUI/jobhistory/inbound/jmx/query" pattern="*://*:*/**/jobhistory/jmx?{**}">
     <rewrite template="{$serviceUrl[JOBHISTORYUI]}/jmx?{**}"/>
   </rule>
+  <rule dir="IN" name="JOBHISTORYUI/jobhistory/inbound/logs" pattern="*://*:*/**/jobhistory/logs?{scheme}?{host}?{port}?{**}">
+    <rewrite template="{scheme}://{host}:{port}/logs/?{**}"/>
+  </rule>
 
-  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/headers/location">
-    <match pattern="{scheme}://{host}:{port}/logs/?{**}"/>
-    <rewrite template="{$frontend[url]}/jobhistory/logs?{scheme}?host={$hostmap(host)}?{port}?{**}"/>
+  <rule dir="IN" name="JOBHISTORYUI/nodelink/inbound" pattern="*://*:*/**/jobhistory/node?{scheme}?{host}?{port}">
+    <rewrite template="{scheme}://{host}:{port}/node?{scheme}?{host}?{port}"/>
   </rule>
-  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/logs/files" pattern="/logs/{**}">
-    <rewrite template="{$frontend[url]}/jobhistory/logs/{**}"/>
+
+
+  <!-- request out web content rewrite rules -->
+
+  <!-- rewrite map reduce node manager request -->
+  <!-- This maps to Nodemanager           -->
+  <rule dir="OUT" name="JOBHISTORYUI/nodelink" pattern="{scheme}://{host}:{port}">
+    <rewrite template="{$frontend[scheme]}://{$frontend[address]}/gateway/nodemanagerui/node?{host}"/>
   </rule>
+
+  <!-- static web resources (css, js, jpeg, etc). -->
   <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/static" pattern="/static/{**}">
     <rewrite template="{$frontend[url]}/jobhistory/static/{**}"/>
   </rule>
@@ -78,6 +94,11 @@
   <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/jobhistory/query" pattern="/jobhistory/{**}?{**}">
     <rewrite template="{$frontend[url]}/jobhistory/{**}?{**}"/>
   </rule>
+
+  <!-- tab content rewrite e.g. /conf, /logs, /stacks, /metrics,/jmx, etc -->
+  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/logs/files" pattern="/logs/{**}">
+    <rewrite template="{$frontend[url]}/jobhistory/logs/{**}"/>
+  </rule>
   <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/jobhistory/logs" pattern="/jobhistory/logs/{**}/?{**}">
     <rewrite template="{$frontend[url]}/jobhistory/joblogs/{**}/?{**}"/>
   </rule>
@@ -96,30 +117,49 @@
   <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/jmx" pattern="/jmx?{**}">
     <rewrite template="{$frontend[url]}/jobhistory/jmx?{**}"/>
   </rule>
-  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/jobs/job">
-    <rewrite template="{$frontend[url]}/jobhistory/job"/>
-  </rule>
-  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/jobs/task">
-    <rewrite template="{$frontend[url]}/jobhistory/task"/>
-  </rule>
-  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/jobs/logs">
-    <rewrite template="{$frontend[url]}/jobhistory/joblogs"/>
-  </rule>
+
+
+  <!-- 302 redirection for jobs, tasks, logs -->
   <filter name="JOBHISTORYUI/jobhistory/outbound/headers">
     <content type="application/x-http-headers">
       <apply path="Location" rule="JOBHISTORYUI/jobhistory/outbound/headers/location"/>
     </content>
   </filter>
+  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/headers/location">
+    <match pattern="{scheme}://{host}:{port}/logs/?{**}"/>
+    <rewrite template="{$frontend[url]}/jobhistory/logs?{scheme}?host={$hostmap(host)}?{port}?{**}"/>
+  </rule>
+
+  <!-- xml content rewrite  -->
   <filter name="JOBHISTORYUI/jobhistory/outbound/configuration">
     <content type="*/xml">
       <buffer path="/configuration/property"/>
     </content>
   </filter>
+
+  <!-- embedded javascript content rewrite -->
   <filter name="JOBHISTORYUI/jobhistory/outbound/jobs">
     <content type="*/html">
+      <apply path="https?://[^/':,]+:[\d]+" rule="JOBHISTORYUI/jobhistory/outbound/jobs/node"/>
       <apply path="/jobhistory/job" rule="JOBHISTORYUI/jobhistory/outbound/jobs/job"/>
       <apply path="/jobhistory/task" rule="JOBHISTORYUI/jobhistory/outbound/jobs/task"/>
       <apply path="/jobhistory/logs" rule="JOBHISTORYUI/jobhistory/outbound/jobs/logs"/>
     </content>
   </filter>
+
+  <!-- rules for embedded js rewrite   -->
+  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/jobs/job">
+    <rewrite template="{$frontend[url]}/jobhistory/job"/>
+  </rule>
+  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/jobs/task">
+    <rewrite template="{$frontend[url]}/jobhistory/task"/>
+  </rule>
+  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/jobs/logs">
+    <rewrite template="{$frontend[url]}/jobhistory/joblogs"/>
+  </rule>
+  <rule dir="OUT" name="JOBHISTORYUI/jobhistory/outbound/jobs/node">
+    <match pattern="{scheme}://{host}:{port}"/>
+    <rewrite template="{$frontend[scheme]}://{$frontend[address]}/gateway/nodemanagerui/node?host={host}"/>
+  </rule>
+
 </rules>
\ No newline at end of file


Mime
View raw message