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.NacosRegistration;
|
||||
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.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -43,7 +43,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@ConditionalOnNacosDiscoveryEnabled
|
||||
@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true)
|
||||
@AutoConfigureBefore(NacosDiscoveryClientAutoConfiguration.class)
|
||||
@AutoConfigureAfter(AutoServiceRegistrationAutoConfiguration.class)
|
||||
@AutoConfigureAfter(AutoServiceRegistrationConfiguration.class)
|
||||
public class NacosDiscoveryAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -154,8 +154,8 @@ public class NacosDiscoveryProperties {
|
||||
}
|
||||
|
||||
serverAddr = Objects.toString(serverAddr, "");
|
||||
if(serverAddr.lastIndexOf("/") != -1) {
|
||||
serverAddr.substring(0,serverAddr.length()-1);
|
||||
if (serverAddr.lastIndexOf("/") != -1) {
|
||||
serverAddr.substring(0, serverAddr.length() - 1);
|
||||
}
|
||||
endpoint = Objects.toString(endpoint, "");
|
||||
namespace = Objects.toString(namespace, "");
|
||||
@ -399,7 +399,8 @@ public class NacosDiscoveryProperties {
|
||||
|
||||
try {
|
||||
namingService = NacosFactory.createNamingService(properties);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOGGER.error("create naming service error!properties={},e=,", this, e);
|
||||
return null;
|
||||
}
|
||||
|
@ -21,8 +21,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.alibaba.nacos.ConditionalOnNacosDiscoveryEnabled;
|
||||
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.discovery.DiscoveryClient;
|
||||
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClientAutoConfiguration;
|
||||
|
@ -36,8 +36,7 @@ public class NacosAutoServiceRegistration
|
||||
|
||||
private NacosRegistration registration;
|
||||
|
||||
public NacosAutoServiceRegistration(
|
||||
ServiceRegistry<Registration> serviceRegistry,
|
||||
public NacosAutoServiceRegistration(ServiceRegistry<Registration> serviceRegistry,
|
||||
AutoServiceRegistrationProperties autoServiceRegistrationProperties,
|
||||
NacosRegistration registration) {
|
||||
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.pojo.Instance;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
||||
@ -43,7 +42,6 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
this.namingService = nacosDiscoveryProperties.namingServiceInstance();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void register(Registration registration) {
|
||||
|
||||
@ -65,7 +63,8 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
namingService.registerInstance(serviceId, instance);
|
||||
logger.info("nacos registry, {} {}:{} register finished", serviceId,
|
||||
instance.getIp(), instance.getPort());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("nacos registry, {} register failed...{},", serviceId,
|
||||
registration.toString(), e);
|
||||
}
|
||||
@ -87,7 +86,8 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||
try {
|
||||
namingService.deregisterInstance(serviceId, registration.getHost(),
|
||||
registration.getPort(), nacosDiscoveryProperties.getClusterName());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("ERR_NACOS_DEREGISTER, de-register failed...{},",
|
||||
registration.toString(), e);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xiaojing
|
||||
* @author pbting
|
||||
*/
|
||||
public class NacosServer extends Server {
|
||||
|
||||
|
@ -62,7 +62,10 @@ public class NacosServerList extends AbstractServerList<NacosServer> {
|
||||
}
|
||||
|
||||
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) {
|
||||
result.add(new NacosServer(instance));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user