#629 Fix bug
This commit is contained in:
parent
6ae100e390
commit
8d28958cb7
@ -65,8 +65,9 @@ server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
||||
# default current work dir
|
||||
server.tomcat.basedir=
|
||||
|
||||
nacos.naming.partition.taskDispatchThreadCount=10
|
||||
nacos.naming.partition.taskDispatchPeriod=200
|
||||
nacos.naming.partition.batchSyncKeyCount=1000
|
||||
nacos.naming.partition.initDataRatio=0.9
|
||||
nacos.naming.partition.syncRetryDelay=5000
|
||||
nacos.naming.distro.taskDispatchThreadCount=10
|
||||
nacos.naming.distro.taskDispatchPeriod=200
|
||||
nacos.naming.distro.batchSyncKeyCount=1000
|
||||
nacos.naming.distro.initDataRatio=0.9
|
||||
nacos.naming.distro.syncRetryDelay=5000
|
||||
nacos.naming.data.warmup=false
|
||||
|
@ -39,8 +39,9 @@ server.tomcat.basedir=
|
||||
|
||||
nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/**
|
||||
|
||||
nacos.naming.partition.taskDispatchThreadCount=10
|
||||
nacos.naming.partition.taskDispatchPeriod=200
|
||||
nacos.naming.partition.batchSyncKeyCount=1000
|
||||
nacos.naming.partition.initDataRatio=0.9
|
||||
nacos.naming.partition.syncRetryDelay=5000
|
||||
nacos.naming.distro.taskDispatchThreadCount=10
|
||||
nacos.naming.distro.taskDispatchPeriod=200
|
||||
nacos.naming.distro.batchSyncKeyCount=1000
|
||||
nacos.naming.distro.initDataRatio=0.9
|
||||
nacos.naming.distro.syncRetryDelay=5000
|
||||
nacos.naming.data.warmup=true
|
||||
|
@ -16,7 +16,9 @@
|
||||
package com.alibaba.nacos.naming.boot;
|
||||
|
||||
import com.alibaba.nacos.naming.misc.Loggers;
|
||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.context.WebServerInitializedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
@ -53,6 +55,10 @@ public class RunningConfig implements ApplicationListener<WebServerInitializedEv
|
||||
}
|
||||
|
||||
public static String getContextPath() {
|
||||
|
||||
if (StringUtils.isBlank(contextPath)) {
|
||||
return UtilsAndCommons.NACOS_SERVER_CONTEXT;
|
||||
}
|
||||
return contextPath;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class DataSyncer implements ServerChangeListener {
|
||||
private DataStore dataStore;
|
||||
|
||||
@Autowired
|
||||
private PartitionConfig partitionConfig;
|
||||
private GlobalConfig partitionConfig;
|
||||
|
||||
@Autowired
|
||||
private Serializer serializer;
|
||||
|
@ -78,6 +78,9 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
|
||||
@Autowired
|
||||
private SwitchDomain switchDomain;
|
||||
|
||||
@Autowired
|
||||
private GlobalConfig globalConfig;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
private volatile Map<String, List<RecordListener>> listeners = new ConcurrentHashMap<>();
|
||||
@ -101,7 +104,8 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
|
||||
initialized = true;
|
||||
return;
|
||||
}
|
||||
while (serverListManager.getHealthyServers().isEmpty()) {
|
||||
// size = 1 means only myself in the list, we need at least one another server alive:
|
||||
while (serverListManager.getHealthyServers().size() <= 1) {
|
||||
Thread.sleep(1000L);
|
||||
Loggers.EPHEMERAL.info("waiting server list init...");
|
||||
}
|
||||
@ -110,6 +114,9 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
|
||||
if (NetUtils.localServer().equals(server.getKey())) {
|
||||
continue;
|
||||
}
|
||||
if (Loggers.EPHEMERAL.isDebugEnabled()) {
|
||||
Loggers.EPHEMERAL.debug("sync from " + server);
|
||||
}
|
||||
// try sync data from remote server:
|
||||
if (syncAllDataFromRemote(server)) {
|
||||
initialized = true;
|
||||
@ -227,7 +234,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
|
||||
processData(data);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Loggers.EPHEMERAL.error("sync full data from " + server + " failed!");
|
||||
Loggers.EPHEMERAL.error("sync full data from " + server + " failed!", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -301,6 +308,10 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return initialized || ServerStatus.UP.name().equals(switchDomain.getOverriddenServerStatus());
|
||||
return isInitialized() || ServerStatus.UP.name().equals(switchDomain.getOverriddenServerStatus());
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return initialized || !globalConfig.isDataWarmup();
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
package com.alibaba.nacos.naming.consistency.ephemeral.distro;
|
||||
|
||||
import com.alibaba.nacos.naming.cluster.servers.Server;
|
||||
import com.alibaba.nacos.naming.misc.GlobalConfig;
|
||||
import com.alibaba.nacos.naming.misc.GlobalExecutor;
|
||||
import com.alibaba.nacos.naming.misc.Loggers;
|
||||
import com.alibaba.nacos.naming.misc.NetUtils;
|
||||
@ -38,7 +39,7 @@ import java.util.concurrent.*;
|
||||
public class TaskDispatcher {
|
||||
|
||||
@Autowired
|
||||
private PartitionConfig partitionConfig;
|
||||
private GlobalConfig partitionConfig;
|
||||
|
||||
@Autowired
|
||||
private DataSyncer dataSyncer;
|
||||
|
@ -101,6 +101,9 @@ public class RaftCore {
|
||||
@Autowired
|
||||
private SwitchDomain switchDomain;
|
||||
|
||||
@Autowired
|
||||
private GlobalConfig globalConfig;
|
||||
|
||||
@Autowired
|
||||
private RaftProxy raftProxy;
|
||||
|
||||
@ -874,7 +877,7 @@ public class RaftCore {
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return initialized;
|
||||
return initialized || !globalConfig.isDataWarmup();
|
||||
}
|
||||
|
||||
public class Notifier implements Runnable {
|
||||
|
@ -223,7 +223,7 @@ public class ServiceController {
|
||||
}
|
||||
|
||||
for (int i = start; i < end; i++) {
|
||||
serviceNameList.add(i, serviceNameList.get(i).replace(groupName + Constants.SERVICE_INFO_SPLITER, ""));
|
||||
serviceNameList.set(i, serviceNameList.get(i).replace(groupName + Constants.SERVICE_INFO_SPLITER, ""));
|
||||
}
|
||||
|
||||
result.put("doms", serviceNameList.subList(start, end));
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.alibaba.nacos.naming.consistency.ephemeral.distro;
|
||||
package com.alibaba.nacos.naming.misc;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -25,7 +25,7 @@ import org.springframework.stereotype.Component;
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Component
|
||||
public class PartitionConfig {
|
||||
public class GlobalConfig {
|
||||
|
||||
@Value("${nacos.naming.distro.taskDispatchPeriod}")
|
||||
private int taskDispatchPeriod = 2000;
|
||||
@ -33,15 +33,15 @@ public class PartitionConfig {
|
||||
@Value("${nacos.naming.distro.batchSyncKeyCount}")
|
||||
private int batchSyncKeyCount = 1000;
|
||||
|
||||
@Value("${nacos.naming.distro.initDataRatio}")
|
||||
private float initDataRatio = 0.9F;
|
||||
|
||||
@Value("${nacos.naming.distro.syncRetryDelay}")
|
||||
private long syncRetryDelay = 5000L;
|
||||
|
||||
@Value("${nacos.naming.distro.taskDispatchThreadCount}")
|
||||
private int taskDispatchThreadCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
@Value("${nacos.naming.data.warmup}")
|
||||
private boolean dataWarmup = false;
|
||||
|
||||
public int getTaskDispatchPeriod() {
|
||||
return taskDispatchPeriod;
|
||||
}
|
||||
@ -50,10 +50,6 @@ public class PartitionConfig {
|
||||
return batchSyncKeyCount;
|
||||
}
|
||||
|
||||
public float getInitDataRatio() {
|
||||
return initDataRatio;
|
||||
}
|
||||
|
||||
public long getSyncRetryDelay() {
|
||||
return syncRetryDelay;
|
||||
}
|
||||
@ -61,4 +57,8 @@ public class PartitionConfig {
|
||||
public int getTaskDispatchThreadCount() {
|
||||
return taskDispatchThreadCount;
|
||||
}
|
||||
|
||||
public boolean isDataWarmup() {
|
||||
return dataWarmup;
|
||||
}
|
||||
}
|
@ -40,11 +40,11 @@ public class ServerStatusSynchronizer implements Synchronizer {
|
||||
params.put("serverStatus", msg.getData());
|
||||
|
||||
String url = "http://" + serverIP + ":" + RunningConfig.getServerPort()
|
||||
+ RunningConfig.getContextPath() + UtilsAndCommons.NACOS_NAMING_CONTEXT + "/operator/serverStatus";
|
||||
+ RunningConfig.getContextPath() + UtilsAndCommons.NACOS_NAMING_CONTEXT + "/operator/server/status";
|
||||
|
||||
if (serverIP.contains(UtilsAndCommons.IP_PORT_SPLITER)) {
|
||||
url = "http://" + serverIP + RunningConfig.getContextPath() + UtilsAndCommons.NACOS_NAMING_CONTEXT
|
||||
+ "/operator/serverStatus";
|
||||
+ "/operator/server/status";
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -31,3 +31,5 @@ nacos.naming.distro.taskDispatchPeriod=200
|
||||
nacos.naming.distro.batchSyncKeyCount=1000
|
||||
nacos.naming.distro.initDataRatio=0.9
|
||||
nacos.naming.distro.syncRetryDelay=5000
|
||||
|
||||
nacos.naming.data.warmup=true
|
||||
|
@ -358,7 +358,7 @@ public class CPInstancesAPI_ITCase {
|
||||
ResponseEntity<String> response = request(NamingBase.NAMING_CONTROLLER_PATH + "/service",
|
||||
Params.newParams()
|
||||
.appendParam("serviceName", serviceName)
|
||||
.appendParam("protectThreshold", "3")
|
||||
.appendParam("protectThreshold", "0.3")
|
||||
.appendParam("namespaceId", namespace)
|
||||
.appendParam("groupName", groupName)
|
||||
.done(),
|
||||
|
@ -24,3 +24,4 @@ nacos.naming.distro.taskDispatchPeriod=200
|
||||
nacos.naming.distro.batchSyncKeyCount=1000
|
||||
nacos.naming.distro.initDataRatio=0.9
|
||||
nacos.naming.distro.syncRetryDelay=5000
|
||||
nacos.naming.data.warmup=false
|
||||
|
Loading…
Reference in New Issue
Block a user