mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
format code
This commit is contained in:
parent
95060a19b1
commit
d7665170ec
@ -28,7 +28,7 @@ import org.springframework.cloud.alibaba.nacos.discovery.NacosDiscoveryClientAut
|
|||||||
import org.springframework.cloud.alibaba.nacos.registry.NacosAutoServiceRegistration;
|
import org.springframework.cloud.alibaba.nacos.registry.NacosAutoServiceRegistration;
|
||||||
import org.springframework.cloud.alibaba.nacos.registry.NacosRegistration;
|
import org.springframework.cloud.alibaba.nacos.registry.NacosRegistration;
|
||||||
import org.springframework.cloud.alibaba.nacos.registry.NacosServiceRegistry;
|
import org.springframework.cloud.alibaba.nacos.registry.NacosServiceRegistry;
|
||||||
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration;
|
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationConfiguration;
|
||||||
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties;
|
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -43,7 +43,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@ConditionalOnNacosDiscoveryEnabled
|
@ConditionalOnNacosDiscoveryEnabled
|
||||||
@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true)
|
||||||
@AutoConfigureBefore(NacosDiscoveryClientAutoConfiguration.class)
|
@AutoConfigureBefore(NacosDiscoveryClientAutoConfiguration.class)
|
||||||
@AutoConfigureAfter(AutoServiceRegistrationAutoConfiguration.class)
|
@AutoConfigureAfter(AutoServiceRegistrationConfiguration.class)
|
||||||
public class NacosDiscoveryAutoConfiguration {
|
public class NacosDiscoveryAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -399,7 +399,8 @@ public class NacosDiscoveryProperties {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
namingService = NacosFactory.createNamingService(properties);
|
namingService = NacosFactory.createNamingService(properties);
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
LOGGER.error("create naming service error!properties={},e=,", this, e);
|
LOGGER.error("create naming service error!properties={},e=,", this, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
|||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.cloud.alibaba.nacos.ConditionalOnNacosDiscoveryEnabled;
|
import org.springframework.cloud.alibaba.nacos.ConditionalOnNacosDiscoveryEnabled;
|
||||||
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
||||||
import org.springframework.cloud.alibaba.nacos.discovery.NacosDiscoveryClient;
|
|
||||||
import org.springframework.cloud.alibaba.nacos.discovery.NacosWatch;
|
|
||||||
import org.springframework.cloud.client.CommonsClientAutoConfiguration;
|
import org.springframework.cloud.client.CommonsClientAutoConfiguration;
|
||||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||||
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAutoConfiguration;
|
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAutoConfiguration;
|
||||||
|
@ -36,8 +36,7 @@ public class NacosAutoServiceRegistration
|
|||||||
|
|
||||||
private NacosRegistration registration;
|
private NacosRegistration registration;
|
||||||
|
|
||||||
public NacosAutoServiceRegistration(
|
public NacosAutoServiceRegistration(ServiceRegistry<Registration> serviceRegistry,
|
||||||
ServiceRegistry<Registration> serviceRegistry,
|
|
||||||
AutoServiceRegistrationProperties autoServiceRegistrationProperties,
|
AutoServiceRegistrationProperties autoServiceRegistrationProperties,
|
||||||
NacosRegistration registration) {
|
NacosRegistration registration) {
|
||||||
super(serviceRegistry, autoServiceRegistrationProperties);
|
super(serviceRegistry, autoServiceRegistrationProperties);
|
||||||
|
@ -18,7 +18,6 @@ package org.springframework.cloud.alibaba.nacos.registry;
|
|||||||
|
|
||||||
import com.alibaba.nacos.api.naming.NamingService;
|
import com.alibaba.nacos.api.naming.NamingService;
|
||||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
||||||
@ -43,7 +42,6 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
|||||||
this.namingService = nacosDiscoveryProperties.namingServiceInstance();
|
this.namingService = nacosDiscoveryProperties.namingServiceInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(Registration registration) {
|
public void register(Registration registration) {
|
||||||
|
|
||||||
@ -65,7 +63,8 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
|||||||
namingService.registerInstance(serviceId, instance);
|
namingService.registerInstance(serviceId, instance);
|
||||||
logger.info("nacos registry, {} {}:{} register finished", serviceId,
|
logger.info("nacos registry, {} {}:{} register finished", serviceId,
|
||||||
instance.getIp(), instance.getPort());
|
instance.getIp(), instance.getPort());
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
logger.error("nacos registry, {} register failed...{},", serviceId,
|
logger.error("nacos registry, {} register failed...{},", serviceId,
|
||||||
registration.toString(), e);
|
registration.toString(), e);
|
||||||
}
|
}
|
||||||
@ -87,7 +86,8 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
|||||||
try {
|
try {
|
||||||
namingService.deregisterInstance(serviceId, registration.getHost(),
|
namingService.deregisterInstance(serviceId, registration.getHost(),
|
||||||
registration.getPort(), nacosDiscoveryProperties.getClusterName());
|
registration.getPort(), nacosDiscoveryProperties.getClusterName());
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
logger.error("ERR_NACOS_DEREGISTER, de-register failed...{},",
|
logger.error("ERR_NACOS_DEREGISTER, de-register failed...{},",
|
||||||
registration.toString(), e);
|
registration.toString(), e);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaojing
|
* @author xiaojing
|
||||||
|
* @author pbting
|
||||||
*/
|
*/
|
||||||
public class NacosServer extends Server {
|
public class NacosServer extends Server {
|
||||||
|
|
||||||
|
@ -62,7 +62,10 @@ public class NacosServerList extends AbstractServerList<NacosServer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<NacosServer> instancesToServerList(List<Instance> instances) {
|
private List<NacosServer> instancesToServerList(List<Instance> instances) {
|
||||||
List<NacosServer> result = new ArrayList<>(instances.size());
|
List<NacosServer> result = new ArrayList<>();
|
||||||
|
if (null == instances) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
for (Instance instance : instances) {
|
for (Instance instance : instances) {
|
||||||
result.add(new NacosServer(instance));
|
result.add(new NacosServer(instance));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user