Merge pull request #212 from hxy1991/master

Fixes #92
This commit is contained in:
yanlinly 2018-11-05 20:44:22 +08:00 committed by GitHub
commit 608104c993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 76 additions and 50 deletions

View File

@ -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)

View File

@ -32,7 +32,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
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)

View File

@ -29,10 +29,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
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 @@ import java.io.IOException;
@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 class CommunicationController {
@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 class CommunicationController {
@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);
}
}

View File

@ -23,7 +23,6 @@ import com.alibaba.nacos.config.server.service.AggrWhitelist;
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;
@ -62,16 +61,12 @@ public class ConfigController {
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;
}

View File

@ -322,9 +322,7 @@ public class ConfigServletInner {
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;
}

View File

@ -38,13 +38,15 @@ import javax.annotation.PostConstruct;
@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 class HealthController {
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()) {

View File

@ -57,8 +57,7 @@ public class HistoryController {
pageSize = null == pageSize ? Integer.valueOf(100) : pageSize;
pageSize = pageSize > 500 ? Integer.valueOf(500) : pageSize;
// configInfoBase没有appName字段
Page<ConfigHistoryInfo> page = persistService.findConfigHistory(dataId, group, tenant, pageNo, pageSize);
return page;
return persistService.findConfigHistory(dataId, group, tenant, pageNo, pageSize);
}
/**
@ -68,8 +67,7 @@ public class HistoryController {
@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);
}
}

View File

@ -29,10 +29,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
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,8 +44,10 @@ import java.util.Map;
@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);

View File

@ -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)

View File

@ -1,12 +1,12 @@
,--.
,--.'|
,--,: : |
,`--.'`| ' : ,---.
| : : | | ' ,'\ .--.--.
,--,: : | Version: 0.4.0
,`--.'`| ' : ,---. Port: 8848
| : : | | ' ,'\ .--.--. Console: http://localhost:8848/nacos/index.html
: | \ | : ,--.--. ,---. / / | / / '
| : ' '; | / \ / \. ; ,. :| : /`./
' ' ;. ;.--. .-. | / / '' | |: :| : ;_
' ' ;. ;.--. .-. | / / '' | |: :| : ;_ https://nacos.io
| | | \ | \__\/: . .. ' / ' | .; : \ \ `.
' : | ; .' ," .--.; |' ; :__| : | `----. \
| | '`--' / / ,. |' | '.'|\ \ / / /`--' /

View File

@ -1,6 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<Pattern>%date %level %msg%n%n</Pattern>
<charset>utf8</charset>
</encoder>
</appender>
<appender name="naming-server"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${nacos.home}/logs/naming-server.log</file>
@ -517,6 +524,31 @@
<appender-ref ref="startLog" />
</logger>
<logger name="org.springframework">
<appender-ref ref="CONSOLE"/>
<level value="INFO"/>
</logger>
<logger name="org.apache.catalina.startup.DigesterFactory">
<appender-ref ref="CONSOLE"/>
<level value="INFO"/>
</logger>
<logger name="org.apache.catalina.util.LifecycleBase">
<appender-ref ref="CONSOLE"/>
<level value="ERROR"/>
</logger>
<logger name="org.apache.coyote.http11.Http11NioProtocol">
<appender-ref ref="CONSOLE"/>
<level value="WARN"/>
</logger>
<logger name="org.apache.tomcat.util.net.NioSelectorPool">
<appender-ref ref="CONSOLE"/>
<level value="WARN"/>
</logger>
<root>
<level value="INFO"/>
<appender-ref ref="rootFile"/>