Merge pull request #1398 from nkorange/hotfix_notify_task_called_before_data_loaded
Fix #1397
This commit is contained in:
commit
409838fe1f
@ -34,36 +34,9 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
@RequestMapping(UtilsAndCommons.NACOS_CMDB_CONTEXT + "/ops")
|
@RequestMapping(UtilsAndCommons.NACOS_CMDB_CONTEXT + "/ops")
|
||||||
public class OperationController {
|
public class OperationController {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SwitchAndOptions switches;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CmdbProvider cmdbProvider;
|
private CmdbProvider cmdbProvider;
|
||||||
|
|
||||||
@RequestMapping(value = "/switch", method = RequestMethod.PUT)
|
|
||||||
public String updateSwitch(HttpServletRequest request) throws Exception {
|
|
||||||
|
|
||||||
String entry = WebUtils.required(request, "entry");
|
|
||||||
String value = WebUtils.required(request, "value");
|
|
||||||
|
|
||||||
switch (entry) {
|
|
||||||
case "dumpTaskInterval":
|
|
||||||
switches.setDumpTaskInterval(Integer.parseInt(value));
|
|
||||||
break;
|
|
||||||
case "eventTaskInterval":
|
|
||||||
switches.setEventTaskInterval(Integer.parseInt(value));
|
|
||||||
break;
|
|
||||||
case "loadDataAtStart":
|
|
||||||
switches.setLoadDataAtStart(Boolean.parseBoolean(value));
|
|
||||||
break;
|
|
||||||
case "labelTaskInterval":
|
|
||||||
switches.setLabelTaskInterval(Integer.parseInt(value));
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return "ok";
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/label", method = RequestMethod.GET)
|
@RequestMapping(value = "/label", method = RequestMethod.GET)
|
||||||
public String queryLabel(HttpServletRequest request) throws Exception {
|
public String queryLabel(HttpServletRequest request) throws Exception {
|
||||||
String entry = WebUtils.required(request, "entry");
|
String entry = WebUtils.required(request, "entry");
|
||||||
|
@ -25,47 +25,31 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class SwitchAndOptions {
|
public class SwitchAndOptions {
|
||||||
|
|
||||||
@Value("${nacos.cmdb.dumpTaskInterval}")
|
@Value("${nacos.cmdb.dumpTaskInterval:3600}")
|
||||||
private int dumpTaskInterval;
|
private int dumpTaskInterval;
|
||||||
|
|
||||||
@Value("${nacos.cmdb.eventTaskInterval}")
|
@Value("${nacos.cmdb.eventTaskInterval:10}")
|
||||||
private int eventTaskInterval;
|
private int eventTaskInterval;
|
||||||
|
|
||||||
@Value("${nacos.cmdb.labelTaskInterval}")
|
@Value("${nacos.cmdb.labelTaskInterval:300}")
|
||||||
private int labelTaskInterval;
|
private int labelTaskInterval;
|
||||||
|
|
||||||
@Value("${nacos.cmdb.loadDataAtStart}")
|
@Value("${nacos.cmdb.loadDataAtStart:false}")
|
||||||
private boolean loadDataAtStart;
|
private boolean loadDataAtStart;
|
||||||
|
|
||||||
public int getDumpTaskInterval() {
|
public int getDumpTaskInterval() {
|
||||||
return dumpTaskInterval;
|
return dumpTaskInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDumpTaskInterval(int dumpTaskInterval) {
|
|
||||||
this.dumpTaskInterval = dumpTaskInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEventTaskInterval() {
|
public int getEventTaskInterval() {
|
||||||
return eventTaskInterval;
|
return eventTaskInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEventTaskInterval(int eventTaskInterval) {
|
|
||||||
this.eventTaskInterval = eventTaskInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLabelTaskInterval() {
|
public int getLabelTaskInterval() {
|
||||||
return labelTaskInterval;
|
return labelTaskInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabelTaskInterval(int labelTaskInterval) {
|
|
||||||
this.labelTaskInterval = labelTaskInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLoadDataAtStart() {
|
public boolean isLoadDataAtStart() {
|
||||||
return loadDataAtStart;
|
return loadDataAtStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadDataAtStart(boolean loadDataAtStart) {
|
|
||||||
this.loadDataAtStart = loadDataAtStart;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -65,10 +65,4 @@ server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
|||||||
# default current work dir
|
# default current work dir
|
||||||
server.tomcat.basedir=
|
server.tomcat.basedir=
|
||||||
|
|
||||||
nacos.naming.distro.taskDispatchThreadCount=1
|
|
||||||
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
|
|
||||||
nacos.naming.expireInstance=true
|
|
||||||
|
@ -39,10 +39,8 @@ 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.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.distro.taskDispatchThreadCount=1
|
|
||||||
nacos.naming.distro.taskDispatchPeriod=200
|
nacos.naming.distro.taskDispatchPeriod=200
|
||||||
nacos.naming.distro.batchSyncKeyCount=1000
|
nacos.naming.distro.batchSyncKeyCount=1000
|
||||||
nacos.naming.distro.initDataRatio=0.9
|
|
||||||
nacos.naming.distro.syncRetryDelay=5000
|
nacos.naming.distro.syncRetryDelay=5000
|
||||||
nacos.naming.data.warmup=true
|
nacos.naming.data.warmup=true
|
||||||
nacos.naming.expireInstance=true
|
nacos.naming.expireInstance=true
|
||||||
|
@ -123,7 +123,7 @@ public class RaftCore {
|
|||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
datums = raftStore.loadDatums(notifier);
|
raftStore.loadDatums(notifier, datums);
|
||||||
|
|
||||||
setTerm(NumberUtils.toLong(raftStore.loadMeta().getProperty("term"), 0L));
|
setTerm(NumberUtils.toLong(raftStore.loadMeta().getProperty("term"), 0L));
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import java.nio.ByteBuffer;
|
|||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nacos
|
* @author nacos
|
||||||
@ -54,9 +54,8 @@ public class RaftStore {
|
|||||||
|
|
||||||
private String cacheDir = UtilsAndCommons.DATA_BASE_DIR + File.separator + "data";
|
private String cacheDir = UtilsAndCommons.DATA_BASE_DIR + File.separator + "data";
|
||||||
|
|
||||||
public synchronized ConcurrentHashMap<String, Datum> loadDatums(RaftCore.Notifier notifier) throws Exception {
|
public synchronized void loadDatums(RaftCore.Notifier notifier, ConcurrentMap<String, Datum> datums) throws Exception {
|
||||||
|
|
||||||
ConcurrentHashMap<String, Datum> datums = new ConcurrentHashMap<>(32);
|
|
||||||
Datum datum;
|
Datum datum;
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
for (File cache : listCaches()) {
|
for (File cache : listCaches()) {
|
||||||
@ -77,7 +76,6 @@ public class RaftStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Loggers.RAFT.info("finish loading all datums, size: {} cost {} ms.", datums.size(), (System.currentTimeMillis() - start));
|
Loggers.RAFT.info("finish loading all datums, size: {} cost {} ms.", datums.size(), (System.currentTimeMillis() - start));
|
||||||
return datums;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Properties loadMeta() throws Exception {
|
public synchronized Properties loadMeta() throws Exception {
|
||||||
|
@ -27,22 +27,19 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class GlobalConfig {
|
public class GlobalConfig {
|
||||||
|
|
||||||
@Value("${nacos.naming.distro.taskDispatchPeriod}")
|
@Value("${nacos.naming.distro.taskDispatchPeriod:200}")
|
||||||
private int taskDispatchPeriod = 2000;
|
private int taskDispatchPeriod = 2000;
|
||||||
|
|
||||||
@Value("${nacos.naming.distro.batchSyncKeyCount}")
|
@Value("${nacos.naming.distro.batchSyncKeyCount:1000}")
|
||||||
private int batchSyncKeyCount = 1000;
|
private int batchSyncKeyCount = 1000;
|
||||||
|
|
||||||
@Value("${nacos.naming.distro.syncRetryDelay}")
|
@Value("${nacos.naming.distro.syncRetryDelay:5000}")
|
||||||
private long syncRetryDelay = 5000L;
|
private long syncRetryDelay = 5000L;
|
||||||
|
|
||||||
@Value("${nacos.naming.distro.taskDispatchThreadCount}")
|
@Value("${nacos.naming.data.warmup:false}")
|
||||||
private int taskDispatchThreadCount = Runtime.getRuntime().availableProcessors();
|
|
||||||
|
|
||||||
@Value("${nacos.naming.data.warmup}")
|
|
||||||
private boolean dataWarmup = false;
|
private boolean dataWarmup = false;
|
||||||
|
|
||||||
@Value("${nacos.naming.expireInstance}")
|
@Value("${nacos.naming.expireInstance:true}")
|
||||||
private boolean expireInstance = true;
|
private boolean expireInstance = true;
|
||||||
|
|
||||||
public int getTaskDispatchPeriod() {
|
public int getTaskDispatchPeriod() {
|
||||||
@ -57,10 +54,6 @@ public class GlobalConfig {
|
|||||||
return syncRetryDelay;
|
return syncRetryDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTaskDispatchThreadCount() {
|
|
||||||
return taskDispatchThreadCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDataWarmup() {
|
public boolean isDataWarmup() {
|
||||||
return dataWarmup;
|
return dataWarmup;
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,3 @@ server.tomcat.accesslog.enabled=true
|
|||||||
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
||||||
# default current work dir
|
# default current work dir
|
||||||
server.tomcat.basedir=
|
server.tomcat.basedir=
|
||||||
|
|
||||||
nacos.naming.distro.taskDispatchThreadCount=1
|
|
||||||
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
|
|
||||||
nacos.naming.expireInstance=true
|
|
||||||
|
@ -18,11 +18,3 @@ server.tomcat.accesslog.enabled=false
|
|||||||
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D
|
||||||
# default current work dir
|
# default current work dir
|
||||||
server.tomcat.basedir=
|
server.tomcat.basedir=
|
||||||
|
|
||||||
nacos.naming.distro.taskDispatchThreadCount=1
|
|
||||||
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
|
|
||||||
nacos.naming.expireInstance=true
|
|
||||||
|
Loading…
Reference in New Issue
Block a user