This is an automated email from the ASF dual-hosted git repository.
xingfudeshi pushed a commit to branch gsoc-2025-meta-registry
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/gsoc-2025-meta-registry by
this push:
new 55d38398b6 optimize: metadata discovery support for consul (#7745)
55d38398b6 is described below
commit 55d38398b6d845a062cd7c6ca2c9ab4a68113d68
Author: YoWuwuuuw <[email protected]>
AuthorDate: Wed Dec 10 14:24:51 2025 +0800
optimize: metadata discovery support for consul (#7745)
---
.../seata/common/metadata/ServiceInstance.java | 21 ++++
.../registry/consul/ConsulRegistryServiceImpl.java | 30 ++++--
.../consul/ConsulRegistryServiceImplTest.java | 109 +++++++++++++++++++++
.../consul/MockConsulRegistryProvider.java | 29 ++++++
.../consul/MockConsulRegistryServiceImpl.java} | 86 ++++++++++------
...ache.seata.discovery.registry.RegistryProvider} | 19 +---
.../src/test/resources/registry.conf | 9 +-
.../discovery/registry/RegistryHeartBeats.java | 15 ++-
8 files changed, 248 insertions(+), 70 deletions(-)
diff --git
a/common/src/main/java/org/apache/seata/common/metadata/ServiceInstance.java
b/common/src/main/java/org/apache/seata/common/metadata/ServiceInstance.java
index 67d8cc7341..468ccfaf1c 100644
--- a/common/src/main/java/org/apache/seata/common/metadata/ServiceInstance.java
+++ b/common/src/main/java/org/apache/seata/common/metadata/ServiceInstance.java
@@ -67,6 +67,7 @@ public class ServiceInstance {
/**
* Converts a list of InetSocketAddress to a list of ServiceInstance.
+ *
* @param addresses list of InetSocketAddress
* @return list of ServiceInstance
*/
@@ -83,6 +84,7 @@ public class ServiceInstance {
/**
* Converts a set of InetSocketAddress to a set of ServiceInstance in
RedisRegistryServiceImpl.
+ *
* @param addresses set of InetSocketAddress
* @return set of ServiceInstance
*/
@@ -116,6 +118,7 @@ public class ServiceInstance {
/**
* Creates a ServiceInstance from an InetSocketAddress and a Map<String,
String> of metadata.
+ *
* @param address the InetSocketAddress
* @param stringMap the map of string metadata
* @return a new ServiceInstance
@@ -128,6 +131,24 @@ public class ServiceInstance {
return new ServiceInstance(address, metadata);
}
+ /**
+ * Convert metadata to Map<String, String>. Non-String values will use
toString().
+ *
+ * @return Map<String, String>
+ */
+ public static Map<String, String> getStringMap(Map<String, Object>
metadata) {
+ Map<String, String> stringMap = new HashMap<>();
+ if (metadata != null) {
+ for (Map.Entry<String, Object> entry : metadata.entrySet()) {
+ stringMap.put(
+ entry.getKey(),
+ entry.getValue() == null ? null :
entry.getValue().toString());
+ }
+ }
+
+ return stringMap;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
diff --git
a/discovery/seata-discovery-consul/src/main/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImpl.java
b/discovery/seata-discovery-consul/src/main/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImpl.java
index afc3e780b9..f57d5e38f7 100644
---
a/discovery/seata-discovery-consul/src/main/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImpl.java
+++
b/discovery/seata-discovery-consul/src/main/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImpl.java
@@ -37,8 +37,10 @@ import org.slf4j.LoggerFactory;
import java.net.InetSocketAddress;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -128,12 +130,12 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
InetSocketAddress address = instance.getAddress();
NetUtil.validAddress(address);
- doRegister(address);
- RegistryHeartBeats.addHeartBeat(REGISTRY_TYPE, address,
this::doRegister);
+ doRegister(instance);
+ RegistryHeartBeats.addHeartBeat(REGISTRY_TYPE, instance,
this::doRegister);
}
- private void doRegister(InetSocketAddress address) {
- getConsulClient().agentServiceRegister(createService(address),
getAclToken());
+ private void doRegister(ServiceInstance instance) {
+ getConsulClient().agentServiceRegister(createService(instance),
getAclToken());
}
@Override
@@ -244,10 +246,12 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
/**
* create a new service
*
- * @param address
+ * @param instance
* @return newService
*/
- private NewService createService(InetSocketAddress address) {
+ private NewService createService(ServiceInstance instance) {
+ InetSocketAddress address = instance.getAddress();
+
NewService newService = new NewService();
newService.setId(createServiceId(address));
newService.setName(getClusterName());
@@ -255,6 +259,7 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
newService.setPort(address.getPort());
newService.setAddress(NetUtil.toIpAddress(address));
newService.setCheck(createCheck(address));
+
newService.setMeta(ServiceInstance.getStringMap(instance.getMetadata()));
return newService;
}
@@ -318,10 +323,17 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
return;
}
- List<ServiceInstance> instances =
ServiceInstance.convertToServiceInstanceList(services.stream()
+ List<ServiceInstance> instances = services.stream()
.map(HealthService::getService)
- .map(service -> new InetSocketAddress(service.getAddress(),
service.getPort()))
- .collect(Collectors.toList()));
+ .map(service -> {
+ InetSocketAddress address = new
InetSocketAddress(service.getAddress(), service.getPort());
+ Map<String, Object> metadata = new HashMap<>();
+ if (service.getMeta() != null) {
+ metadata.putAll(service.getMeta());
+ }
+ return new ServiceInstance(address, metadata);
+ })
+ .collect(Collectors.toList());
clusterAddressMap.put(cluster, instances);
diff --git
a/discovery/seata-discovery-consul/src/test/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImplTest.java
b/discovery/seata-discovery-consul/src/test/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImplTest.java
new file mode 100644
index 0000000000..9490aa598e
--- /dev/null
+++
b/discovery/seata-discovery-consul/src/test/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImplTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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.seata.discovery.registry.consul;
+
+import org.apache.seata.common.metadata.ServiceInstance;
+import org.apache.seata.discovery.registry.RegistryProvider;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * ConsulRegistryServiceImpl test
+ * Need to configure the address of consul into the registry.conf file for test
+ */
+@Disabled
+public class ConsulRegistryServiceImplTest {
+
+ private static MockConsulRegistryServiceImpl registryService;
+
+ @BeforeAll
+ public static void setUp() throws Exception {
+ ServiceLoader<RegistryProvider> providers =
ServiceLoader.load(RegistryProvider.class);
+ RegistryProvider provider = providers.iterator().next();
+ registryService = (MockConsulRegistryServiceImpl) provider.provide();
+ }
+
+ @AfterAll
+ public static void tearDown() throws Exception {
+ if (registryService != null) {
+ registryService.close();
+ }
+ }
+
+ @Test
+ public void testMetadataRegistrationAndDiscovery() throws Exception {
+ Map<String, Object> metadata1 = new HashMap<>();
+ metadata1.put("version", "1.0.0");
+ metadata1.put("environment", "test");
+ metadata1.put("weight", 100);
+
+ ServiceInstance instance1 = new ServiceInstance(new
InetSocketAddress("127.0.0.1", 8080), metadata1);
+ registryService.register(instance1);
+
+ Map<String, Object> metadata2 = new HashMap<>();
+ metadata2.put("version", "2.0.0");
+ metadata2.put("zone", "bj");
+
+ ServiceInstance instance2 = new ServiceInstance(new
InetSocketAddress("127.0.0.1", 9090), metadata2);
+ registryService.register(instance2);
+
+ Thread.sleep(3000);
+
+ List<ServiceInstance> instances =
registryService.lookup("default_tx_group");
+
+ assertNotNull(instances);
+ assertFalse(instances.isEmpty());
+
+ ServiceInstance foundInstance1 = instances.stream()
+ .filter(inst ->
inst.getAddress().equals(instance1.getAddress()))
+ .findFirst()
+ .orElse(null);
+
+ assertNotNull(foundInstance1);
+ Map<String, Object> foundMetadata1 = foundInstance1.getMetadata();
+ assertNotNull(foundMetadata1);
+ assertEquals("1.0.0", foundMetadata1.get("version"));
+ assertEquals("test", foundMetadata1.get("environment"));
+ assertEquals("100", foundMetadata1.get("weight"));
+
+ ServiceInstance foundInstance2 = instances.stream()
+ .filter(inst ->
inst.getAddress().equals(instance2.getAddress()))
+ .findFirst()
+ .orElse(null);
+
+ assertNotNull(foundInstance2);
+ Map<String, Object> foundMetadata2 = foundInstance2.getMetadata();
+ assertNotNull(foundMetadata2);
+ assertEquals("2.0.0", foundMetadata2.get("version"));
+ assertEquals("bj", foundMetadata2.get("zone"));
+
+ registryService.unregister(instance1);
+ registryService.unregister(instance2);
+ }
+}
diff --git
a/discovery/seata-discovery-consul/src/test/java/org/apache/seata/discovery/registry/consul/MockConsulRegistryProvider.java
b/discovery/seata-discovery-consul/src/test/java/org/apache/seata/discovery/registry/consul/MockConsulRegistryProvider.java
new file mode 100644
index 0000000000..43a1de5aee
--- /dev/null
+++
b/discovery/seata-discovery-consul/src/test/java/org/apache/seata/discovery/registry/consul/MockConsulRegistryProvider.java
@@ -0,0 +1,29 @@
+/*
+ * 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.seata.discovery.registry.consul;
+
+import org.apache.seata.common.loader.LoadLevel;
+import org.apache.seata.discovery.registry.RegistryProvider;
+import org.apache.seata.discovery.registry.RegistryService;
+
+@LoadLevel(name = "Consul", order = 1)
+public class MockConsulRegistryProvider implements RegistryProvider {
+ @Override
+ public RegistryService provide() {
+ return MockConsulRegistryServiceImpl.getInstance();
+ }
+}
diff --git
a/discovery/seata-discovery-consul/src/main/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImpl.java
b/discovery/seata-discovery-consul/src/test/java/org/apache/seata/discovery/registry/consul/MockConsulRegistryServiceImpl.java
similarity index 81%
copy from
discovery/seata-discovery-consul/src/main/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImpl.java
copy to
discovery/seata-discovery-consul/src/test/java/org/apache/seata/discovery/registry/consul/MockConsulRegistryServiceImpl.java
index afc3e780b9..d539b97548 100644
---
a/discovery/seata-discovery-consul/src/main/java/org/apache/seata/discovery/registry/consul/ConsulRegistryServiceImpl.java
+++
b/discovery/seata-discovery-consul/src/test/java/org/apache/seata/discovery/registry/consul/MockConsulRegistryServiceImpl.java
@@ -37,8 +37,10 @@ import org.slf4j.LoggerFactory;
import java.net.InetSocketAddress;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -48,12 +50,16 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
-public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener> {
+/**
+ * Mock implementation of ConsulRegistryServiceImpl for testing purposes.
+ * Uses TTL checks instead of TCP checks to avoid connection issues in test
environment.
+ */
+public class MockConsulRegistryServiceImpl implements
RegistryService<ConsulListener> {
- private static volatile ConsulRegistryServiceImpl instance;
+ private static volatile MockConsulRegistryServiceImpl instance;
private static volatile ConsulClient client;
- private static final Logger LOGGER =
LoggerFactory.getLogger(ConsulRegistryServiceImpl.class);
+ private static final Logger LOGGER =
LoggerFactory.getLogger(MockConsulRegistryServiceImpl.class);
private static final Configuration FILE_CONFIG =
ConfigurationFactory.CURRENT_FILE_INSTANCE;
private static final String FILE_ROOT_REGISTRY = "registry";
private static final String FILE_CONFIG_SPLIT_CHAR = ".";
@@ -76,14 +82,6 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
private String transactionServiceGroup;
- /**
- * default tcp check interval
- */
- private static final String DEFAULT_CHECK_INTERVAL = "10s";
- /**
- * default tcp check timeout
- */
- private static final String DEFAULT_CHECK_TIMEOUT = "1s";
/**
* default deregister critical server after
*/
@@ -93,7 +91,7 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
*/
private static final int DEFAULT_WATCH_TIMEOUT = 60;
- private ConsulRegistryServiceImpl() {
+ private MockConsulRegistryServiceImpl() {
// initial the capacity with 8
clusterAddressMap = new ConcurrentHashMap<>(MAP_INITIAL_CAPACITY);
listenerMap = new ConcurrentHashMap<>(MAP_INITIAL_CAPACITY);
@@ -108,15 +106,15 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
}
/**
- * get instance of ConsulRegistryServiceImpl
+ * get instance of MockConsulRegistryServiceImpl
*
* @return instance
*/
- static ConsulRegistryServiceImpl getInstance() {
+ static MockConsulRegistryServiceImpl getInstance() {
if (instance == null) {
- synchronized (ConsulRegistryServiceImpl.class) {
+ synchronized (MockConsulRegistryServiceImpl.class) {
if (instance == null) {
- instance = new ConsulRegistryServiceImpl();
+ instance = new MockConsulRegistryServiceImpl();
}
}
}
@@ -126,20 +124,34 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
@Override
public void register(ServiceInstance instance) throws Exception {
InetSocketAddress address = instance.getAddress();
- NetUtil.validAddress(address);
+ // Skip address validation for testing
+ // NetUtil.validAddress(address);
+
+ doRegister(instance);
+ // Immediately send TTL check to make service healthy
+ doTtlCheck(instance);
+ // Add heartbeat for re-registration and TTL check
+ RegistryHeartBeats.addHeartBeat(REGISTRY_TYPE, instance,
this::doRegister);
+ // Add TTL check to keep service healthy
+ RegistryHeartBeats.addHeartBeat(REGISTRY_TYPE, instance, 15000,
this::doTtlCheck);
+ }
- doRegister(address);
- RegistryHeartBeats.addHeartBeat(REGISTRY_TYPE, address,
this::doRegister);
+ private void doRegister(ServiceInstance instance) {
+ NewService service = createService(instance);
+ getConsulClient().agentServiceRegister(service, getAclToken());
}
- private void doRegister(InetSocketAddress address) {
- getConsulClient().agentServiceRegister(createService(address),
getAclToken());
+ private void doTtlCheck(ServiceInstance instance) throws Exception {
+ // Send TTL check to keep service healthy
+ String checkId = "service:" + createServiceId(instance.getAddress());
+ getConsulClient().agentCheckPass(checkId, getAclToken());
}
@Override
public void unregister(ServiceInstance instance) {
InetSocketAddress address = instance.getAddress();
- NetUtil.validAddress(address);
+ // Skip address validation for testing
+ // NetUtil.validAddress(address);
getConsulClient().agentServiceDeregister(createServiceId(address),
getAclToken());
}
@@ -192,7 +204,7 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
*/
private ConsulClient getConsulClient() {
if (client == null) {
- synchronized (ConsulRegistryServiceImpl.class) {
+ synchronized (MockConsulRegistryServiceImpl.class) {
if (client == null) {
String serverAddr =
FILE_CONFIG.getConfig(FILE_CONFIG_KEY_PREFIX + SERVER_ADDR_KEY);
InetSocketAddress inetSocketAddress =
NetUtil.toInetSocketAddress(serverAddr);
@@ -244,10 +256,12 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
/**
* create a new service
*
- * @param address
+ * @param instance
* @return newService
*/
- private NewService createService(InetSocketAddress address) {
+ private NewService createService(ServiceInstance instance) {
+ InetSocketAddress address = instance.getAddress();
+
NewService newService = new NewService();
newService.setId(createServiceId(address));
newService.setName(getClusterName());
@@ -255,20 +269,21 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
newService.setPort(address.getPort());
newService.setAddress(NetUtil.toIpAddress(address));
newService.setCheck(createCheck(address));
+
newService.setMeta(ServiceInstance.getStringMap(instance.getMetadata()));
return newService;
}
/**
- * create service check based on TCP
+ * create service check based on TTL (for testing purposes)
+ * This allows the service to be considered healthy without actually
running on the port
*
* @param address
* @return
*/
private NewService.Check createCheck(InetSocketAddress address) {
NewService.Check check = new NewService.Check();
- check.setTcp(NetUtil.toStringAddress(address));
- check.setInterval(DEFAULT_CHECK_INTERVAL);
- check.setTimeout(DEFAULT_CHECK_TIMEOUT);
+ // Use TTL check instead of TCP check for testing
+ check.setTtl("30s");
check.setDeregisterCriticalServiceAfter(DEFAULT_DEREGISTER_TIME);
return check;
}
@@ -318,10 +333,17 @@ public class ConsulRegistryServiceImpl implements
RegistryService<ConsulListener
return;
}
- List<ServiceInstance> instances =
ServiceInstance.convertToServiceInstanceList(services.stream()
+ List<ServiceInstance> instances = services.stream()
.map(HealthService::getService)
- .map(service -> new InetSocketAddress(service.getAddress(),
service.getPort()))
- .collect(Collectors.toList()));
+ .map(service -> {
+ InetSocketAddress address = new
InetSocketAddress(service.getAddress(), service.getPort());
+ Map<String, Object> metadata = new HashMap<>();
+ if (service.getMeta() != null) {
+ metadata.putAll(service.getMeta());
+ }
+ return new ServiceInstance(address, metadata);
+ })
+ .collect(Collectors.toList());
clusterAddressMap.put(cluster, instances);
diff --git a/discovery/seata-discovery-consul/src/test/resources/registry.conf
b/discovery/seata-discovery-consul/src/test/resources/META-INF/services/org.apache.seata.discovery.registry.RegistryProvider
similarity index 76%
copy from discovery/seata-discovery-consul/src/test/resources/registry.conf
copy to
discovery/seata-discovery-consul/src/test/resources/META-INF/services/org.apache.seata.discovery.registry.RegistryProvider
index 5ad014bf55..cce1e6e069 100644
--- a/discovery/seata-discovery-consul/src/test/resources/registry.conf
+++
b/discovery/seata-discovery-consul/src/test/resources/META-INF/services/org.apache.seata.discovery.registry.RegistryProvider
@@ -14,21 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "file"
-
- file {
- name = "file.conf"
- }
-}
-
-config {
- # file、nacos 、apollo、zk、consul、etcd3
- type = "file"
-
- file {
- name = "file.conf"
- }
-}
\ No newline at end of file
+org.apache.seata.discovery.registry.consul.MockConsulRegistryProvider
\ No newline at end of file
diff --git a/discovery/seata-discovery-consul/src/test/resources/registry.conf
b/discovery/seata-discovery-consul/src/test/resources/registry.conf
index 5ad014bf55..05a682d03a 100644
--- a/discovery/seata-discovery-consul/src/test/resources/registry.conf
+++ b/discovery/seata-discovery-consul/src/test/resources/registry.conf
@@ -17,10 +17,13 @@
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "file"
+ type = "consul"
- file {
- name = "file.conf"
+ consul {
+ cluster = "default"
+ serverAddr = "127.0.0.1:8500"
+ heartbeat-enabled = "true"
+ acl-token = ""
}
}
diff --git
a/discovery/seata-discovery-core/src/main/java/org/apache/seata/discovery/registry/RegistryHeartBeats.java
b/discovery/seata-discovery-core/src/main/java/org/apache/seata/discovery/registry/RegistryHeartBeats.java
index 7798b2d383..ce2eb5ff8d 100644
---
a/discovery/seata-discovery-core/src/main/java/org/apache/seata/discovery/registry/RegistryHeartBeats.java
+++
b/discovery/seata-discovery-core/src/main/java/org/apache/seata/discovery/registry/RegistryHeartBeats.java
@@ -16,12 +16,12 @@
*/
package org.apache.seata.discovery.registry;
+import org.apache.seata.common.metadata.ServiceInstance;
import org.apache.seata.config.Configuration;
import org.apache.seata.config.ConfigurationFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.net.InetSocketAddress;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
@@ -54,12 +54,11 @@ public class RegistryHeartBeats {
}
});
- public static void addHeartBeat(String registryType, InetSocketAddress
serverAddress, ReRegister reRegister) {
- addHeartBeat(registryType, serverAddress,
getHeartbeatPeriod(registryType), reRegister);
+ public static void addHeartBeat(String registryType, ServiceInstance
instance, ReRegister reRegister) {
+ addHeartBeat(registryType, instance, getHeartbeatPeriod(registryType),
reRegister);
}
- public static void addHeartBeat(
- String registryType, InetSocketAddress serverAddress, long period,
ReRegister reRegister) {
+ public static void addHeartBeat(String registryType, ServiceInstance
instance, long period, ReRegister reRegister) {
if (!getHeartbeatEnabled(registryType)) {
LOGGER.info("registry heartbeat disabled");
return;
@@ -70,7 +69,7 @@ public class RegistryHeartBeats {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("seata heartbeat re-registry.");
}
- reRegister.register(serverAddress);
+ reRegister.register(instance);
} catch (Exception e) {
LOGGER.error("seata registry heartbeat failed!", e);
}
@@ -108,9 +107,9 @@ public class RegistryHeartBeats {
/**
* do re-register
*
- * @param serverAddress the server address
+ * @param instance the ServiceInstance
* @throws Exception the exception
*/
- void register(InetSocketAddress serverAddress) throws Exception;
+ void register(ServiceInstance instance) throws Exception;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]