Sync develop

This commit is contained in:
hongqiaowei
2022-05-06 16:03:52 +08:00
committed by GitHub
10 changed files with 41 additions and 18 deletions

View File

@@ -12,7 +12,7 @@
<groupId>com.fizzgate</groupId>
<artifactId>fizz-bootstrap</artifactId>
<version>2.6.2</version>
<version>2.6.3</version>
<properties>
<java.version>1.8</java.version>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId>
<version>2.6.2</version>
<version>2.6.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId>
<version>2.6.2</version>
<version>2.6.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -50,7 +50,7 @@ public abstract class FizzServiceRegistration {
UP, DOWN, STARTING, OUT_OF_SERVICE, UNKNOWN;
}
private String id;
protected String id;
private Type type;
@@ -91,12 +91,22 @@ public abstract class FizzServiceRegistration {
public void register() {
serviceRegistry.register(registration);
LOGGER.info("register to {} {}", type, id);
}
public void deregister() {
serviceRegistry.deregister(registration);
LOGGER.info("deregister to {} {}", type, id);
}
public void close() {
serviceRegistry.close();
shutdownClient();
LOGGER.info("close {} {}", type, id);
}
protected abstract void shutdownClient();
public abstract ServerStatus getServerStatus();
public abstract List<String> getServices();

View File

@@ -32,7 +32,6 @@ import we.util.JacksonUtils;
import we.util.Result;
import we.util.ThreadContext;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.HashMap;
@@ -45,7 +44,7 @@ import java.util.Map;
@Service
public class RegistryCenterService implements ApplicationListener<ContextRefreshedEvent> {
private static final Logger log = LoggerFactory.getLogger(RegistryCenterService.class);
private static final Logger LOGGER = LoggerFactory.getLogger(RegistryCenterService.class);
private Map<String, RegistryCenter> registryCenterMap = new HashMap<>();
@@ -81,7 +80,7 @@ public class RegistryCenterService implements ApplicationListener<ContextRefresh
json = (String) e.getValue();
RegistryCenter rc = JacksonUtils.readValue(json, RegistryCenter.class);
registryCenterMap.put(rc.name, rc);
log.info("init registry center {}", rc.name);
LOGGER.info("init registry center {}", rc);
rc.initFizzServiceRegistration(applicationContext);
rc.getFizzServiceRegistration().register();
}
@@ -91,7 +90,7 @@ public class RegistryCenterService implements ApplicationListener<ContextRefresh
result.t = t;
}
} else {
log.info("no registry center");
LOGGER.info("no registry center");
}
return Mono.empty();
}
@@ -118,12 +117,12 @@ public class RegistryCenterService implements ApplicationListener<ContextRefresh
result.code = Result.FAIL;
result.msg = "lsn error, channel: " + channel;
result.t = t;
log.error("lsn channel {} error", channel, t);
LOGGER.error("lsn channel {} error", channel, t);
}
)
.doOnSubscribe(
s -> {
log.info("success to lsn on {}", channel);
LOGGER.info("success to lsn on {}", channel);
}
)
.doOnNext(
@@ -134,19 +133,23 @@ public class RegistryCenterService implements ApplicationListener<ContextRefresh
RegistryCenter prev = null;
if (rc.isDeleted) {
prev = registryCenterMap.remove(rc.name);
log.info("remove registry center {}", rc.name);
prev.getFizzServiceRegistration().deregister();
LOGGER.info("remove registry center {}", prev);
FizzServiceRegistration fizzServiceRegistration = prev.getFizzServiceRegistration();
fizzServiceRegistration.deregister();
fizzServiceRegistration.close();
} else {
prev = registryCenterMap.put(rc.name, rc);
log.info("update registry center {}", rc.name);
LOGGER.info("update registry center {} with {}", prev, rc);
if (prev != null) {
prev.getFizzServiceRegistration().deregister();
FizzServiceRegistration fizzServiceRegistration = prev.getFizzServiceRegistration();
fizzServiceRegistration.deregister();
fizzServiceRegistration.close();
}
rc.initFizzServiceRegistration(applicationContext);
rc.getFizzServiceRegistration().register();
}
} catch (Throwable t) {
log.error("update registry center error, {}", message, t);
LOGGER.error("update registry center error, {}", message, t);
}
}
)

View File

@@ -55,6 +55,12 @@ public class FizzEurekaServiceRegistration extends FizzServiceRegistration {
return client;
}
@Override
protected void shutdownClient() {
client.shutdown();
LOGGER.info("shutdown {} client", id);
}
@Override
public ServerStatus getServerStatus() {
EurekaClientConfig eurekaClientConfig = client.getEurekaClientConfig();

View File

@@ -67,6 +67,10 @@ public class FizzNacosServiceRegistration extends FizzServiceRegistration {
return namingService;
}
@Override
protected void shutdownClient() {
}
@Override
public ServerStatus getServerStatus() {
String status = namingService.getServerStatus();

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId>
<version>2.6.2</version>
<version>2.6.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>fizz-gateway-community</artifactId>
<groupId>com.fizzgate</groupId>
<version>2.6.2</version>
<version>2.6.3</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -37,7 +37,7 @@
<artifactId>fizz-gateway-community</artifactId>
<name>${project.artifactId}</name>
<description>fizz gateway community</description>
<version>2.6.2</version>
<version>2.6.3</version>
<packaging>pom</packaging>
<modules>
<module>fizz-common</module>