fix: fix merge confilt

This commit is contained in:
chuntaojun 2020-03-09 15:38:03 +08:00
commit 0a325bf9c7
4 changed files with 41 additions and 30 deletions

View File

@ -40,7 +40,10 @@ import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.LinkedBlockingQueue;
/**
* A consistency protocol algorithm called <b>Distro</b>
@ -59,18 +62,6 @@ import java.util.concurrent.*;
@org.springframework.stereotype.Service("distroConsistencyService")
public class DistroConsistencyServiceImpl implements EphemeralConsistencyService {
private ScheduledExecutorService executor = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setDaemon(true);
t.setName("com.alibaba.nacos.naming.distro.notifier");
return t;
}
});
@Autowired
private DistroMapper distroMapper;
@ -80,9 +71,6 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
@Autowired
private TaskDispatcher taskDispatcher;
@Autowired
private DataSyncer dataSyncer;
@Autowired
private Serializer serializer;
@ -97,7 +85,7 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
private boolean initialized = false;
public volatile Notifier notifier = new Notifier();
private volatile Notifier notifier = new Notifier();
private LoadDataTask loadDataTask = new LoadDataTask();
@ -107,19 +95,8 @@ public class DistroConsistencyServiceImpl implements EphemeralConsistencyService
@PostConstruct
public void init() {
GlobalExecutor.submit(new Runnable() {
@Override
public void run() {
try {
load();
} catch (Exception e) {
Loggers.DISTRO.error("load data failed.", e);
}
}
});
executor.submit(notifier);
GlobalExecutor.submit(loadDataTask);
GlobalExecutor.submitDistroNotifyTask(notifier);
}
private class LoadDataTask implements Runnable {

View File

@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.nacos.naming.boot.RunningConfig;
import com.alibaba.nacos.naming.boot.SpringContext;
import com.alibaba.nacos.naming.consistency.KeyBuilder;
import com.alibaba.nacos.naming.core.DistroMapper;
import com.alibaba.nacos.naming.core.Instance;
import com.alibaba.nacos.naming.core.Service;
@ -65,7 +66,7 @@ public class ClientBeatCheckTask implements Runnable {
}
public String taskKey() {
return service.getName();
return KeyBuilder.buildServiceMetaKey(service.getNamespaceId(), service.getName());
}
@Override

View File

@ -125,6 +125,18 @@ public class GlobalExecutor {
}
);
private static ScheduledExecutorService distroNotifyExecutor = new ScheduledThreadPoolExecutor(1, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setDaemon(true);
t.setName("com.alibaba.nacos.naming.distro.notifier");
return t;
}
});
public static void submitDataSync(Runnable runnable, long delay) {
dataSyncExecutor.schedule(runnable, delay, TimeUnit.MILLISECONDS);
}
@ -178,6 +190,10 @@ public class GlobalExecutor {
executorService.schedule(runnable, delay, TimeUnit.MILLISECONDS);
}
public static void submitDistroNotifyTask(Runnable runnable) {
distroNotifyExecutor.submit(runnable);
}
public static void submitServiceUpdate(Runnable runnable) {
serviceUpdateExecutor.execute(runnable);
}

View File

@ -0,0 +1,17 @@
192.168.16.101 - - [09/Mar/2020:12:02:15 +0800] "GET /nacos/v1/cs/health HTTP/1.1" 200 2 147
127.0.0.1 - - [09/Mar/2020:12:02:15 +0800] "PUT /nacos/v1/ns/operator/switches?entry=overriddenServerStatus&value=UP HTTP/1.1" 200 2 195
127.0.0.1 - - [09/Mar/2020:12:02:15 +0800] "PUT /nacos/v1/ns/operator/switches?entry=overriddenServerStatus&value=UP HTTP/1.1" 200 2 197
127.0.0.1 - - [09/Mar/2020:12:02:15 +0800] "PUT /nacos/v1/ns/operator/switches?entry=overriddenServerStatus&value=UP HTTP/1.1" 200 2 198
127.0.0.1 - - [09/Mar/2020:12:02:15 +0800] "PUT /nacos/v1/ns/operator/switches?entry=autoChangeHealthCheckEnabled&value=false HTTP/1.1" 200 2 6
127.0.0.1 - - [09/Mar/2020:12:02:15 +0800] "PUT /nacos/v1/ns/operator/switches?entry=autoChangeHealthCheckEnabled&value=false HTTP/1.1" 200 2 8
127.0.0.1 - - [09/Mar/2020:12:02:15 +0800] "PUT /nacos/v1/ns/operator/switches?entry=autoChangeHealthCheckEnabled&value=false HTTP/1.1" 200 2 10
127.0.0.1 - - [09/Mar/2020:12:02:16 +0800] "GET /nacos/v1/ns/operator/metrics?app=unknown&encoding=UTF-8&namespaceId=public HTTP/1.1" 200 187 62
127.0.0.1 - - [09/Mar/2020:12:02:16 +0800] "GET /nacos/v1/ns/operator/metrics?app=unknown&encoding=UTF-8&namespaceId=public HTTP/1.1" 200 185 62
127.0.0.1 - - [09/Mar/2020:12:02:16 +0800] "GET /nacos/v1/ns/operator/metrics?app=unknown&encoding=UTF-8&namespaceId=public HTTP/1.1" 200 185 62
127.0.0.1 - - [09/Mar/2020:12:02:16 +0800] "GET /nacos/v1/ns/service/list?app=unknown&pageSize=10&groupName=DEFAULT_GROUP&encoding=UTF-8&namespaceId=public&pageNo=1 HTTP/1.1" 200 32 7
127.0.0.1 - - [09/Mar/2020:12:02:16 +0800] "GET /nacos/v1/ns/service/list?app=unknown&pageSize=10&groupName=DEFAULT_GROUP&encoding=UTF-8&namespaceId=public&pageNo=1 HTTP/1.1" 200 32 7
127.0.0.1 - - [09/Mar/2020:12:02:16 +0800] "POST /nacos/v1/ns/instance?app=unknown&metadata=%7B%7D&ip=127.0.0.1&weight=1.0&ephemeral=true&serviceName=DEFAULT_GROUP%40%40jinhanb9I1B.B3ETP.net&encoding=UTF-8&groupName=DEFAULT_GROUP&namespaceId=public&port=8080&enable=true&healthy=true&clusterName=c1 HTTP/1.1" 200 2 42
127.0.0.1 - - [09/Mar/2020:12:02:16 +0800] "POST /nacos/v1/ns/instance?app=unknown&metadata=%7B%7D&ip=127.0.0.1&weight=1.0&ephemeral=true&serviceName=DEFAULT_GROUP%40%40jinhan3RA7V.5g5rC.net&encoding=UTF-8&groupName=DEFAULT_GROUP&namespaceId=public&port=8080&enable=true&healthy=true&clusterName=c1 HTTP/1.1" 200 2 46
127.0.0.1 - - [09/Mar/2020:12:02:16 +0800] "GET /nacos/v1/ns/instance/list?app=unknown&healthyOnly=false&namespaceId=public&clientIP=127.0.0.1&serviceName=DEFAULT_GROUP%40%40jinhan3RA7V.5g5rC.net&udpPort=65151&encoding=UTF-8 HTTP/1.1" 200 270 13
127.0.0.1 - - [09/Mar/2020:12:02:16 +0800] "GET /nacos/v1/ns/instance/list?app=unknown&healthyOnly=false&namespaceId=public&clientIP=127.0.0.1&serviceName=DEFAULT_GROUP%40%40jinhanb9I1B.B3ETP.net&udpPort=65150&encoding=UTF-8 HTTP/1.1" 200 544 17
127.0.0.1 - - [09/Mar/2020:12:02:16 +0800] "DELETE /nacos/v1/ns/instance?app=unknown&namespaceId=public&port=8080&clusterName=c1&ip=127.0.0.1&ephemeral=true&serviceName=DEFAULT_GROUP%40%40jinhan3RA7V.5g5rC.net&encoding=UTF-8 HTTP/1.1" 200 2 5