mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
Merge pull request #394 from yunzheng1228/master
format code and fixed example's bug
This commit is contained in:
commit
dbfc363c02
4
pom.xml
4
pom.xml
@ -61,6 +61,10 @@
|
|||||||
<email>mercyblitz@gmail.com</email>
|
<email>mercyblitz@gmail.com</email>
|
||||||
<organization>Alibaba</organization>
|
<organization>Alibaba</organization>
|
||||||
<url>https://github.com/mercyblitz</url>
|
<url>https://github.com/mercyblitz</url>
|
||||||
|
</developer>
|
||||||
|
<developer>
|
||||||
|
<name>yunzheng</name>
|
||||||
|
<email>yunzheng1228@gmail.com</email>
|
||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
spring.application.name=sca-nacos-config
|
spring.application.name=nacos-config-example
|
||||||
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
|
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
|
||||||
spring.cloud.nacos.config.shared-data-ids=base-common.properties,common.properties
|
spring.cloud.nacos.config.shared-data-ids=base-common.properties,common.properties
|
||||||
spring.cloud.nacos.config.refreshable-dataids=common.properties
|
spring.cloud.nacos.config.refreshable-dataids=common.properties
|
@ -57,7 +57,7 @@ import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
|
|||||||
@ConfigurationProperties("spring.cloud.nacos.discovery")
|
@ConfigurationProperties("spring.cloud.nacos.discovery")
|
||||||
public class NacosDiscoveryProperties {
|
public class NacosDiscoveryProperties {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory
|
private static final Logger log = LoggerFactory
|
||||||
.getLogger(NacosDiscoveryProperties.class);
|
.getLogger(NacosDiscoveryProperties.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -413,7 +413,7 @@ public class NacosDiscoveryProperties {
|
|||||||
namingService = NacosFactory.createNamingService(properties);
|
namingService = NacosFactory.createNamingService(properties);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
LOGGER.error("create naming service error!properties={},e=,", this, e);
|
log.error("create naming service error!properties={},e=,", this, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return namingService;
|
return namingService;
|
||||||
|
@ -33,7 +33,7 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public class NacosDiscoveryClient implements DiscoveryClient {
|
public class NacosDiscoveryClient implements DiscoveryClient {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory
|
private static final Logger log = LoggerFactory
|
||||||
.getLogger(NacosDiscoveryClient.class);
|
.getLogger(NacosDiscoveryClient.class);
|
||||||
public static final String DESCRIPTION = "Spring Cloud Nacos Discovery Client";
|
public static final String DESCRIPTION = "Spring Cloud Nacos Discovery Client";
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public class NacosDiscoveryClient implements DiscoveryClient {
|
|||||||
return services.getData();
|
return services.getData();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
LOGGER.error("get service name from nacos server fail,", e);
|
log.error("get service name from nacos server fail,", e);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
|||||||
@Endpoint(id = "nacos-discovery")
|
@Endpoint(id = "nacos-discovery")
|
||||||
public class NacosDiscoveryEndpoint {
|
public class NacosDiscoveryEndpoint {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory
|
private static final Logger log = LoggerFactory
|
||||||
.getLogger(NacosDiscoveryEndpoint.class);
|
.getLogger(NacosDiscoveryEndpoint.class);
|
||||||
|
|
||||||
private NacosDiscoveryProperties nacosDiscoveryProperties;
|
private NacosDiscoveryProperties nacosDiscoveryProperties;
|
||||||
@ -61,7 +61,7 @@ public class NacosDiscoveryEndpoint {
|
|||||||
subscribe = namingService.getSubscribeServices();
|
subscribe = namingService.getSubscribeServices();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
LOGGER.error("get subscribe services from nacos fail,", e);
|
log.error("get subscribe services from nacos fail,", e);
|
||||||
}
|
}
|
||||||
result.put("subscribe", subscribe);
|
result.put("subscribe", subscribe);
|
||||||
return result;
|
return result;
|
||||||
|
@ -31,7 +31,7 @@ import org.springframework.util.StringUtils;
|
|||||||
*/
|
*/
|
||||||
public class NacosAutoServiceRegistration
|
public class NacosAutoServiceRegistration
|
||||||
extends AbstractAutoServiceRegistration<Registration> {
|
extends AbstractAutoServiceRegistration<Registration> {
|
||||||
private static final Logger LOGGER = LoggerFactory
|
private static final Logger log = LoggerFactory
|
||||||
.getLogger(NacosAutoServiceRegistration.class);
|
.getLogger(NacosAutoServiceRegistration.class);
|
||||||
|
|
||||||
private NacosRegistration registration;
|
private NacosRegistration registration;
|
||||||
@ -65,7 +65,7 @@ public class NacosAutoServiceRegistration
|
|||||||
@Override
|
@Override
|
||||||
protected void register() {
|
protected void register() {
|
||||||
if (!this.registration.getNacosDiscoveryProperties().isRegisterEnabled()) {
|
if (!this.registration.getNacosDiscoveryProperties().isRegisterEnabled()) {
|
||||||
LOGGER.debug("Registration disabled.");
|
log.debug("Registration disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.registration.getPort() < 0) {
|
if (this.registration.getPort() < 0) {
|
||||||
|
@ -32,7 +32,7 @@ import org.springframework.util.StringUtils;
|
|||||||
*/
|
*/
|
||||||
public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(NacosServiceRegistry.class);
|
private static final Logger log = LoggerFactory.getLogger(NacosServiceRegistry.class);
|
||||||
|
|
||||||
private final NacosDiscoveryProperties nacosDiscoveryProperties;
|
private final NacosDiscoveryProperties nacosDiscoveryProperties;
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
|||||||
public void register(Registration registration) {
|
public void register(Registration registration) {
|
||||||
|
|
||||||
if (StringUtils.isEmpty(registration.getServiceId())) {
|
if (StringUtils.isEmpty(registration.getServiceId())) {
|
||||||
logger.info("No service to register for nacos client...");
|
log.warn("No service to register for nacos client...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,11 +62,11 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
namingService.registerInstance(serviceId, instance);
|
namingService.registerInstance(serviceId, instance);
|
||||||
logger.info("nacos registry, {} {}:{} register finished", serviceId,
|
log.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,
|
log.error("nacos registry, {} register failed...{},", serviceId,
|
||||||
registration.toString(), e);
|
registration.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,10 +74,10 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
|||||||
@Override
|
@Override
|
||||||
public void deregister(Registration registration) {
|
public void deregister(Registration registration) {
|
||||||
|
|
||||||
logger.info("De-registering from Nacos Server now...");
|
log.info("De-registering from Nacos Server now...");
|
||||||
|
|
||||||
if (StringUtils.isEmpty(registration.getServiceId())) {
|
if (StringUtils.isEmpty(registration.getServiceId())) {
|
||||||
logger.info("No dom to de-register for nacos client...");
|
log.warn("No dom to de-register for nacos client...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +89,11 @@ public class NacosServiceRegistry implements ServiceRegistry<Registration> {
|
|||||||
registration.getPort(), nacosDiscoveryProperties.getClusterName());
|
registration.getPort(), nacosDiscoveryProperties.getClusterName());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
logger.error("ERR_NACOS_DEREGISTER, de-register failed...{},",
|
log.error("ERR_NACOS_DEREGISTER, de-register failed...{},",
|
||||||
registration.toString(), e);
|
registration.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("De-registration finished.");
|
log.info("De-registration finished.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,7 +45,7 @@ public class AnsServiceRegistry implements ServiceRegistry<AnsRegistration> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(registration.getServiceId())) {
|
if (StringUtils.isEmpty(registration.getServiceId())) {
|
||||||
log.info("No service to register for client...");
|
log.warn("No service to register for client...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public class AnsServiceRegistry implements ServiceRegistry<AnsRegistration> {
|
|||||||
log.info("De-registering from ANSServer now...");
|
log.info("De-registering from ANSServer now...");
|
||||||
|
|
||||||
if (StringUtils.isEmpty(registration.getServiceId())) {
|
if (StringUtils.isEmpty(registration.getServiceId())) {
|
||||||
log.info("No dom to de-register for client...");
|
log.warn("No dom to de-register for client...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user