#502 Fix error log print
This commit is contained in:
parent
0e76f55a3f
commit
cc1f6647b0
@ -16,6 +16,7 @@
|
||||
package com.alibaba.nacos.naming.consistency.persistent.simpleraft;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.naming.boot.RunningConfig;
|
||||
import com.alibaba.nacos.naming.misc.HttpClient;
|
||||
import com.alibaba.nacos.naming.misc.Loggers;
|
||||
import com.alibaba.nacos.naming.misc.NetUtils;
|
||||
@ -43,6 +44,8 @@ public class PeerSet {
|
||||
|
||||
private Set<String> sites = new HashSet<>();
|
||||
|
||||
private boolean ready = false;
|
||||
|
||||
public PeerSet() {
|
||||
}
|
||||
|
||||
@ -57,6 +60,10 @@ public class PeerSet {
|
||||
return sites;
|
||||
}
|
||||
|
||||
public boolean isReady() {
|
||||
return ready;
|
||||
}
|
||||
|
||||
public void add(List<String> servers) {
|
||||
for (String server : servers) {
|
||||
RaftPeer peer = new RaftPeer();
|
||||
@ -71,6 +78,10 @@ public class PeerSet {
|
||||
local.voteFor = NetUtils.localServer();
|
||||
|
||||
}
|
||||
|
||||
if (RunningConfig.getServerPort() > 0) {
|
||||
ready = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(List<String> servers) {
|
||||
|
@ -371,6 +371,11 @@ public class RaftCore {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
if (!peers.isReady()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RaftPeer local = peers.local();
|
||||
local.leaderDueMs -= GlobalExecutor.TICK_PERIOD_MS;
|
||||
if (local.leaderDueMs > 0) {
|
||||
@ -470,6 +475,10 @@ public class RaftCore {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!peers.isReady()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RaftPeer local = peers.local();
|
||||
local.heartbeatDueMs -= GlobalExecutor.TICK_PERIOD_MS;
|
||||
if (local.heartbeatDueMs > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user