Browse Source

[Improvement-14658][etcd] Distinguish between add and update by using pre kv (#14659)

Co-authored-by: eye <eye.gu@aloudata.com>
3.2.1-prepare
eye-gu 10 months ago committed by GitHub
parent
commit
3148dba7a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-etcd/src/main/java/org/apache/dolphinscheduler/plugin/registry/etcd/EtcdRegistry.java

9
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-etcd/src/main/java/org/apache/dolphinscheduler/plugin/registry/etcd/EtcdRegistry.java

@ -151,7 +151,8 @@ public class EtcdRegistry implements Registry {
public boolean subscribe(String path, SubscribeListener listener) {
try {
ByteSequence watchKey = byteSequence(path);
WatchOption watchOption = WatchOption.newBuilder().isPrefix(true).build();
WatchOption watchOption =
WatchOption.newBuilder().withPrevKV(true).isPrefix(true).build();
watcherMap.computeIfAbsent(path,
$ -> client.getWatchClient().watch(watchKey, watchOption, watchResponse -> {
for (WatchEvent event : watchResponse.getEvents()) {
@ -352,7 +353,11 @@ public class EtcdRegistry implements Registry {
switch (event.getEventType()) {
case PUT:
type(Type.ADD);
if (event.getPrevKV().getKey().isEmpty()) {
type(Type.ADD);
} else {
type(Type.UPDATE);
}
break;
case DELETE:
type(Type.REMOVE);

Loading…
Cancel
Save