#502 fix bug
This commit is contained in:
parent
e7171c0eef
commit
f0c71e6d8b
@ -40,7 +40,7 @@ public class OperationController {
|
||||
@Autowired
|
||||
private CmdbProvider cmdbProvider;
|
||||
|
||||
@RequestMapping(value = "/updateSwitch", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/switch", method = RequestMethod.PUT)
|
||||
public String updateSwitch(HttpServletRequest request) throws Exception {
|
||||
|
||||
String entry = WebUtils.required(request, "entry");
|
||||
@ -64,7 +64,7 @@ public class OperationController {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/queryLabel", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/label", method = RequestMethod.GET)
|
||||
public String queryLabel(HttpServletRequest request) throws Exception {
|
||||
String entry = WebUtils.required(request, "entry");
|
||||
String label = WebUtils.required(request, "label");
|
||||
|
@ -97,7 +97,7 @@ if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then
|
||||
JAVA_OPT="${JAVA_OPT} -cp .:${BASE_DIR}/plugins/cmdb/*.jar"
|
||||
JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${BASE_DIR}/logs/nacos_gc.log:time,tags:filecount=10,filesize=102400"
|
||||
else
|
||||
#JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${BASE_DIR}/plugins/cmdb"
|
||||
JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${BASE_DIR}/plugins/cmdb"
|
||||
JAVA_OPT="${JAVA_OPT} -Xloggc:${BASE_DIR}/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
|
||||
fi
|
||||
|
||||
|
Binary file not shown.
@ -27,7 +27,9 @@ import org.springframework.stereotype.Component;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Data sync task dispatcher
|
||||
@ -96,8 +98,7 @@ public class TaskDispatcher {
|
||||
String key = queue.poll(partitionConfig.getTaskDispatchPeriod(),
|
||||
TimeUnit.MILLISECONDS);
|
||||
|
||||
if (StringUtils.isBlank(key) || dataSyncer.getServers() == null ||
|
||||
dataSyncer.getServers().isEmpty()) {
|
||||
if (dataSyncer.getServers() == null || dataSyncer.getServers().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -105,7 +106,7 @@ public class TaskDispatcher {
|
||||
keys = new ArrayList<>();
|
||||
}
|
||||
|
||||
if (dataSize < partitionConfig.getBatchSyncKeyCount()) {
|
||||
if (StringUtils.isNotBlank(key)) {
|
||||
keys.add(key);
|
||||
dataSize++;
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -397,13 +398,13 @@ public class ServiceController {
|
||||
return filteredServices;
|
||||
}
|
||||
|
||||
private Selector parseSelector(String selectorJsonString) throws NacosException {
|
||||
private Selector parseSelector(String selectorJsonString) throws Exception {
|
||||
|
||||
if (StringUtils.isBlank(selectorJsonString)) {
|
||||
return new NoneSelector();
|
||||
}
|
||||
|
||||
JSONObject selectorJson = JSON.parseObject(selectorJsonString);
|
||||
JSONObject selectorJson = JSON.parseObject(URLDecoder.decode(selectorJsonString, "UTF-8"));
|
||||
switch (SelectorType.valueOf(selectorJson.getString("type"))) {
|
||||
case none:
|
||||
return new NoneSelector();
|
||||
|
@ -473,8 +473,8 @@ public class Service extends com.alibaba.nacos.api.naming.pojo.Service implement
|
||||
for (Cluster cluster : clusters) {
|
||||
Cluster oldCluster = clusterMap.get(cluster.getName());
|
||||
if (oldCluster != null) {
|
||||
oldCluster.update(cluster);
|
||||
oldCluster.setService(this);
|
||||
oldCluster.update(cluster);
|
||||
} else {
|
||||
cluster.init();
|
||||
cluster.setService(this);
|
||||
|
@ -20,9 +20,9 @@ import com.alibaba.nacos.api.common.Constants;
|
||||
import com.alibaba.nacos.api.exception.NacosException;
|
||||
import com.alibaba.nacos.naming.cluster.ServerMode;
|
||||
import com.alibaba.nacos.naming.consistency.ConsistencyService;
|
||||
import com.alibaba.nacos.naming.consistency.Datum;
|
||||
import com.alibaba.nacos.naming.consistency.KeyBuilder;
|
||||
import com.alibaba.nacos.naming.consistency.RecordListener;
|
||||
import com.alibaba.nacos.naming.consistency.Datum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -70,7 +70,7 @@ public class SwitchManager implements RecordListener<SwitchDomain> {
|
||||
Datum datum = consistencyService.get(UtilsAndCommons.getSwitchDomainKey());
|
||||
SwitchDomain switchDomain;
|
||||
|
||||
if (datum != null) {
|
||||
if (datum != null && datum.value != null) {
|
||||
switchDomain = (SwitchDomain) datum.value;
|
||||
} else {
|
||||
switchDomain = this.switchDomain.clone();
|
||||
|
@ -57,8 +57,6 @@ import java.util.Set;
|
||||
*/
|
||||
public class LabelSelector extends ExpressionSelector implements Selector {
|
||||
|
||||
private CmdbReader cmdbReader;
|
||||
|
||||
/**
|
||||
* The labels relevant to this the selector.
|
||||
*
|
||||
@ -93,9 +91,11 @@ public class LabelSelector extends ExpressionSelector implements Selector {
|
||||
|
||||
public LabelSelector() {
|
||||
setType(SelectorType.label.name());
|
||||
cmdbReader = SpringContext.getAppContext().getBean(CmdbReader.class);
|
||||
}
|
||||
|
||||
private CmdbReader getCmdbReader() {
|
||||
return SpringContext.getAppContext().getBean(CmdbReader.class);
|
||||
}
|
||||
|
||||
public static Set<String> parseExpression(String expression) throws NacosException {
|
||||
return ExpressionInterpreter.parseExpression(expression);
|
||||
@ -115,11 +115,11 @@ public class LabelSelector extends ExpressionSelector implements Selector {
|
||||
boolean matched = true;
|
||||
for (String labelName : getLabels()) {
|
||||
|
||||
String consumerLabelValue = cmdbReader.queryLabel(consumer, PreservedEntityTypes.ip.name(), labelName);
|
||||
String consumerLabelValue = getCmdbReader().queryLabel(consumer, PreservedEntityTypes.ip.name(), labelName);
|
||||
|
||||
if (StringUtils.isNotBlank(consumerLabelValue) &&
|
||||
!StringUtils.equals(consumerLabelValue,
|
||||
cmdbReader.queryLabel(instance.getIp(), PreservedEntityTypes.ip.name(), labelName))) {
|
||||
getCmdbReader().queryLabel(instance.getIp(), PreservedEntityTypes.ip.name(), labelName))) {
|
||||
matched = false;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user