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

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


The following commit(s) were added to refs/heads/master by this push:
     new 60aa1c9a8 Support nacos discovery (#5008)
60aa1c9a8 is described below

commit 60aa1c9a8479a1c1c25a4996945c20f7eff66900
Author: Zhen Wang <[email protected]>
AuthorDate: Fri Dec 1 14:51:53 2023 +0800

    Support nacos discovery (#5008)
---
 linkis-commons/linkis-module/pom.xml               | 80 ++++++++++++++++++++--
 .../linkis-engineconn-manager-server/pom.xml       |  6 ++
 linkis-dist/bin/checkEnv.sh                        |  6 +-
 linkis-dist/bin/install.sh                         | 54 +++++++++++----
 linkis-dist/deploy-config/linkis-env.sh            |  7 ++
 .../conf/{ => eureka}/application-engineconn.yml   |  0
 .../conf/{ => eureka}/application-eureka.yml       |  0
 .../conf/{ => eureka}/application-linkis.yml       |  0
 .../conf/{ => nacos}/application-engineconn.yml    | 22 +++---
 .../conf/{ => nacos}/application-linkis.yml        | 30 ++++----
 linkis-dist/package/sbin/common.sh                 |  2 +
 linkis-dist/package/sbin/linkis-start-all.sh       |  8 ++-
 linkis-dist/package/sbin/linkis-stop-all.sh        |  8 ++-
 pom.xml                                            |  6 ++
 14 files changed, 174 insertions(+), 55 deletions(-)

diff --git a/linkis-commons/linkis-module/pom.xml 
b/linkis-commons/linkis-module/pom.xml
index d4ffc38e2..f92edb821 100644
--- a/linkis-commons/linkis-module/pom.xml
+++ b/linkis-commons/linkis-module/pom.xml
@@ -64,10 +64,6 @@
         </exclusion>
       </exclusions>
     </dependency>
-    <dependency>
-      <groupId>org.springframework.cloud</groupId>
-      <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
-    </dependency>
 
     <dependency>
       <groupId>org.springframework.boot</groupId>
@@ -277,4 +273,80 @@
     </plugins>
   </build>
 
+  <profiles>
+    <profile>
+      <id>eureka</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+        <property>
+          <name>discovery</name>
+          <value>eureka</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>org.springframework.cloud</groupId>
+          <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>nacos</id>
+      <activation>
+        <property>
+          <name>discovery</name>
+          <value>nacos</value>
+        </property>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>com.alibaba.cloud</groupId>
+          <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+          <exclusions>
+            <exclusion>
+              <groupId>org.springframework.boot</groupId>
+              <artifactId>*</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.springframework.cloud</groupId>
+              <artifactId>spring-cloud-commons</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.springframework.cloud</groupId>
+              <artifactId>spring-cloud-context</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.springframework.boot</groupId>
+              <artifactId>spring-boot-starter</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>com.fasterxml.jackson.core</groupId>
+              <artifactId>jackson-core</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>com.fasterxml.jackson.core</groupId>
+              <artifactId>jackson-databind</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>com.google.code.findbugs</groupId>
+              <artifactId>jsr305</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>org.yaml</groupId>
+              <artifactId>snakeyaml</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>io.prometheus</groupId>
+              <artifactId>simpleclient</artifactId>
+            </exclusion>
+            <exclusion>
+              <groupId>com.google.guava</groupId>
+              <artifactId>guava</artifactId>
+            </exclusion>
+          </exclusions>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
+
 </project>
diff --git 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/pom.xml
 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/pom.xml
index 41022d30d..99458c8af 100644
--- 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/pom.xml
+++ 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/pom.xml
@@ -51,6 +51,12 @@
       <artifactId>linkis-rpc</artifactId>
       <version>${project.version}</version>
       <scope>provided</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>com.google.guava</groupId>
+          <artifactId>guava</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
 
     <dependency>
diff --git a/linkis-dist/bin/checkEnv.sh b/linkis-dist/bin/checkEnv.sh
index cca13ac30..aea783cd7 100644
--- a/linkis-dist/bin/checkEnv.sh
+++ b/linkis-dist/bin/checkEnv.sh
@@ -203,8 +203,10 @@ echo -e "\n<-----End to check service status---->"
 # --- check Service Port
 echo -e "\n3. <-----Start to check service Port---->"
 
-SERVER_PORT=$EUREKA_PORT
-check_service_port
+if [ "$DISCOVERY" == "EUREKA" ]; then
+  SERVER_PORT=$EUREKA_PORT
+  check_service_port
+fi
 
 SERVER_PORT=$GATEWAY_PORT
 check_service_port
diff --git a/linkis-dist/bin/install.sh b/linkis-dist/bin/install.sh
index d6e50221d..5db6b5224 100644
--- a/linkis-dist/bin/install.sh
+++ b/linkis-dist/bin/install.sh
@@ -110,6 +110,14 @@ else
     isSuccess "cp ${LINKIS_PACKAGE} to $LINKIS_HOME"
 fi
 
+if [ "$DISCOVERY" == "NACOS" ]; then
+  mv $LINKIS_HOME/conf/nacos/* $LINKIS_HOME/conf
+else
+  mv $LINKIS_HOME/conf/eureka/* $LINKIS_HOME/conf
+fi
+rm -rf $LINKIS_HOME/conf/nacos
+rm -rf $LINKIS_HOME/conf/eureka
+
 cp ${LINKIS_CONFIG_PATH} $LINKIS_HOME/conf
 cp ${LINKIS_DB_CONFIG_PATH} $LINKIS_HOME/conf
 
@@ -407,34 +415,50 @@ fi
 
 currentTime=`date +%Y%m%d%H%M%S`
 
-##eureka
-sed -i ${txt}  "s#defaultZone:.*#defaultZone: $EUREKA_URL#g" 
$LINKIS_HOME/conf/application-eureka.yml
-sed -i ${txt}  "s#port:.*#port: $EUREKA_PORT#g" 
$LINKIS_HOME/conf/application-eureka.yml
 sed -i ${txt}  "s#linkis.app.version:.*#linkis.app.version: 
$LINKIS_VERSION-$currentTime#g" $LINKIS_HOME/conf/application-eureka.yml
-
-##server application.yml
-sed -i ${txt}  "s#defaultZone:.*#defaultZone: $EUREKA_URL#g" 
$LINKIS_HOME/conf/application-linkis.yml
 sed -i ${txt}  "s#linkis.app.version:.*#linkis.app.version: 
$LINKIS_VERSION-$currentTime#g" $LINKIS_HOME/conf/application-linkis.yml
-
-sed -i ${txt}  "s#defaultZone:.*#defaultZone: $EUREKA_URL#g" 
$LINKIS_HOME/conf/application-engineconn.yml
 sed -i ${txt}  "s#linkis.app.version:.*#linkis.app.version: 
$LINKIS_VERSION-$currentTime#g" $LINKIS_HOME/conf/application-engineconn.yml
 
-if [ "$EUREKA_PREFER_IP" == "true" ]; then
-  sed -i ${txt}  "s/# prefer-ip-address:/prefer-ip-address:/g" 
$LINKIS_HOME/conf/application-eureka.yml
+sed -i ${txt}  "s#DISCOVERY=.*#DISCOVERY=$DISCOVERY#g" 
$LINKIS_HOME/sbin/common.sh
+
+if [ "$DISCOVERY" == "EUREKA" ]; then
+  ##eureka
+  sed -i ${txt}  "s#defaultZone:.*#defaultZone: $EUREKA_URL#g" 
$LINKIS_HOME/conf/application-eureka.yml
+  sed -i ${txt}  "s#port:.*#port: $EUREKA_PORT#g" 
$LINKIS_HOME/conf/application-eureka.yml
+  sed -i ${txt}  "s#linkis.app.version:.*#linkis.app.version: 
$LINKIS_VERSION-$currentTime#g" $LINKIS_HOME/conf/application-eureka.yml
+
+  ##server application.yml
+  sed -i ${txt}  "s#defaultZone:.*#defaultZone: $EUREKA_URL#g" 
$LINKIS_HOME/conf/application-linkis.yml
 
-  sed -i ${txt}  "s/# prefer-ip-address:/prefer-ip-address:/g" 
$LINKIS_HOME/conf/application-linkis.yml
-  sed -i ${txt}  "s/# instance-id:/instance-id:/g" 
$LINKIS_HOME/conf/application-linkis.yml
+  sed -i ${txt}  "s#defaultZone:.*#defaultZone: $EUREKA_URL#g" 
$LINKIS_HOME/conf/application-engineconn.yml
 
-  sed -i ${txt}  "s/# prefer-ip-address:/prefer-ip-address:/g" 
$LINKIS_HOME/conf/application-engineconn.yml
-  sed -i ${txt}  "s/# instance-id:/instance-id:/g" 
$LINKIS_HOME/conf/application-linkis.yml
+  if [ "$EUREKA_PREFER_IP" == "true" ]; then
+    sed -i ${txt}  "s/# prefer-ip-address:/prefer-ip-address:/g" 
$LINKIS_HOME/conf/application-eureka.yml
+
+    sed -i ${txt}  "s/# prefer-ip-address:/prefer-ip-address:/g" 
$LINKIS_HOME/conf/application-linkis.yml
+    sed -i ${txt}  "s/# instance-id:/instance-id:/g" 
$LINKIS_HOME/conf/application-linkis.yml
+
+    sed -i ${txt}  "s/# prefer-ip-address:/prefer-ip-address:/g" 
$LINKIS_HOME/conf/application-engineconn.yml
+    sed -i ${txt}  "s/# instance-id:/instance-id:/g" 
$LINKIS_HOME/conf/application-linkis.yml
+
+    sed -i ${txt}  
"s#linkis.discovery.prefer-ip-address.*#linkis.discovery.prefer-ip-address=true#g"
 $common_conf
+  fi
+  export DISCOVERY_SERVER_ADDRES=$EUREKA_INSTALL_IP:$EUREKA_POR
+fi
+
+if [ "$DISCOVERY" == "NACOS" ]; then
+  sed -i ${txt}  "s#server-addr:.*#server-addr: $NACOS_SERVER_ADDR#g" 
$LINKIS_HOME/conf/application-linkis.yml
+  sed -i ${txt}  "s#server-addr:.*#server-addr: $NACOS_SERVER_ADDR#g" 
$LINKIS_HOME/conf/application-engineconn.yml
 
   sed -i ${txt}  
"s#linkis.discovery.prefer-ip-address.*#linkis.discovery.prefer-ip-address=true#g"
 $common_conf
+
+  export DISCOVERY_SERVER_ADDRES=$NACOS_SERVER_ADDR
 fi
 
 echo "update conf $common_conf"
 sed -i ${txt}  
"s#wds.linkis.server.version.*#wds.linkis.server.version=$LINKIS_SERVER_VERSION#g"
 $common_conf
 sed -i ${txt}  
"s#wds.linkis.gateway.url.*#wds.linkis.gateway.url=http://$GATEWAY_INSTALL_IP:$GATEWAY_PORT#g";
 $common_conf
-sed -i ${txt}  
"s#linkis.discovery.server-address.*#linkis.discovery.server-address=http://$EUREKA_INSTALL_IP:$EUREKA_PORT#g";
 $common_conf
+sed -i ${txt}  
"s#linkis.discovery.server-address.*#linkis.discovery.server-address=http://$DISCOVERY_SERVER_ADDRES#g";
 $common_conf
 if [[ 'postgresql' = "$dbType" ]];then
   sed -i ${txt}  
"s#wds.linkis.server.mybatis.datasource.url.*#wds.linkis.server.mybatis.datasource.url=jdbc:postgresql://${PG_HOST}:${PG_PORT}/${PG_DB}?currentSchema=${PG_SCHEMA}\&stringtype=unspecified#g"
 $common_conf
   sed -i ${txt}  
"s#wds.linkis.server.mybatis.datasource.username.*#wds.linkis.server.mybatis.datasource.username=$PG_USER#g"
 $common_conf
diff --git a/linkis-dist/deploy-config/linkis-env.sh 
b/linkis-dist/deploy-config/linkis-env.sh
index f37d0720a..fed49826b 100644
--- a/linkis-dist/deploy-config/linkis-env.sh
+++ b/linkis-dist/deploy-config/linkis-env.sh
@@ -111,6 +111,9 @@ SPARK_CONF_DIR=/appcom/config/spark-config
 #            Linkis in a distributed manner and set the following microservice 
parameters
 #
 
+###  DISCOVERY
+DISCOVERY=EUREKA
+
 ###  EUREKA install information
 ###  You can access it in your browser at the address 
below:http://${EUREKA_INSTALL_IP}:${EUREKA_PORT}
 #EUREKA: Microservices Service Registration Discovery Center
@@ -119,6 +122,10 @@ EUREKA_PORT=20303
 export EUREKA_PREFER_IP=false
 #EUREKA_HEAP_SIZE="512M"
 
+###  NACOS install information
+###  NACOS
+NACOS_SERVER_ADDR=127.0.0.1:8848
+
 ##linkis-mg-gateway
 #GATEWAY_INSTALL_IP=127.0.0.1
 GATEWAY_PORT=9001
diff --git a/linkis-dist/package/conf/application-engineconn.yml 
b/linkis-dist/package/conf/eureka/application-engineconn.yml
similarity index 100%
copy from linkis-dist/package/conf/application-engineconn.yml
copy to linkis-dist/package/conf/eureka/application-engineconn.yml
diff --git a/linkis-dist/package/conf/application-eureka.yml 
b/linkis-dist/package/conf/eureka/application-eureka.yml
similarity index 100%
rename from linkis-dist/package/conf/application-eureka.yml
rename to linkis-dist/package/conf/eureka/application-eureka.yml
diff --git a/linkis-dist/package/conf/application-linkis.yml 
b/linkis-dist/package/conf/eureka/application-linkis.yml
similarity index 100%
copy from linkis-dist/package/conf/application-linkis.yml
copy to linkis-dist/package/conf/eureka/application-linkis.yml
diff --git a/linkis-dist/package/conf/application-engineconn.yml 
b/linkis-dist/package/conf/nacos/application-engineconn.yml
similarity index 66%
rename from linkis-dist/package/conf/application-engineconn.yml
rename to linkis-dist/package/conf/nacos/application-engineconn.yml
index 4f9610513..0cf4dd90b 100644
--- a/linkis-dist/package/conf/application-engineconn.yml
+++ b/linkis-dist/package/conf/nacos/application-engineconn.yml
@@ -20,20 +20,14 @@ spring:
       max-file-size: 500MB
       max-request-size: 500MB
       file-size-threshold: 50MB
-eureka:
-  instance:
-    # prefer-ip-address: true
-    # instance-id: 
${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}
-    lease-renewal-interval-in-seconds: 4
-    lease-expiration-duration-in-seconds: 12
-    metadata-map:
-      prometheus.path: ${prometheus.path:/api/rest_j/v1/actuator/prometheus}
-      linkis.app.version: ${linkis.app.version}
-  client:
-    serviceUrl:
-      defaultZone: http://127.0.0.1:20303/eureka/
-    registry-fetch-interval-seconds: 8
-    initial-instance-info-replication-interval-seconds: 10
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        metadata:
+          prometheus.path: 
${prometheus.path:/api/rest_j/v1/actuator/prometheus}
+          linkis.app.version: ${linkis.app.version}
+
 management:
   endpoints:
     web:
diff --git a/linkis-dist/package/conf/application-linkis.yml 
b/linkis-dist/package/conf/nacos/application-linkis.yml
similarity index 72%
rename from linkis-dist/package/conf/application-linkis.yml
rename to linkis-dist/package/conf/nacos/application-linkis.yml
index 868a94294..07dc8adeb 100644
--- a/linkis-dist/package/conf/application-linkis.yml
+++ b/linkis-dist/package/conf/nacos/application-linkis.yml
@@ -13,19 +13,13 @@
 # limitations under the License.
 #
 
-eureka:
-  instance:
-    # prefer-ip-address: true
-    # instance-id: 
${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}
-    lease-renewal-interval-in-seconds: 4
-    lease-expiration-duration-in-seconds: 12
-    metadata-map:
-      prometheus.path: ${prometheus.path:${prometheus.endpoint}}
-      linkis.app.version: ${linkis.app.version}
-  client:
-    serviceUrl:
-      defaultZone: http://127.0.0.1:20303/eureka/
-    registry-fetch-interval-seconds: 8
+nacos:
+  discovery:
+    server-addr: 127.0.0.1:8848
+  metadata:
+    prometheus.path: ${prometheus.path:/api/rest_j/v1/actuator/prometheus}
+    linkis.app.version: ${linkis.app.version}
+
 management:
   endpoints:
     web:
@@ -50,8 +44,16 @@ spring:
 #ribbon:
 #  ReadTimeout: 10000
 #  ConnectTimeout: 10000
+  cloud:
+    nacos:
+      discovery:
+        server-addr: 127.0.0.1:8848
+        metadata:
+          prometheus.path: 
${prometheus.path:/api/rest_j/v1/actuator/prometheus}
+          linkis.app.version: ${linkis.app.version}
+
 
 ##disable  kinif4j.production when you want to use apidoc during development
 knife4j:
   enable: true
-  production: true
\ No newline at end of file
+  production: true
diff --git a/linkis-dist/package/sbin/common.sh 
b/linkis-dist/package/sbin/common.sh
index 6a9acb207..f3f055593 100644
--- a/linkis-dist/package/sbin/common.sh
+++ b/linkis-dist/package/sbin/common.sh
@@ -27,6 +27,8 @@ NC='\033[0m' # No Color
 GREEN='\033[0;32m'
 #used as: echo -e "Apache ${RED}Linkis ${NC} Test \n"
 
+export DISCOVERY=EUREKA
+
 function isLocal(){
     if [ "$1" == "127.0.0.1" ];then
         return 0
diff --git a/linkis-dist/package/sbin/linkis-start-all.sh 
b/linkis-dist/package/sbin/linkis-start-all.sh
index c9bd38061..55c1ba684 100644
--- a/linkis-dist/package/sbin/linkis-start-all.sh
+++ b/linkis-dist/package/sbin/linkis-start-all.sh
@@ -131,9 +131,11 @@ sleep 3
 }
 
 #linkis-mg-eureka
-export SERVER_NAME="mg-eureka"
-SERVER_IP=$EUREKA_INSTALL_IP
-checkServer
+if [ "$DISCOVERY" == "EUREKA" ]; then
+  export SERVER_NAME="mg-eureka"
+  SERVER_IP=$EUREKA_INSTALL_IP
+  checkServer
+fi
 
 
 #linkis-mg-gateway
diff --git a/linkis-dist/package/sbin/linkis-stop-all.sh 
b/linkis-dist/package/sbin/linkis-stop-all.sh
index a560075a9..4302cf7af 100644
--- a/linkis-dist/package/sbin/linkis-stop-all.sh
+++ b/linkis-dist/package/sbin/linkis-stop-all.sh
@@ -103,8 +103,10 @@ SERVER_IP=$MANAGER_INSTALL_IP
 stopApp
 
 #linkis-mg-eureka
-export SERVER_NAME="mg-eureka"
-SERVER_IP=$EUREKA_INSTALL_IP
-stopApp
+if [ "$DISCOVERY" == "EUREKA" ]; then
+  export SERVER_NAME="mg-eureka"
+  SERVER_IP=$EUREKA_INSTALL_IP
+  stopApp
+fi
 
 echo "stop-all shell script executed completely"
diff --git a/pom.xml b/pom.xml
index eec3219c1..327a455a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -217,6 +217,7 @@
     <spring.boot.version>2.3.12.RELEASE</spring.boot.version>
     <spring-netflix.version>2.2.9.RELEASE</spring-netflix.version>
     <spring-cloud.version>Hoxton.SR12</spring-cloud.version>
+    <spring.cloud.nacos.version>2.2.9.RELEASE</spring.cloud.nacos.version>
 
     <!-- platform encoding override -->
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -1355,6 +1356,11 @@
           </exclusion>
         </exclusions>
       </dependency>
+      <dependency>
+        <groupId>com.alibaba.cloud</groupId>
+        <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
+        <version>${spring.cloud.nacos.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to