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

jianbin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new dadaa6bdcf optimize: rename the server naming/v1 api to vgroup/v1 
(#6783)
dadaa6bdcf is described below

commit dadaa6bdcf994cb22370dee6e025ff0e2689ed80
Author: funkye <jian...@apache.org>
AuthorDate: Wed Aug 28 09:11:39 2024 +0800

    optimize: rename the server naming/v1 api to vgroup/v1 (#6783)
---
 changes/en-us/2.x.md                               |  1 +
 changes/zh-cn/2.x.md                               |  1 +
 .../apache/seata/common/NamingServerConstants.java |  4 ++--
 .../NamingserverRegistryServiceImpl.java           | 28 +++++-----------------
 script/client/spring/application.properties        |  1 +
 server/pom.xml                                     | 10 ++++----
 ...ontroller.java => VGroupMappingController.java} |  9 +++----
 server/src/main/resources/application.yml          |  2 +-
 ...rTest.java => VGroupMappingControllerTest.java} |  8 +++----
 server/src/test/resources/application.properties   |  5 +++-
 10 files changed, 30 insertions(+), 39 deletions(-)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 4829e0974c..b55f7dc775 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -68,6 +68,7 @@ Add changes here for all PR submitted to the 2.x branch.
 - [[#6780](https://github.com/apache/incubator-seata/pull/6780)] optimize the 
reflection operation in class `SerializerServiceLoader`
 - [[#6784](https://github.com/apache/incubator-seata/pull/6784)] upgrade axios 
to 1.7.4
 - [[#6787](https://github.com/apache/incubator-seata/pull/6787)] upgrade 
elliptic to 6.5.7
+- [[#6783](https://github.com/apache/incubator-seata/pull/6783)] rename the 
server naming/v1 api to vgroup/v1
 
 ### refactor:
 
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 9f53d34f53..5850e95000 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -69,6 +69,7 @@
 - [[#6780](https://github.com/apache/incubator-seata/pull/6780)] 优化类 
`SerializerServiceLoader` 中的反射操作
 - [[#6784](https://github.com/apache/incubator-seata/pull/6784)] 升级 axios 至 
1.7.4 版本
 - [[#6787](https://github.com/apache/incubator-seata/pull/6787)] 升级 elliptic 至 
6.5.7 版本
+- [[#6783](https://github.com/apache/incubator-seata/pull/6783)] 
将server事务分组修改接口改为/vgroup/v1
 
 
 ### refactor:
diff --git 
a/common/src/main/java/org/apache/seata/common/NamingServerConstants.java 
b/common/src/main/java/org/apache/seata/common/NamingServerConstants.java
index 975a42d3ee..11ba530cfd 100644
--- a/common/src/main/java/org/apache/seata/common/NamingServerConstants.java
+++ b/common/src/main/java/org/apache/seata/common/NamingServerConstants.java
@@ -25,7 +25,7 @@ public interface NamingServerConstants {
     /**
      * The constant HTTP_ADD_GROUP_SUFFIX
      */
-    String HTTP_ADD_GROUP_SUFFIX = "/naming/v1/addVGroup?";
+    String HTTP_ADD_GROUP_SUFFIX = "/vgroup/v1/addVGroup?";
 
     /**
      * The constant CONSTANT_UNIT
@@ -40,7 +40,7 @@ public interface NamingServerConstants {
     /**
      * The constant HTTP_REMOVE_GROUP_SUFFIX
      */
-    String HTTP_REMOVE_GROUP_SUFFIX = "/naming/v1/removeVGroup?";
+    String HTTP_REMOVE_GROUP_SUFFIX = "/vgroup/v1/removeVGroup?";
 
     /**
      * The constant IP_PORT_SPLIT_CHAR
diff --git 
a/discovery/seata-discovery-namingserver/src/main/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImpl.java
 
b/discovery/seata-discovery-namingserver/src/main/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImpl.java
index ab78d48bbc..2781f4687b 100644
--- 
a/discovery/seata-discovery-namingserver/src/main/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImpl.java
+++ 
b/discovery/seata-discovery-namingserver/src/main/java/org/apache/seata/discovery/registry/namingserver/NamingserverRegistryServiceImpl.java
@@ -29,7 +29,6 @@ import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ThreadLocalRandom;
@@ -78,34 +77,31 @@ public class NamingserverRegistryServiceImpl implements 
RegistryService<NamingLi
     private static final String TIME_OUT_KEY = "timeout";
 
     private static final String HEART_BEAT_KEY = "heartbeat-period";
-    private static int HEARTBEAT_PERIOD = 30 * 1000;
-    private static final int HEALTHCHECK_PERIOD = 3 * 1000;
+    private static int healthcheckPeriod = 5 * 1000;
     private static final int PULL_PERIOD = 30 * 1000;
     private static final int LONG_POLL_TIME_OUT_PERIOD = 28 * 1000;
     private static final int THREAD_POOL_NUM = 1;
     private static final int HEALTH_CHECK_THRESHOLD = 1; // namingserver is 
considered unhealthy if failing in healthy check more than 1 times
     private volatile long term = 0;
     private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-    private ScheduledFuture<?> heartBeatScheduledFuture;
     private volatile boolean isSubscribed = false;
     private static final Configuration FILE_CONFIG = 
ConfigurationFactory.CURRENT_FILE_INSTANCE;
     private String namingServerAddressCache;
     private static ConcurrentMap<String /* namingserver address */, 
AtomicInteger /* Number of Health Check Continues Failures */> 
AVAILABLE_NAMINGSERVER_MAP = new ConcurrentHashMap<>();
     private static final ConcurrentMap<String/* vgroup */, 
List<InetSocketAddress>> VGROUP_ADDRESS_MAP = new ConcurrentHashMap<>();
     private static final ConcurrentMap<String/* vgroup */, 
List<NamingListener>> LISTENER_SERVICE_MAP = new ConcurrentHashMap<>();
-    protected final ScheduledExecutorService executorService = new 
ScheduledThreadPoolExecutor(1, new NamedThreadFactory("scheduledExcuter", 
THREAD_POOL_NUM, true));
+    protected final ScheduledExecutorService executorService = new 
ScheduledThreadPoolExecutor(1, new 
NamedThreadFactory("seata-namingser-scheduled", THREAD_POOL_NUM, true));
     private final ExecutorService notifierExecutor = new 
ThreadPoolExecutor(THREAD_POOL_NUM, THREAD_POOL_NUM, Integer.MAX_VALUE, 
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), new 
NamedThreadFactory("serviceNamingNotifier", THREAD_POOL_NUM));
 
 
     private NamingserverRegistryServiceImpl() {
         
OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
         String heartBeatKey = String.join(FILE_CONFIG_SPLIT_CHAR, 
FILE_ROOT_REGISTRY, REGISTRY_TYPE, HEART_BEAT_KEY);
-        HEARTBEAT_PERIOD = FILE_CONFIG.getInt(heartBeatKey, HEARTBEAT_PERIOD);
+        healthcheckPeriod = FILE_CONFIG.getInt(heartBeatKey, 
healthcheckPeriod);
         List<String> urlList = getNamingAddrs();
         checkAvailableNamingAddr(urlList);
-        this.executorService.scheduleAtFixedRate(() -> {
-            checkAvailableNamingAddr(urlList);
-        }, HEARTBEAT_PERIOD, HEALTHCHECK_PERIOD, TimeUnit.MILLISECONDS);
+        this.executorService.scheduleAtFixedRate(() -> 
checkAvailableNamingAddr(urlList), healthcheckPeriod,
+                healthcheckPeriod, TimeUnit.MILLISECONDS);
     }
 
     private void checkAvailableNamingAddr(List<String> urlList) {
@@ -154,14 +150,8 @@ public class NamingserverRegistryServiceImpl implements 
RegistryService<NamingLi
         NetUtil.validAddress(address);
         Instance instance = Instance.getInstance();
         instance.setTransaction(new 
Node.Endpoint(address.getAddress().getHostAddress(), address.getPort(), 
"netty"));
-
         instance.setTimestamp(System.currentTimeMillis());
         doRegister(instance, getNamingAddrs());
-
-        if (heartBeatScheduledFuture != null && 
!heartBeatScheduledFuture.isCancelled()) {
-            heartBeatScheduledFuture.cancel(false);
-        }
-
     }
 
     public void doRegister(Instance instance, List<String> urlList) {
@@ -209,11 +199,6 @@ public class NamingserverRegistryServiceImpl implements 
RegistryService<NamingLi
 
     @Override
     public void unregister(InetSocketAddress address) {
-        // stop heartbeat
-
-        if (heartBeatScheduledFuture != null && 
!heartBeatScheduledFuture.isCancelled()) {
-            heartBeatScheduledFuture.cancel(true);
-        }
         NetUtil.validAddress(address);
         Instance instance = Instance.getInstance();
         instance.setTransaction(new 
Node.Endpoint(address.getAddress().getHostAddress(), address.getPort(), 
"netty"));
@@ -400,9 +385,8 @@ public class NamingserverRegistryServiceImpl implements 
RegistryService<NamingLi
                 term = metaResponse.getTerm();
             }
             VGROUP_ADDRESS_MAP.put(vGroup, newAddressList);
-            removeOfflineAddressesIfNecessary(vGroup, newAddressList);
         } catch (IOException e) {
-            e.printStackTrace();
+            LOGGER.error(e.getMessage());
             throw new RemoteException();
         }
 
diff --git a/script/client/spring/application.properties 
b/script/client/spring/application.properties
index 1715c37362..e4c004afc0 100755
--- a/script/client/spring/application.properties
+++ b/script/client/spring/application.properties
@@ -133,6 +133,7 @@ seata.registry.etcd3.server-addr=http://localhost:2379
 
 seata.registry.eureka.weight=1
 seata.registry.eureka.service-url=http://localhost:8761/eureka
+
 seata.registry.namingserver.server-addr=127.0.0.1:8081
 seata.registry.namingserver.namespace=public
 seata.registry.namingserver.heartbeat-period=5000
diff --git a/server/pom.xml b/server/pom.xml
index a9b6f05bd8..902095f26b 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -194,11 +194,11 @@
             <artifactId>mysql-connector-java</artifactId>
             <scope>test</scope>
         </dependency>
-<!--        <dependency>-->
-<!--            <groupId>org.mariadb.jdbc</groupId>-->
-<!--            <artifactId>mariadb-java-client</artifactId>-->
-<!--            <scope>provided</scope>-->
-<!--        </dependency>-->
+<!--        <dependency>
+            <groupId>org.mariadb.jdbc</groupId>
+            <artifactId>mariadb-java-client</artifactId>
+            <scope>provided</scope>
+        </dependency>-->
         <dependency>
             <groupId>org.postgresql</groupId>
             <artifactId>postgresql</artifactId>
diff --git 
a/server/src/main/java/org/apache/seata/server/controller/NamingController.java 
b/server/src/main/java/org/apache/seata/server/controller/VGroupMappingController.java
similarity index 93%
rename from 
server/src/main/java/org/apache/seata/server/controller/NamingController.java
rename to 
server/src/main/java/org/apache/seata/server/controller/VGroupMappingController.java
index cd7a63074b..ae80858ff1 100644
--- 
a/server/src/main/java/org/apache/seata/server/controller/NamingController.java
+++ 
b/server/src/main/java/org/apache/seata/server/controller/VGroupMappingController.java
@@ -37,8 +37,8 @@ import static 
org.apache.seata.common.ConfigurationKeys.FILE_ROOT_TYPE;
 import static org.apache.seata.common.ConfigurationKeys.NAMING_SERVER;
 
 @RestController
-@RequestMapping("/naming/v1")
-public class NamingController {
+@RequestMapping("/vgroup/v1")
+public class VGroupMappingController {
 
     private VGroupMappingStoreManager vGroupMappingStoreManager;
 
@@ -46,8 +46,9 @@ public class NamingController {
 
     @PostConstruct
     private void init() {
-        if 
(StringUtils.equals(ConfigurationFactory.getInstance().getConfig(FILE_ROOT_REGISTRY
-                + FILE_CONFIG_SPLIT_CHAR + FILE_ROOT_TYPE), NAMING_SERVER)) {
+        String type =
+            ConfigurationFactory.getInstance().getConfig(FILE_ROOT_REGISTRY + 
FILE_CONFIG_SPLIT_CHAR + FILE_ROOT_TYPE);
+        if (StringUtils.equals(type, NAMING_SERVER)) {
             vGroupMappingStoreManager = 
SessionHolder.getRootVGroupMappingManager();
         }
     }
diff --git a/server/src/main/resources/application.yml 
b/server/src/main/resources/application.yml
index c70a2f842f..c1cf43c79e 100644
--- a/server/src/main/resources/application.yml
+++ b/server/src/main/resources/application.yml
@@ -53,4 +53,4 @@ seata:
     secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
     tokenValidityInMilliseconds: 1800000
     ignore:
-      urls: 
/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/version.json,/health,/error
\ No newline at end of file
+      urls: 
/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/version.json,/health,/error,/vgroup/v1/**
\ No newline at end of file
diff --git 
a/server/src/test/java/org/apache/seata/server/controller/NamingControllerTest.java
 
b/server/src/test/java/org/apache/seata/server/controller/VGroupMappingControllerTest.java
similarity index 84%
rename from 
server/src/test/java/org/apache/seata/server/controller/NamingControllerTest.java
rename to 
server/src/test/java/org/apache/seata/server/controller/VGroupMappingControllerTest.java
index 8ea8997aae..b085e529c3 100644
--- 
a/server/src/test/java/org/apache/seata/server/controller/NamingControllerTest.java
+++ 
b/server/src/test/java/org/apache/seata/server/controller/VGroupMappingControllerTest.java
@@ -24,17 +24,17 @@ import org.springframework.boot.test.context.SpringBootTest;
 
 @Disabled
 @SpringBootTest
-class NamingControllerTest {
+class VGroupMappingControllerTest {
     @Autowired
-    private NamingController namingController;
+    private VGroupMappingController vGroupMappingController;
 
     @Test
     void addVGroup() {
-        namingController.addVGroup("group1","unit1");
+        vGroupMappingController.addVGroup("group1","unit1");
     }
 
     @Test
     void removeVGroup() {
-        namingController.removeVGroup("group1");
+        vGroupMappingController.removeVGroup("group1");
     }
 }
\ No newline at end of file
diff --git a/server/src/test/resources/application.properties 
b/server/src/test/resources/application.properties
index 7e94fbef63..5d100e7e8c 100644
--- a/server/src/test/resources/application.properties
+++ b/server/src/test/resources/application.properties
@@ -21,4 +21,7 @@ seata.metrics.enabled=true
 seata.metrics.exporter-list=prometheus
 seata.metrics.exporter-prometheus-port=9898
 seata.metrics.registry-type=compact
-seata.server.service-port=8091
\ No newline at end of file
+seata.server.service-port=8091
+seata.registry.namingserver.server-addr=127.0.0.1:8081
+seata.registry.namingserver.namespace=public
+seata.registry.namingserver.heartbeat-period=5000
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to