You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2020/03/09 09:20:47 UTC

[GitHub] [knox] smolnar82 opened a new pull request #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata

smolnar82 opened a new pull request #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata
URL: https://github.com/apache/knox/pull/282
 
 
   ## What changes were proposed in this pull request?
   
   Corrected the contexts for Impala/Kudu/HBase UI services and fixed the code which selects the correct service definition when looking for metadata (the version was not considered before).
   
   ## How was this patch tested?
   
   Tested manually: added a sample descriptor (with IMPALAUI, KUDUUI, HBASEUI services) pointing to a remote cluster (where valid URLs are found). Knox generated the topology properly and the correct URLs are displayed on the Home page.
   
   <img width="1669" alt="Screen Shot 2020-03-09 at 9 57 13 AM" src="https://user-images.githubusercontent.com/34065904/76199059-736fb480-61ef-11ea-8e77-24d50c8efee2.png">
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [knox] smolnar82 commented on a change in pull request #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata

Posted by GitBox <gi...@apache.org>.
smolnar82 commented on a change in pull request #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata
URL: https://github.com/apache/knox/pull/282#discussion_r389879022
 
 

 ##########
 File path: gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/ServiceModel.java
 ##########
 @@ -101,14 +103,27 @@ public String getContext() {
   }
 
   @XmlElement
-  public String getServiceUrl() {
+  public String getServiceUrl() throws MalformedURLException {
     String context = getContext();
     if ("HIVE".equals(getServiceName())) {
       return String.format(Locale.ROOT, "jdbc:hive2://%s:%d/;?hive.server2.transport.mode=http;hive.server2.thrift.http.path=/%s/%s%s", request.getServerName(),
           request.getServerPort(), gatewayPath, topologyName, context);
     } else {
+      final String backendUrlString = getBackendServiceUrl();
       if (context.indexOf("{{BACKEND_HOST}}") > -1) {
-        context = context.replace("{{BACKEND_HOST}}", getBackendServiceUrl());
+        context = context.replace("{{BACKEND_HOST}}", backendUrlString);
+      }
+      if (context.indexOf("{{SCHEME}}") > -1 || context.indexOf("{{HOST}}") > -1 || context.indexOf("{{PORT}}") > -1) {
+        final URL backendUrl = new URL(backendUrlString);
+        if (context.indexOf("{{SCHEME}}") > -1) {
+          context = context.replace("{{SCHEME}}", backendUrl.getProtocol());
+        }
+        if (context.indexOf("{{HOST}}") > -1) {
+          context = context.replace("{{HOST}}", backendUrl.getHost());
+        }
+        if (context.indexOf("{{PORT}}") > -1) {
+          context = context.replace("{{PORT}}", String.valueOf(backendUrl.getPort()));
+        }
 
 Review comment:
   Fixed; I'll wait till Travis finishes and merge this one.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [knox] smolnar82 edited a comment on issue #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata

Posted by GitBox <gi...@apache.org>.
smolnar82 edited a comment on issue #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata
URL: https://github.com/apache/knox/pull/282#issuecomment-596701584
 
 
   > Looks good.
   > Suggestion: It might be useful if you update KNOX-2259 with additional fixes done here like for HBase and Metadata code.
   
   Done (HBase and Kudu have their own JIRAs; I referenced this PR for them too)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [knox] smolnar82 merged pull request #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata

Posted by GitBox <gi...@apache.org>.
smolnar82 merged pull request #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata
URL: https://github.com/apache/knox/pull/282
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [knox] smolnar82 commented on issue #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata

Posted by GitBox <gi...@apache.org>.
smolnar82 commented on issue #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata
URL: https://github.com/apache/knox/pull/282#issuecomment-596701584
 
 
   > Looks good.
   > Suggestion: It might be useful if you update KNOX-2259 with additional fixes done here like for HBase and Metadata code.
   
   Done (HBase and KUDU has its own JIRA; I referenced this PR for them too)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [knox] risdenk commented on a change in pull request #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata

Posted by GitBox <gi...@apache.org>.
risdenk commented on a change in pull request #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata
URL: https://github.com/apache/knox/pull/282#discussion_r389693686
 
 

 ##########
 File path: gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/ServiceModel.java
 ##########
 @@ -101,14 +103,27 @@ public String getContext() {
   }
 
   @XmlElement
-  public String getServiceUrl() {
+  public String getServiceUrl() throws MalformedURLException {
     String context = getContext();
     if ("HIVE".equals(getServiceName())) {
       return String.format(Locale.ROOT, "jdbc:hive2://%s:%d/;?hive.server2.transport.mode=http;hive.server2.thrift.http.path=/%s/%s%s", request.getServerName(),
           request.getServerPort(), gatewayPath, topologyName, context);
     } else {
+      final String backendUrlString = getBackendServiceUrl();
       if (context.indexOf("{{BACKEND_HOST}}") > -1) {
-        context = context.replace("{{BACKEND_HOST}}", getBackendServiceUrl());
+        context = context.replace("{{BACKEND_HOST}}", backendUrlString);
+      }
+      if (context.indexOf("{{SCHEME}}") > -1 || context.indexOf("{{HOST}}") > -1 || context.indexOf("{{PORT}}") > -1) {
+        final URL backendUrl = new URL(backendUrlString);
+        if (context.indexOf("{{SCHEME}}") > -1) {
+          context = context.replace("{{SCHEME}}", backendUrl.getProtocol());
+        }
+        if (context.indexOf("{{HOST}}") > -1) {
+          context = context.replace("{{HOST}}", backendUrl.getHost());
+        }
+        if (context.indexOf("{{PORT}}") > -1) {
+          context = context.replace("{{PORT}}", String.valueOf(backendUrl.getPort()));
+        }
 
 Review comment:
   Not sure we need all the double checks? Can't we just do `context.replace(...)` and if it doesn't match it won't replace? The strings here are super short. It might even be slower to do a check and then replace anyway.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [knox] smolnar82 commented on a change in pull request #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata

Posted by GitBox <gi...@apache.org>.
smolnar82 commented on a change in pull request #282: KNOX-2259 KNOX-2260 KNOX-2261 - Fixed Impala/Kudu/HBase UI context path in service metadata
URL: https://github.com/apache/knox/pull/282#discussion_r389871389
 
 

 ##########
 File path: gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/ServiceModel.java
 ##########
 @@ -101,14 +103,27 @@ public String getContext() {
   }
 
   @XmlElement
-  public String getServiceUrl() {
+  public String getServiceUrl() throws MalformedURLException {
     String context = getContext();
     if ("HIVE".equals(getServiceName())) {
       return String.format(Locale.ROOT, "jdbc:hive2://%s:%d/;?hive.server2.transport.mode=http;hive.server2.thrift.http.path=/%s/%s%s", request.getServerName(),
           request.getServerPort(), gatewayPath, topologyName, context);
     } else {
+      final String backendUrlString = getBackendServiceUrl();
       if (context.indexOf("{{BACKEND_HOST}}") > -1) {
-        context = context.replace("{{BACKEND_HOST}}", getBackendServiceUrl());
+        context = context.replace("{{BACKEND_HOST}}", backendUrlString);
+      }
+      if (context.indexOf("{{SCHEME}}") > -1 || context.indexOf("{{HOST}}") > -1 || context.indexOf("{{PORT}}") > -1) {
+        final URL backendUrl = new URL(backendUrlString);
+        if (context.indexOf("{{SCHEME}}") > -1) {
+          context = context.replace("{{SCHEME}}", backendUrl.getProtocol());
+        }
+        if (context.indexOf("{{HOST}}") > -1) {
+          context = context.replace("{{HOST}}", backendUrl.getHost());
+        }
+        if (context.indexOf("{{PORT}}") > -1) {
+          context = context.replace("{{PORT}}", String.valueOf(backendUrl.getPort()));
+        }
 
 Review comment:
   We definetly need the first if (backend URL may start with unknown protocol, such as dfs, ws, etc..) -> result in an error.
   I agree with the small ifs.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services