michaellx1057 commented on code in PR #18641:
URL:
https://github.com/apache/dolphinscheduler/pull/18641#discussion_r4035333161
##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-etcd/src/main/java/org/apache/dolphinscheduler/plugin/registry/etcd/EtcdRegistry.java:
##########
@@ -433,12 +433,18 @@ private Event toEvent(final WatchEvent watchEvent, final
String watchedPath) {
break;
}
final KeyValue keyValue = watchEvent.getKeyValue();
+ final KeyValue dataKeyValue;
+ if (eventType == Event.Type.REMOVE) {
+ dataKeyValue = watchEvent.getPrevKV();
+ } else {
+ dataKeyValue = keyValue;
+ }
return Event.builder()
.type(eventType)
.watchedPath(watchedPath)
.eventPath(Optional.ofNullable(keyValue).map(kv ->
kv.getKey().toString(StandardCharsets.UTF_8))
.orElse(null))
- .eventData(Optional.ofNullable(keyValue).map(kv ->
kv.getValue().toString(StandardCharsets.UTF_8))
+ .eventData(Optional.ofNullable(dataKeyValue).map(kv ->
kv.getValue().toString(StandardCharsets.UTF_8))
Review Comment:
Thanks for the suggestion. I've inlined the value selection into `eventData`.
##########
dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/Event.java:
##########
@@ -33,6 +33,7 @@ public class Event {
// The full path where the event was generated
private final String eventPath;
// The value corresponding to the path
+ // ADD/UPDATE carry the current value; REMOVE carries the last value
before deletion.
Review Comment:
Thanks, the added comment has been removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]