mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
update the Nacos instance by real group name, not use the default group name
This commit is contained in:
parent
573e8ed6c5
commit
b264579012
@ -40,7 +40,11 @@ import static org.springframework.util.ReflectionUtils.rethrowRuntimeException;
|
||||
* @author <a href="mailto:78552423@qq.com">eshun</a>
|
||||
*/
|
||||
public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
|
||||
|
||||
private static final String STATUS_UP = "UP";
|
||||
|
||||
private static final String STATUS_DOWN = "DOWN";
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(NacosServiceRegistry.class);
|
||||
|
||||
private final NacosDiscoveryProperties nacosDiscoveryProperties;
|
||||
@ -119,7 +123,7 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
@Override
|
||||
public void setStatus(Registration registration, String status) {
|
||||
|
||||
if (!"UP".equalsIgnoreCase(status) && !"DOWN".equalsIgnoreCase(status)) {
|
||||
if (!STATUS_UP.equalsIgnoreCase(status) && !STATUS_DOWN.equalsIgnoreCase(status)) {
|
||||
log.warn("can't support status {},please choose UP or DOWN", status);
|
||||
return;
|
||||
}
|
||||
@ -128,7 +132,7 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
|
||||
Instance instance = getNacosInstanceFromRegistration(registration);
|
||||
|
||||
if ("DOWN".equalsIgnoreCase(status)) {
|
||||
if (STATUS_DOWN.equalsIgnoreCase(status)) {
|
||||
instance.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
@ -138,7 +142,7 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
try {
|
||||
Properties nacosProperties = nacosDiscoveryProperties.getNacosProperties();
|
||||
nacosServiceManager.getNamingMaintainService(nacosProperties)
|
||||
.updateInstance(serviceId, instance);
|
||||
.updateInstance(serviceId, nacosDiscoveryProperties.getGroup(), instance);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("update nacos instance status fail", e);
|
||||
|
Loading…
x
Reference in New Issue
Block a user