This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch dev-2.1.5
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev-2.1.5 by this push:
     new f5d4b67ab [Improve] flink cluster support proxy
f5d4b67ab is described below

commit f5d4b67ab53475d0f5e5565226550ce3df1b4bb3
Author: benjobs <[email protected]>
AuthorDate: Sun Aug 25 22:45:28 2024 +0800

    [Improve] flink cluster support proxy
---
 .../console/core/controller/ProxyController.java   | 15 +++++-----
 .../console/core/service/ProxyService.java         |  3 ++
 .../core/service/impl/ProxyServiceImpl.java        | 32 +++++++++++++++++-----
 .../src/locales/lang/en/flink/app.ts               |  6 ++--
 .../src/views/setting/FlinkCluster/index.vue       |  4 +--
 5 files changed, 41 insertions(+), 19 deletions(-)

diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProxyController.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProxyController.java
index a8b677081..6b1709c20 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProxyController.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ProxyController.java
@@ -19,8 +19,6 @@ package org.apache.streampark.console.core.controller;
 
 import org.apache.streampark.console.core.service.ProxyService;
 
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
@@ -41,21 +39,24 @@ public class ProxyController {
   @Autowired private ProxyService proxyService;
 
   @GetMapping("flink/{id}/**")
-  @RequiresPermissions("app:view")
   public ResponseEntity<?> proxyFlink(HttpServletRequest request, 
@PathVariable("id") Long id)
       throws Exception {
     return proxyService.proxyFlink(request, id);
   }
 
+  @GetMapping("cluster/{id}/**")
+  public ResponseEntity<?> proxyCluster(HttpServletRequest request, 
@PathVariable("id") Long id)
+      throws Exception {
+    return proxyService.proxyCluster(request, id);
+  }
+
   @GetMapping("history/{id}/**")
-  @RequiresPermissions("app:view")
-  public ResponseEntity<?> proxyHistory(HttpServletRequest request, 
@PathVariable("id") Long logId)
+  public ResponseEntity<?> proxyHistory(HttpServletRequest request, 
@PathVariable("id") Long id)
       throws Exception {
-    return proxyService.proxyHistory(request, logId);
+    return proxyService.proxyHistory(request, id);
   }
 
   @GetMapping("yarn/{id}/**")
-  @RequiresPermissions("app:view")
   public ResponseEntity<?> proxyYarn(HttpServletRequest request, 
@PathVariable("id") Long logId)
       throws Exception {
     return proxyService.proxyYarn(request, logId);
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/ProxyService.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/ProxyService.java
index aba092371..ef5774a65 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/ProxyService.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/ProxyService.java
@@ -22,9 +22,12 @@ import org.springframework.http.ResponseEntity;
 import javax.servlet.http.HttpServletRequest;
 
 public interface ProxyService {
+
   ResponseEntity<?> proxyFlink(HttpServletRequest request, Long id) throws 
Exception;
 
   ResponseEntity<?> proxyYarn(HttpServletRequest request, Long logId) throws 
Exception;
 
   ResponseEntity<?> proxyHistory(HttpServletRequest request, Long logId) 
throws Exception;
+
+  ResponseEntity<?> proxyCluster(HttpServletRequest request, Long clusterId) 
throws Exception;
 }
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProxyServiceImpl.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProxyServiceImpl.java
index ee7960fdb..2be531b0d 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProxyServiceImpl.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProxyServiceImpl.java
@@ -112,7 +112,7 @@ public class ProxyServiceImpl implements ProxyService {
       case YARN_SESSION:
         String yarnURL = YarnUtils.getRMWebAppProxyURL();
         url = yarnURL + "/proxy/" + app.getClusterId();
-        url += getRequestURL(request).replace("/proxy/flink/" + appId, "");
+        url += getRequestURL(request, "/proxy/flink/" + appId);
         return proxyYarnRequest(request, url);
       case REMOTE:
         FlinkCluster cluster = 
flinkClusterService.getById(app.getFlinkClusterId());
@@ -130,7 +130,7 @@ public class ProxyServiceImpl implements ProxyService {
       return builder.build();
     }
 
-    url += getRequestURL(request).replace("/proxy/flink/" + appId, "");
+    url += getRequestURL(request, "/proxy/flink/" + appId);
     return proxyRequest(request, url);
   }
 
@@ -145,7 +145,7 @@ public class ProxyServiceImpl implements ProxyService {
     String yarnId = log.getYarnAppId();
     String yarnURL = YarnUtils.getRMWebAppProxyURL();
     String url = yarnURL + "/proxy/" + yarnId + "/";
-    url += getRequestURL(request).replace("/proxy/yarn/" + logId, "");
+    url += getRequestURL(request, "/proxy/yarn/" + logId);
     return proxyYarnRequest(request, url);
   }
 
@@ -162,7 +162,23 @@ public class ProxyServiceImpl implements ProxyService {
     if (StringUtils.isBlank(url)) {
       return builder.body("The jobManager url is null.");
     }
-    url += getRequestURL(request).replace("/proxy/history/" + logId, "");
+    url += getRequestURL(request, "/proxy/history/" + logId);
+    return proxyRequest(request, url);
+  }
+
+  @Override
+  public ResponseEntity<?> proxyCluster(HttpServletRequest request, Long 
clusterId)
+      throws Exception {
+    ResponseEntity.BodyBuilder builder = 
ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE);
+    FlinkCluster cluster = flinkClusterService.getById(clusterId);
+    if (cluster == null) {
+      return builder.body("The cluster not found.");
+    }
+    String url = cluster.getAddress();
+    if (StringUtils.isBlank(url)) {
+      return builder.body("The cluster address is invalid.");
+    }
+    url += getRequestURL(request, "/proxy/cluster/" + clusterId);
     return proxyRequest(request, url);
   }
 
@@ -234,9 +250,11 @@ public class ProxyServiceImpl implements ProxyService {
     }
   }
 
-  private String getRequestURL(HttpServletRequest request) {
-    return request.getRequestURI()
-        + (request.getQueryString() != null ? "?" + request.getQueryString() : 
"");
+  private String getRequestURL(HttpServletRequest request, String 
replaceString) {
+    String url =
+        request.getRequestURI()
+            + (request.getQueryString() != null ? "?" + 
request.getQueryString() : "");
+    return url.replace(replaceString, "");
   }
 
   /**
diff --git 
a/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/app.ts 
b/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/app.ts
index b5fc6228c..e55f53ec9 100644
--- 
a/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/app.ts
+++ 
b/streampark-console/streampark-console-webapp/src/locales/lang/en/flink/app.ts
@@ -124,9 +124,9 @@ export default {
     copyStartcURL: 'App Start',
     copyCancelcURL: 'App Cancel',
     apiDocCenter: 'Api Doc Center',
-    nullAccessToken: "The current user's token not exist, please contact the 
administrator to add",
-    invalidAccessToken: 'access token is invalid, please contact the 
administrator',
-    invalidTokenUser: 'the user is locked, please contact the administrator',
+    nullAccessToken: "The current user have no token, please contact the admin 
to add",
+    invalidAccessToken: 'access token is invalid, please contact the admin',
+    invalidTokenUser: 'the user is locked, please contact the admin',
     detailTab: {
       detailTabName: {
         option: 'Option',
diff --git 
a/streampark-console/streampark-console-webapp/src/views/setting/FlinkCluster/index.vue
 
b/streampark-console/streampark-console-webapp/src/views/setting/FlinkCluster/index.vue
index 4137459b1..a27d0be49 100644
--- 
a/streampark-console/streampark-console-webapp/src/views/setting/FlinkCluster/index.vue
+++ 
b/streampark-console/streampark-console-webapp/src/views/setting/FlinkCluster/index.vue
@@ -184,7 +184,7 @@
             <div class="list-content-item">
               <span>{{ t('setting.flinkCluster.form.address') }}</span>
               <p style="margin-top: 10px">
-                <a :href="item.address" target="_blank">
+                <a :href="`/proxy/cluster/${item.id}/`" target="_blank">
                   {{ item.address }}
                 </a>
               </p>
@@ -237,7 +237,7 @@
                 :disabled="!handleIsStart(item)"
                 v-auth="'app:detail'"
                 shape="circle"
-                :href="item.address"
+                :href="`/proxy/cluster/${item.id}/`"
                 target="_blank"
                 size="large"
                 class="control-button"

Reply via email to