From e6cb65b488edb578a346b4058d7a3581f8c387a9 Mon Sep 17 00:00:00 2001 From: ChengJie1053 <18033291053@163.com> Date: Thu, 14 Mar 2024 18:50:25 +0800 Subject: [PATCH] Code optimization --- .../org/apache/linkis/rpc/conf/CacheManualRefresher.java | 3 --- .../linkis/rpc/conf/EurekaClientCacheManualRefresher.java | 4 ++-- .../linkis/rpc/conf/NacosClientCacheManualRefresher.java | 8 ++++---- linkis-dist/package/conf/application-engineconn.yml | 5 +---- linkis-dist/package/conf/application-linkis.yml | 5 +---- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/CacheManualRefresher.java b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/CacheManualRefresher.java index 214d6fb854..dbdf52a1fc 100644 --- a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/CacheManualRefresher.java +++ b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/CacheManualRefresher.java @@ -17,9 +17,6 @@ package org.apache.linkis.rpc.conf; -import org.springframework.stereotype.Component; - -@Component public interface CacheManualRefresher { void refresh(); } diff --git a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/EurekaClientCacheManualRefresher.java b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/EurekaClientCacheManualRefresher.java index 870693a91c..7394698672 100644 --- a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/EurekaClientCacheManualRefresher.java +++ b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/EurekaClientCacheManualRefresher.java @@ -21,7 +21,7 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.stereotype.Component; import org.springframework.util.ReflectionUtils; @@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory; @Component -@ConditionalOnProperty(name = "discovery", havingValue = "eureka") +@ConditionalOnClass(name = "org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration") public class EurekaClientCacheManualRefresher implements CacheManualRefresher { private static final Logger logger = LoggerFactory.getLogger(EurekaClientCacheManualRefresher.class); diff --git a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/NacosClientCacheManualRefresher.java b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/NacosClientCacheManualRefresher.java index af5df373cf..db26cd0f2c 100644 --- a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/NacosClientCacheManualRefresher.java +++ b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/conf/NacosClientCacheManualRefresher.java @@ -17,22 +17,22 @@ package org.apache.linkis.rpc.conf; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.stereotype.Component; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Component -@ConditionalOnProperty(name = "discovery", havingValue = "nacos") +@ConditionalOnClass(name = "com.alibaba.cloud.nacos.registry.NacosServiceRegistryAutoConfiguration") public class NacosClientCacheManualRefresher implements CacheManualRefresher { private static final Logger logger = LoggerFactory.getLogger(NacosClientCacheManualRefresher.class); public void refresh() { try { - logger.warn("Failed to obtain nacos metadata. Wait 3 seconds"); - Thread.sleep(3000L); + logger.warn("Failed to obtain nacos metadata. Wait 100 milliseconds"); + Thread.sleep(100L); } catch (InterruptedException e) { } diff --git a/linkis-dist/package/conf/application-engineconn.yml b/linkis-dist/package/conf/application-engineconn.yml index ee8e5d150b..174ddd2305 100644 --- a/linkis-dist/package/conf/application-engineconn.yml +++ b/linkis-dist/package/conf/application-engineconn.yml @@ -52,7 +52,4 @@ management: include: refresh,info,health,metrics logging: - config: classpath:log4j2.xml - -#The default value is eureka, Optional value: eureka,nacos -discovery: eureka \ No newline at end of file + config: classpath:log4j2.xml \ No newline at end of file diff --git a/linkis-dist/package/conf/application-linkis.yml b/linkis-dist/package/conf/application-linkis.yml index fbf2fae3f1..82fb281211 100644 --- a/linkis-dist/package/conf/application-linkis.yml +++ b/linkis-dist/package/conf/application-linkis.yml @@ -63,7 +63,4 @@ spring: ##disable kinif4j.production when you want to use apidoc during development knife4j: enable: true - production: true - -#The default value is eureka, Optional value: eureka,nacos -discovery: eureka \ No newline at end of file + production: true \ No newline at end of file