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:
[email protected]
With regards,
Apache Git Services