diff --git a/README.md b/README.md index e3126dd69ba..ab2e3749575 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ For more details, see [quick-start.](https://nacos.io/en-us/docs/quick-start.htm 3. #### Quick start for other open-source projects: -* [quick start with spring cloud](https://nacos.io/en-us/docs/use-nacos-with-springcloud.html) +* [quick start with spring cloud](https://nacos.io/en-us/docs/quick-start-spring-cloud.html) * [quick start with dubbo](https://nacos.io/en-us/docs/use-nacos-with-dubbo.html) diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/CapacityController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/CapacityController.java index 850108514c7..ce884117f89 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/CapacityController.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/CapacityController.java @@ -32,7 +32,7 @@ import javax.servlet.http.HttpServletResponse; /** - * capcity manage + * Capacity Management * * @author hexu.hxy */ @@ -42,8 +42,10 @@ public class CapacityController { private static final Logger LOGGER = LoggerFactory.getLogger(CapacityController.class); + private final CapacityService capacityService; + @Autowired - private CapacityService capacityService; + public CapacityController(CapacityService capacityService) {this.capacityService = capacityService;} @ResponseBody @RequestMapping(method = RequestMethod.GET) diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/CommunicationController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/CommunicationController.java index 1b38f06e7cd..2c09f388a2a 100755 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/CommunicationController.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/CommunicationController.java @@ -29,10 +29,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; /** @@ -45,15 +43,19 @@ @RequestMapping(Constants.COMMUNICATION_CONTROLLER_PATH) public class CommunicationController { - @Autowired - private DumpService dumpService; + private final DumpService dumpService; - @Autowired - protected LongPollingService longPollingService; + private final LongPollingService longPollingService; private String trueStr = "true"; - - /** + + @Autowired + public CommunicationController(DumpService dumpService, LongPollingService longPollingService) { + this.dumpService = dumpService; + this.longPollingService = longPollingService; + } + + /** * 通知配置信息改变 * */ @@ -87,11 +89,9 @@ public SampleResult getSubClientConfig(HttpServletRequest request, @RequestParam("dataId") String dataId, @RequestParam("group") String group, @RequestParam(value = "tenant", required = false) String tenant, - ModelMap modelMap) - throws IOException, ServletException, Exception { + ModelMap modelMap) { group = StringUtils.isBlank(group) ? Constants.DEFAULT_GROUP : group; - SampleResult sampleResult = longPollingService.getCollectSubscribleInfo(dataId, group, tenant); - return sampleResult; + return longPollingService.getCollectSubscribleInfo(dataId, group, tenant); } /** @@ -100,11 +100,7 @@ public SampleResult getSubClientConfig(HttpServletRequest request, @RequestMapping(value= "/watcherConfigs", method = RequestMethod.GET) @ResponseBody public SampleResult getSubClientConfigByIp(HttpServletRequest request, - HttpServletResponse response, - @RequestParam("ip") String ip, - ModelMap modelMap) - throws IOException, ServletException, Exception { - SampleResult sampleResult = longPollingService.getCollectSubscribleInfoByIp(ip); - return sampleResult; + HttpServletResponse response, @RequestParam("ip") String ip,ModelMap modelMap) { + return longPollingService.getCollectSubscribleInfoByIp(ip); } } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java index 41ffc0dfa7a..ff071f9da7c 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigController.java @@ -23,7 +23,6 @@ import com.alibaba.nacos.config.server.service.ConfigDataChangeEvent; import com.alibaba.nacos.config.server.service.ConfigSubService; import com.alibaba.nacos.config.server.service.PersistService; -import com.alibaba.nacos.config.server.service.merge.MergeDatumService; import com.alibaba.nacos.config.server.service.trace.ConfigTraceService; import com.alibaba.nacos.config.server.utils.*; import com.alibaba.nacos.config.server.utils.event.EventDispatcher; @@ -61,17 +60,13 @@ public class ConfigController { private final transient ConfigServletInner inner; private final transient PersistService persistService; - - private final transient MergeDatumService mergeService; private final transient ConfigSubService configSubService; @Autowired - public ConfigController(ConfigServletInner configServletInner, PersistService persistService, MergeDatumService mergeService, - ConfigSubService configSubService) { + public ConfigController(ConfigServletInner configServletInner, PersistService persistService, ConfigSubService configSubService) { this.inner = configServletInner; this.persistService = persistService; - this.mergeService = mergeService; this.configSubService = configSubService; } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigServletInner.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigServletInner.java index cd8883ebad7..4d864a8f78c 100755 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigServletInner.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/ConfigServletInner.java @@ -322,9 +322,7 @@ private static int tryConfigReadLock(HttpServletRequest request, HttpServletResp private static boolean isUseTag(CacheItem cacheItem, String tag) { if (cacheItem != null && cacheItem.tagMd5 != null && cacheItem.tagMd5.size() > 0) { - if (StringUtils.isNotBlank(tag) && cacheItem.tagMd5.containsKey(tag)) { - return true; - } + return StringUtils.isNotBlank(tag) && cacheItem.tagMd5.containsKey(tag); } return false; } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/HealthController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/HealthController.java index aa2ee407ae8..5b672fdfccf 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/HealthController.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/HealthController.java @@ -38,13 +38,15 @@ @RequestMapping(Constants.HEALTH_CONTROLLER_PATH) public class HealthController { - @Autowired - private DynamicDataSource dynamicDataSource; + private final DynamicDataSource dynamicDataSource; private DataSourceService dataSourceService; private String heathUpStr = "UP"; private String heathDownStr = "DOWN"; private String heathWarnStr = "WARN"; + @Autowired + public HealthController(DynamicDataSource dynamicDataSource) {this.dynamicDataSource = dynamicDataSource;} + @PostConstruct public void init() { dataSourceService = dynamicDataSource.getDataSource(); @@ -63,7 +65,7 @@ public String getHealth() { sb.append("从数据库 ").append(dbStatus.split(":")[1]).append(" down. "); } else { sb.append("DOWN:"); - if (dbStatus.indexOf(heathDownStr) != -1) { + if (dbStatus.contains(heathDownStr)) { sb.append("主数据库 ").append(dbStatus.split(":")[1]).append(" down. "); } if (!ServerListService.isAddressServerHealth()) { diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/HistoryController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/HistoryController.java index 6a3b66a0235..b89f3bbf126 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/HistoryController.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/HistoryController.java @@ -57,8 +57,7 @@ public Page listConfigHistory(HttpServletRequest request, Htt pageSize = null == pageSize ? Integer.valueOf(100) : pageSize; pageSize = pageSize > 500 ? Integer.valueOf(500) : pageSize; // configInfoBase没有appName字段 - Page page = persistService.findConfigHistory(dataId, group, tenant, pageNo, pageSize); - return page; + return persistService.findConfigHistory(dataId, group, tenant, pageNo, pageSize); } /** @@ -68,8 +67,7 @@ public Page listConfigHistory(HttpServletRequest request, Htt @ResponseBody public ConfigHistoryInfo getConfigHistoryInfo(HttpServletRequest request, HttpServletResponse response, @RequestParam("nid") Long nid, ModelMap modelMap) { - ConfigHistoryInfo configInfo = persistService.detailConfigHistory(nid); - return configInfo; + return persistService.detailConfigHistory(nid); } } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/ListenerController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/ListenerController.java index 93dc8253e6f..9d9a6ae2354 100755 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/ListenerController.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/ListenerController.java @@ -29,10 +29,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -46,9 +44,11 @@ @RequestMapping(Constants.LISTENER_CONTROLLER_PATH) public class ListenerController { + private final ConfigSubService configSubService; + @Autowired - ConfigSubService configSubService; - + public ListenerController(ConfigSubService configSubService) {this.configSubService = configSubService;} + /* * 获取客户端订阅配置信息 */ @@ -57,8 +57,7 @@ public class ListenerController { public GroupkeyListenserStatus getAllSubClientConfigByIp(HttpServletRequest request, HttpServletResponse response, @RequestParam("ip") String ip, @RequestParam(value = "all", required = false) boolean all, @RequestParam(value = "tenant", required = false) String tenant, - @RequestParam(value = "sampleTime", required = false, defaultValue = "1") int sampleTime, ModelMap modelMap) - throws IOException, ServletException, Exception { + @RequestParam(value = "sampleTime", required = false, defaultValue = "1") int sampleTime, ModelMap modelMap) throws Exception { SampleResult collectSampleResult = configSubService.getCollectSampleResultByIp(ip, sampleTime); GroupkeyListenserStatus gls = new GroupkeyListenserStatus(); gls.setCollectStatus(200); diff --git a/config/src/main/java/com/alibaba/nacos/config/server/controller/OpsController.java b/config/src/main/java/com/alibaba/nacos/config/server/controller/OpsController.java index 827fe8ff365..03f1420a47d 100755 --- a/config/src/main/java/com/alibaba/nacos/config/server/controller/OpsController.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/controller/OpsController.java @@ -40,11 +40,15 @@ public class OpsController { private static final Logger log = LoggerFactory.getLogger(OpsController.class); - @Autowired - protected PersistService persistService; + protected final PersistService persistService; + + private final DumpService dumpService; @Autowired - DumpService dumpService; + public OpsController(PersistService persistService, DumpService dumpService) { + this.persistService = persistService; + this.dumpService = dumpService; + } // ops call @RequestMapping(value = "/localCache", method = RequestMethod.POST) diff --git a/core/src/main/resources/banner.txt b/core/src/main/resources/banner.txt index 4ebabe6fa06..d409e36aecc 100644 --- a/core/src/main/resources/banner.txt +++ b/core/src/main/resources/banner.txt @@ -1,12 +1,12 @@ ,--. ,--.'| - ,--,: : | -,`--.'`| ' : ,---. -| : : | | ' ,'\ .--.--. + ,--,: : | Version: 0.4.0 +,`--.'`| ' : ,---. Port: 8848 +| : : | | ' ,'\ .--.--. Console: http://localhost:8848/nacos/index.html : | \ | : ,--.--. ,---. / / | / / ' | : ' '; | / \ / \. ; ,. :| : /`./ -' ' ;. ;.--. .-. | / / '' | |: :| : ;_ +' ' ;. ;.--. .-. | / / '' | |: :| : ;_ https://nacos.io | | | \ | \__\/: . .. ' / ' | .; : \ \ `. ' : | ; .' ," .--.; |' ; :__| : | `----. \ | | '`--' / / ,. |' | '.'|\ \ / / /`--' / diff --git a/distribution/conf/nacos-logback.xml b/distribution/conf/nacos-logback.xml index 895d74eaa81..796050ef816 100644 --- a/distribution/conf/nacos-logback.xml +++ b/distribution/conf/nacos-logback.xml @@ -1,6 +1,13 @@ + + + %date %level %msg%n%n + utf8 + + + ${nacos.home}/logs/naming-server.log @@ -517,6 +524,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + +