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 2022/10/26 12:16:40 UTC

[incubator-linkis] branch dev-1.3.1 updated: [BUG] retain all inRegistry ServiceInstance (#3703) (#3726)

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

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


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new e73d28b38 [BUG] retain all inRegistry ServiceInstance (#3703) (#3726)
e73d28b38 is described below

commit e73d28b38b0fc853b9c287dc6273c1eb7255046f
Author: 人生有如两个橘子 <15...@163.com>
AuthorDate: Wed Oct 26 20:16:33 2022 +0800

    [BUG] retain all inRegistry ServiceInstance (#3703) (#3726)
---
 .../linkis/gateway/ujes/route/DefaultLabelGatewayRouter.scala | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

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 0ca2b9dbd..bc4134218 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
@@ -83,14 +83,19 @@ class DefaultLabelGatewayRouter(var routeLabelParsers: util.List[RouteLabelParse
     if (serviceInstances.size() <= 0) {
       throw new GatewayErrorException(NO_ROUTE_SERVICE.getErrorCode, NO_ROUTE_SERVICE.getErrorDesc)
     }
-    val serviceId = serviceInstances.get(0).getApplicationName
-    val filteredInstances = retainAllInRegistry(serviceId, serviceInstances)
+
+    val serviceIds = serviceInstances.map(_.getApplicationName).distinct
+    val filteredInstances = new util.ArrayList[ServiceInstance]()
+    for (serviceId <- serviceIds) {
+      filteredInstances.addAll(retainAllInRegistry(serviceId, serviceInstances))
+    }
+
     if (filteredInstances.size() > 0) {
       filteredInstances.get(Random.nextInt(filteredInstances.size()))
     } else {
       throw new GatewayErrorException(
         CANNOT_INSTANCE.getErrorCode,
-        MessageFormat.format(CANNOT_INSTANCE.getErrorDesc, serviceId)
+        MessageFormat.format(CANNOT_INSTANCE.getErrorDesc, serviceIds.mkString(","))
       )
     }
   }


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