You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2023/03/27 06:43:09 UTC

[linkis] branch dev-1.3.2 updated: Feat move dss gateway support (#4408)

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

peacewong pushed a commit to branch dev-1.3.2
in repository https://gitbox.apache.org/repos/asf/linkis.git


The following commit(s) were added to refs/heads/dev-1.3.2 by this push:
     new 304fb3f46 Feat move dss gateway support (#4408)
304fb3f46 is described below

commit 304fb3f4624f45e5c25f6e6d41a8ea2e9904b32a
Author: Jack Xu <xu...@126.com>
AuthorDate: Mon Mar 27 14:43:01 2023 +0800

    Feat move dss gateway support (#4408)
    
    * feat(linkis-mg): move dss-gateway-support code to linkis
---
 .github/workflows/build-backend.yml                |   2 +-
 .mvn/wrapper/maven-wrapper.properties              |   2 +-
 linkis-dist/package/conf/log4j2.xml                |   8 +-
 linkis-dist/pom.xml                                |   5 +
 .../metadata/query/service/HdfsMetaService.java    |   1 +
 .../linkis-service-discovery/linkis-eureka/pom.xml |   6 +-
 .../linkis/gateway/parser}/RouteLabelParser.scala  |   2 +-
 .../linkis-gateway-server-support/pom.xml          |  16 +-
 .../src/main/assembly/distribution.xml             |   5 -
 .../dss/parser/DSSGatewayConfiguration.scala       |  31 +++
 .../gateway/dss/parser/DSSGatewayParser.scala      | 258 +++++++++++++++++++++
 .../gateway/dss/parser/DSSRouteLabelParser.scala   |  35 +++
 .../parser/EntranceExecutionGatewayParser.scala    |   3 +-
 .../ujes/route/DefaultLabelGatewayRouter.scala     |   2 +-
 .../ujes/route/GatewayRouterConfiguration.scala    |   2 +-
 linkis-spring-cloud-services/pom.xml               |   1 -
 16 files changed, 348 insertions(+), 31 deletions(-)

diff --git a/.github/workflows/build-backend.yml b/.github/workflows/build-backend.yml
index fec9f02f6..dcbb14187 100644
--- a/.github/workflows/build-backend.yml
+++ b/.github/workflows/build-backend.yml
@@ -20,7 +20,7 @@ name: Build Backend
 on: [push, pull_request]
 
 env:
-  MAVEN_OPTS: -Dmaven.resolver.transport=wagon -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
+  MAVEN_OPTS: -Dmaven.resolver.transport=wagon -Dmaven.wagon.httpconnectionManager.ttlSeconds=30
 
 jobs:
   build-backend:
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
index 08ea486aa..d8b2495a1 100644
--- a/.mvn/wrapper/maven-wrapper.properties
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -14,5 +14,5 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.0/apache-maven-3.9.0-bin.zip
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.1/apache-maven-3.9.1-bin.zip
 wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
diff --git a/linkis-dist/package/conf/log4j2.xml b/linkis-dist/package/conf/log4j2.xml
index c10f78e6c..f91717325 100644
--- a/linkis-dist/package/conf/log4j2.xml
+++ b/linkis-dist/package/conf/log4j2.xml
@@ -17,9 +17,13 @@
   -->
   
 <configuration status="error" monitorInterval="30">
+    <properties>
+        <property name="LOG_PATH">${env:LINKIS_LOG_DIR:-logs}</property>
+        <property name="LOG_FILE">${sys:serviceName:-linkis}</property>
+    </properties>
     <appenders>
-        <RollingFile name="RollingFile" append="true" fileName="${env:LINKIS_LOG_DIR}/${sys:serviceName}.log"
-                     filePattern="${env:LINKIS_LOG_DIR}/$${date:yyyy-MM}/${sys:serviceName}/linkis-log-%d{yyyy-MM-dd-hh}-%i.log">
+        <RollingFile name="RollingFile" append="true" fileName="${LOG_PATH}/${LOG_FILE}.log"
+                     filePattern="${LOG_PATH}/$${date:yyyy-MM}/${LOG_FILE}/linkis-log-%d{yyyy-MM-dd-hh}-%i.log">
             <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] [%-40t] %c{1.} (%L) [%M] - %msg%xEx%n"/>
             <Policies>
                 <SizeBasedTriggeringPolicy size="100MB"/>
diff --git a/linkis-dist/pom.xml b/linkis-dist/pom.xml
index b847950a7..54012cdb8 100644
--- a/linkis-dist/pom.xml
+++ b/linkis-dist/pom.xml
@@ -26,6 +26,11 @@
   <artifactId>linkis-dist</artifactId>
   <packaging>pom</packaging>
 
+  <properties>
+    <maven.deploy.skip>true</maven.deploy.skip>
+    <maven.install.skip>true</maven.install.skip>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.apache.linkis</groupId>
diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/service/hdfs/src/main/java/org/apache/linkis/metadata/query/service/HdfsMetaService.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/service/hdfs/src/main/java/org/apache/linkis/metadata/query/service/HdfsMetaService.java
index 7d8e10587..e546a32a1 100644
--- a/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/service/hdfs/src/main/java/org/apache/linkis/metadata/query/service/HdfsMetaService.java
+++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata-query/service/hdfs/src/main/java/org/apache/linkis/metadata/query/service/HdfsMetaService.java
@@ -78,6 +78,7 @@ public class HdfsMetaService extends AbstractFsMetaService<HdfsConnection> {
       HdfsConnection connection, Map<String, String> queryParams) {
     List<String> filterRules = new ArrayList<>();
     AtomicReference<URI> uriReference = new AtomicReference<>();
+    LOG.info("query hdfs ConnectionInfo for uri: {}", queryParams.get("uri"));
     Optional.ofNullable(queryParams.get("uri"))
         .ifPresent(
             uri -> {
diff --git a/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml b/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml
index 72a57fa25..e432fcd29 100644
--- a/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml
+++ b/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml
@@ -23,10 +23,14 @@
     <version>${revision}</version>
     <relativePath>../../../pom.xml</relativePath>
   </parent>
-
   <artifactId>linkis-eureka</artifactId>
   <packaging>jar</packaging>
 
+  <properties>
+    <maven.deploy.skip>true</maven.deploy.skip>
+    <maven.install.skip>true</maven.install.skip>
+  </properties>
+
   <dependencies>
     <dependency>
       <groupId>org.springframework.cloud</groupId>
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/label/RouteLabelParser.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/parser/RouteLabelParser.scala
similarity index 98%
rename from linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/label/RouteLabelParser.scala
rename to linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/parser/RouteLabelParser.scala
index 3bddda3de..9a01fbbbf 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/label/RouteLabelParser.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/parser/RouteLabelParser.scala
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.linkis.gateway.ujes.route.label
+package org.apache.linkis.gateway.parser
 
 import org.apache.linkis.common.utils.{Logging, Utils}
 import org.apache.linkis.gateway.http.GatewayContext
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/pom.xml b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/pom.xml
index ef4635ae0..8d8c131ab 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/pom.xml
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/pom.xml
@@ -94,19 +94,6 @@
       <artifactId>jackson-databind</artifactId>
     </dependency>
 
-    <!-- https://mavenlibs.com/maven/dependency/com.webank.wedatasphere.dss/dss-gateway-support -->
-    <dependency>
-      <groupId>com.webank.wedatasphere.dss</groupId>
-      <artifactId>dss-gateway-support</artifactId>
-      <version>1.1.1</version>
-      <exclusions>
-        <exclusion>
-          <groupId>org.apache.linkis</groupId>
-          <artifactId>linkis-gateway-server-support</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-
   </dependencies>
 
   <build>
@@ -115,7 +102,6 @@
         <groupId>net.alchim31.maven</groupId>
         <artifactId>scala-maven-plugin</artifactId>
       </plugin>
-
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-assembly-plugin</artifactId>
@@ -126,7 +112,7 @@
           <appendAssemblyId>false</appendAssemblyId>
           <attach>false</attach>
           <descriptors>
-            <descriptor>/src/main/assembly/distribution.xml</descriptor>
+            <descriptor>src/main/assembly/distribution.xml</descriptor>
           </descriptors>
         </configuration>
         <executions>
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/assembly/distribution.xml b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/assembly/distribution.xml
index 7180fea9c..cf2fd1232 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/assembly/distribution.xml
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/assembly/distribution.xml
@@ -21,7 +21,6 @@
     <id>linkis-gateway</id>
     <formats>
         <format>dir</format>
-        <format>zip</format>
     </formats>
     <includeBaseDirectory>false</includeBaseDirectory>
     <baseDirectory>linkis-gateway</baseDirectory>
@@ -44,9 +43,5 @@
         </dependencySet>
     </dependencySets>
 
-    <fileSets>
-
-    </fileSets>
-
 </assembly>
 
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/dss/parser/DSSGatewayConfiguration.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/dss/parser/DSSGatewayConfiguration.scala
new file mode 100644
index 000000000..8dd859e02
--- /dev/null
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/dss/parser/DSSGatewayConfiguration.scala
@@ -0,0 +1,31 @@
+/*
+ * 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.linkis.gateway.dss.parser
+
+import org.apache.linkis.common.conf.CommonVars
+
+object DSSGatewayConfiguration {
+  val DSS_SPRING_NAME = CommonVars("wds.linkis.dss.name", "dss-server")
+
+  val DSS_URL_LABEL_PREFIX = CommonVars("wds.dss.gateway.url.prefix.name", "labels")
+
+  val DSS_URL_ROUTE_LABEL_PREFIX = CommonVars("wds.dss.gateway.url.prefix.name", "labelsRoute")
+
+  val DSS_URL_APPCONNS = CommonVars("wds.dss.gateway.url.appconns", "visualis")
+
+}
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/dss/parser/DSSGatewayParser.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/dss/parser/DSSGatewayParser.scala
new file mode 100644
index 000000000..bdf8dfbe5
--- /dev/null
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/dss/parser/DSSGatewayParser.scala
@@ -0,0 +1,258 @@
+/*
+ * 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.linkis.gateway.dss.parser
+
+import org.apache.linkis.common.ServiceInstance
+import org.apache.linkis.gateway.exception.TooManyServiceException
+import org.apache.linkis.gateway.http.GatewayContext
+import org.apache.linkis.gateway.parser.AbstractGatewayParser
+import org.apache.linkis.gateway.springcloud.SpringCloudGatewayConfiguration.{
+  normalPath,
+  API_URL_PREFIX
+}
+import org.apache.linkis.manager.label.builder.factory.LabelBuilderFactoryContext
+import org.apache.linkis.manager.label.entity.Label
+import org.apache.linkis.manager.label.entity.route.RouteLabel
+import org.apache.linkis.protocol.constants.TaskConstant
+import org.apache.linkis.rpc.sender.SpringCloudFeignConfigurationCache
+import org.apache.linkis.server.BDPJettyServerHelper
+
+import org.springframework.stereotype.Component
+
+import java.util
+import java.util.Locale
+
+import scala.collection.JavaConverters._
+
+@Component
+class DSSGatewayParser extends AbstractGatewayParser {
+
+  val appConns = DSSGatewayConfiguration.DSS_URL_APPCONNS.getValue.split(",")
+
+  override def shouldContainRequestBody(gatewayContext: GatewayContext): Boolean = {
+    var contentType = gatewayContext.getRequest.getHeaders.get("Content-Type")
+    if (null == contentType) {
+      contentType = gatewayContext.getRequest.getHeaders.get("content-type")
+    }
+
+    if (
+        contentType != null && contentType.nonEmpty
+        && contentType(0).contains("form-data")
+    ) {
+      logger.info("DSS gateway get request type is form-data")
+      return false
+    }
+
+    gatewayContext.getRequest.getRequestURI match {
+      case DSSGatewayParser.DSS_URL_DEFAULT_REGEX(_, _) => true
+      case DSSGatewayParser.DSS_URL_REGEX(_, _, _) => true
+      case DSSGatewayParser.APPCONN_URL_DEFAULT_REGEX(_, appconn, _)
+          if appConns.contains(appconn) =>
+        true
+      case _ => false
+    }
+  }
+
+  override def parse(gatewayContext: GatewayContext): Unit =
+    gatewayContext.getRequest.getRequestURI match {
+
+      case DSSGatewayParser.DSS_URL_REGEX(version, firstName, secondName) =>
+        if (sendResponseWhenNotMatchVersion(gatewayContext, version)) return
+        var tmpServerName = "dss-" + firstName + "-" + secondName + "-server"
+        tmpServerName = getServiceNameFromLabel(gatewayContext, tmpServerName)
+        val serviceName: Option[String] =
+          findCommonService("dss/" + firstName + "/" + secondName, tmpServerName)
+        if (serviceName.isDefined) {
+          gatewayContext.getGatewayRoute.setServiceInstance(ServiceInstance(serviceName.get, null))
+        } else {
+          logger.info(
+            "Now set default serviceInstance name " + DSSGatewayConfiguration.DSS_SPRING_NAME.getValue + "," + gatewayContext.getRequest.getRequestURI
+          )
+          gatewayContext.getGatewayRoute.setServiceInstance(
+            ServiceInstance(DSSGatewayConfiguration.DSS_SPRING_NAME.getValue, null)
+          )
+        }
+      case DSSGatewayParser.DSS_URL_DEFAULT_REGEX(version, firstName) =>
+        if (sendResponseWhenNotMatchVersion(gatewayContext, version)) return
+        var tmpServerName = "dss-" + firstName + "-server"
+        tmpServerName = getServiceNameFromLabel(gatewayContext, tmpServerName)
+        val serviceName: Option[String] = findCommonService("dss/" + firstName, tmpServerName)
+        if (serviceName.isDefined) {
+          gatewayContext.getGatewayRoute.setServiceInstance(ServiceInstance(serviceName.get, null))
+        } else {
+          logger.info(
+            "Now set default serviceInstance name " + DSSGatewayConfiguration.DSS_SPRING_NAME.getValue + "," + gatewayContext.getRequest.getRequestURI
+          )
+          gatewayContext.getGatewayRoute.setServiceInstance(
+            ServiceInstance(DSSGatewayConfiguration.DSS_SPRING_NAME.getValue, null)
+          )
+        }
+      case DSSGatewayParser.APPCONN_URL_DEFAULT_REGEX(version, serverName, _)
+          if appConns.contains(serverName) =>
+        if (sendResponseWhenNotMatchVersion(gatewayContext, version)) return
+        var tmpServerName = serverName
+        tmpServerName = getServiceNameFromLabel(gatewayContext, tmpServerName)
+        val serviceName: Option[String] = findCommonService(tmpServerName, tmpServerName)
+        if (serviceName.isDefined) {
+          gatewayContext.getGatewayRoute.setServiceInstance(ServiceInstance(serviceName.get, null))
+        } else {
+          logger.info(
+            "Now set default serviceInstance name " + DSSGatewayConfiguration.DSS_SPRING_NAME.getValue + "," + gatewayContext.getRequest.getRequestURI
+          )
+          gatewayContext.getGatewayRoute.setServiceInstance(
+            ServiceInstance(DSSGatewayConfiguration.DSS_SPRING_NAME.getValue, null)
+          )
+        }
+      case _ =>
+    }
+
+  private def getServiceNameFromLabel(
+      gatewayContext: GatewayContext,
+      tmpServiceName: String
+  ): String = {
+    var requestUrlLabels = gatewayContext.getRequest.getQueryParams
+      .getOrDefault(DSSGatewayConfiguration.DSS_URL_LABEL_PREFIX.getValue, null)
+    if (requestUrlLabels == null) {
+      requestUrlLabels = gatewayContext.getRequest.getQueryParams
+        .getOrDefault(DSSGatewayConfiguration.DSS_URL_ROUTE_LABEL_PREFIX.getValue, null)
+    }
+    logger.info(
+      "Get ServiceName From  Label and method is " + gatewayContext.getRequest.getMethod.toString + ",and urlLabels is " + requestUrlLabels
+    )
+    val requestMethod = gatewayContext.getRequest.getMethod.toLowerCase(Locale.getDefault())
+    if (
+        requestUrlLabels == null && (requestMethod
+          .equals("post") || requestMethod.equals("put") || requestMethod.equals("delete"))
+    ) {
+      val requestBody = Option(gatewayContext.getRequest.getRequestBody)
+      val routeLabelList = new util.ArrayList[RouteLabel]()
+
+      requestBody match {
+        // todo form-data resolve
+        case Some(body) =>
+          val labelBuilderFactory = LabelBuilderFactoryContext.getLabelBuilderFactory
+          val json =
+            BDPJettyServerHelper.gson.fromJson(body, classOf[java.util.Map[String, Object]])
+          val labels: util.List[Label[_]] = json.get(TaskConstant.LABELS) match {
+            case map: util.Map[String, Object] => labelBuilderFactory.getLabels(map)
+            case map: util.Map[String, Any] => labelBuilderFactory.getLabels(map.asInstanceOf)
+            case _ => new util.ArrayList[Label[_]]()
+          }
+          labels.asScala
+            .filter(label => label.isInstanceOf[RouteLabel])
+            .foreach(label => {
+              routeLabelList.add(label.asInstanceOf[RouteLabel])
+            })
+
+        case _ => null
+      }
+      val labelNameList = routeLabelList.asScala.map(routeLabel => routeLabel.getStringValue).toList
+      if (labelNameList != null && labelNameList.size > 0) {
+        genServiceNameByDSSLabel(labelNameList, tmpServiceName)
+      } else if (null != requestUrlLabels) {
+        genServiceNameByDSSLabel(requestUrlLabels.toList, tmpServiceName)
+      } else tmpServiceName
+
+    } else {
+      if (requestUrlLabels != null) {
+        genServiceNameByDSSLabel(requestUrlLabels.toList, tmpServiceName)
+      } else tmpServiceName
+    }
+  }
+
+  private def genServiceNameByDSSLabel(labelList: List[String], tmpServiceName: String): String = {
+    var resultName = tmpServiceName
+    if (null != labelList && labelList.size > 0) {
+      val labelNameList = labelList(0).replace(" ", "").split(",").toList
+      if (labelNameList.size > 0) {
+        if (labelNameList.find(name => name.equalsIgnoreCase("dev")).isDefined) {
+          resultName = tmpServiceName + "-dev"
+        } else if (labelNameList.find(name => name.equalsIgnoreCase("prod")).isDefined) {
+          resultName = tmpServiceName + "-prod"
+        } else if (labelNameList.find(name => name.equalsIgnoreCase("test")).isDefined) {
+          resultName = tmpServiceName + "-test"
+        } else {
+          resultName = tmpServiceName
+        }
+      }
+    }
+    resultName
+  }
+
+  private def findCommonService(parsedServiceId: String, tmpServerName: String) = findService(
+    parsedServiceId,
+    tmpServerName,
+    services => {
+      val errorMsg = new TooManyServiceException(
+        s"Cannot find a correct serviceId for parsedServiceId $parsedServiceId, service list is: " + services
+      )
+      warn("", errorMsg)
+      throw errorMsg
+    }
+  )
+
+  protected def findService(
+      parsedServiceId: String,
+      tmpServerName: String,
+      tooManyDeal: List[String] => Option[String]
+  ): Option[String] = {
+    val findIt: (String => Boolean) => Option[String] = op => {
+      val services =
+        SpringCloudFeignConfigurationCache.getDiscoveryClient.getServices.asScala.filter(op).toList
+      if (services.length == 1) Some(services.head)
+      else if (services.length > 1) tooManyDeal(services)
+      else None
+    }
+    // 通过匹配到最多的url中的path进行路由,如/dss/framework/workspace/ 会匹配到 dss-framework-workspace-server 而不是 dss-server
+    // 如果产生了相等的情况,则按照短的service名字为准 比如/dss/getProject,
+    // 我们可能会匹配到dss-server以及 dss-framework-workspace-server,则选择短名称的dss-server
+    val findMostCorrect: (String => (String, Int)) => Option[String] = { op =>
+      {
+        val serviceMap =
+          SpringCloudFeignConfigurationCache.getDiscoveryClient.getServices.asScala.map(op).toMap
+        var count = 0
+        var retService: Option[String] = None
+        serviceMap.foreach { case (k, v) =>
+          if (v > count) {
+            count = v
+            retService = Some(k)
+          } else if (retService.isDefined && v == count && k.length < retService.get.length) {
+            retService = Some(k)
+          }
+        }
+        retService
+      }
+    }
+    val lowerServiceId = parsedServiceId.toLowerCase(Locale.getDefault())
+    val serverName = tmpServerName.toLowerCase(Locale.getDefault())
+    findIt(_.toLowerCase(Locale.getDefault()) == serverName).orElse(findMostCorrect(service => {
+      (service, lowerServiceId.split("/").count(word => service.contains(word)))
+    }))
+  }
+
+}
+
+object DSSGatewayParser {
+  val DSS_HEADER = normalPath(API_URL_PREFIX) + "rest_[a-zA-Z][a-zA-Z_0-9]*/(v\\d+)/dss/"
+  val DSS_URL_REGEX = (DSS_HEADER + "([^/]+)/" + "([^/]+)/.+").r
+  val DSS_URL_DEFAULT_REGEX = (DSS_HEADER + "([^/]+).+").r
+
+  val APPCONN_HEADER = normalPath(API_URL_PREFIX) + "rest_[a-zA-Z][a-zA-Z_0-9]*/(v\\d+)/([^/]+)/"
+  val APPCONN_URL_DEFAULT_REGEX = (APPCONN_HEADER + "([^/]+).+").r
+
+}
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/dss/parser/DSSRouteLabelParser.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/dss/parser/DSSRouteLabelParser.scala
new file mode 100644
index 000000000..48ec059ca
--- /dev/null
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/dss/parser/DSSRouteLabelParser.scala
@@ -0,0 +1,35 @@
+/*
+ * 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.linkis.gateway.dss.parser
+
+import org.apache.linkis.gateway.http.GatewayContext
+import org.apache.linkis.gateway.parser.RouteLabelParser
+import org.apache.linkis.manager.label.entity.route.RouteLabel
+
+import org.springframework.stereotype.Component
+
+import java.util
+
+@Component
+class DSSRouteLabelParser extends RouteLabelParser {
+
+  override def parse(gatewayContext: GatewayContext): util.List[RouteLabel] = {
+    new util.ArrayList[RouteLabel]()
+  }
+
+}
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceExecutionGatewayParser.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceExecutionGatewayParser.scala
index d5c4df23e..f46105190 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceExecutionGatewayParser.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/parser/EntranceExecutionGatewayParser.scala
@@ -20,9 +20,8 @@ package org.apache.linkis.gateway.ujes.parser
 import org.apache.linkis.common.ServiceInstance
 import org.apache.linkis.gateway.config.GatewayConfiguration
 import org.apache.linkis.gateway.http.GatewayContext
-import org.apache.linkis.gateway.parser.AbstractGatewayParser
+import org.apache.linkis.gateway.parser.{AbstractGatewayParser, RouteLabelParser}
 import org.apache.linkis.gateway.springcloud.SpringCloudGatewayConfiguration._
-import org.apache.linkis.gateway.ujes.route.label.RouteLabelParser
 import org.apache.linkis.instance.label.service.InsLabelService
 import org.apache.linkis.manager.label.entity.route.RouteLabel
 
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/DefaultLabelGatewayRouter.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/DefaultLabelGatewayRouter.scala
index d1c2318ae..70b0bfd4b 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/DefaultLabelGatewayRouter.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/DefaultLabelGatewayRouter.scala
@@ -21,7 +21,7 @@ import org.apache.linkis.common.ServiceInstance
 import org.apache.linkis.gateway.errorcode.LinkisGatewayCoreErrorCodeSummary._
 import org.apache.linkis.gateway.exception.GatewayErrorException
 import org.apache.linkis.gateway.http.GatewayContext
-import org.apache.linkis.gateway.ujes.route.label.RouteLabelParser
+import org.apache.linkis.gateway.parser.RouteLabelParser
 import org.apache.linkis.manager.label.entity.route.RouteLabel
 
 import org.apache.commons.lang3.StringUtils
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/GatewayRouterConfiguration.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/GatewayRouterConfiguration.scala
index 418d19259..208cd7fae 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/GatewayRouterConfiguration.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/src/main/scala/org/apache/linkis/gateway/ujes/route/GatewayRouterConfiguration.scala
@@ -18,8 +18,8 @@
 package org.apache.linkis.gateway.ujes.route
 
 import org.apache.linkis.common.utils.Logging
+import org.apache.linkis.gateway.parser.{GenericRoueLabelParser, RouteLabelParser}
 import org.apache.linkis.gateway.springcloud.SpringCloudGatewayConfiguration
-import org.apache.linkis.gateway.ujes.route.label.{GenericRoueLabelParser, RouteLabelParser}
 
 import org.springframework.boot.autoconfigure.AutoConfigureBefore
 import org.springframework.context.annotation.{Bean, Configuration, Scope}
diff --git a/linkis-spring-cloud-services/pom.xml b/linkis-spring-cloud-services/pom.xml
index 74473095b..f2a615916 100644
--- a/linkis-spring-cloud-services/pom.xml
+++ b/linkis-spring-cloud-services/pom.xml
@@ -28,7 +28,6 @@
   <packaging>pom</packaging>
 
   <modules>
-
     <module>linkis-service-discovery/linkis-eureka</module>
     <module>linkis-service-gateway</module>
   </modules>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org