You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by "ywj1352 (via GitHub)" <gi...@apache.org> on 2023/06/14 13:47:04 UTC

[GitHub] [shenyu] ywj1352 commented on a diff in pull request #4735: [type:feat] Admin sync data

ywj1352 commented on code in PR #4735:
URL: https://github.com/apache/shenyu/pull/4735#discussion_r1229650326


##########
shenyu-discovery/shenyu-discovery-zookeeper/src/main/java/org/apache/shenyu/discovery/zookeeper/ZookeeperDiscoveryService.java:
##########
@@ -112,59 +116,81 @@ private void createOrUpdate(final String key, final String value, final CreateMo
     @Override
     public void watcher(final String key, final DataChangedEventListener listener) {
         try {
-            this.client.getData().usingWatcher(new CuratorWatcher() {
-                @Override
-                public void process(final WatchedEvent watchedEvent) throws Exception {
-                    if (Objects.nonNull(listener)) {
-                        String path = Objects.isNull(watchedEvent.getPath()) ? "" : watchedEvent.getPath();
-                        if (StringUtils.isNoneBlank(path)) {
-                            client.getData().usingWatcher(this).forPath(path);
-                            byte[] ret = client.getData().forPath(key);
-                            String data = Objects.isNull(ret) ? null : new String(ret, StandardCharsets.UTF_8);
-                            LOGGER.info("shenyu ZookeeperDiscoveryService onChange key={}", path);
-                            listener.onChange(buildDataChangedEvent(path, data, watchedEvent));
-                        }
+            TreeCache treeCache = new TreeCache(client, key);
+            TreeCacheListener treeCacheListener = (curatorFramework, event) -> {
+                ChildData data = event.getData();
+                DataChangedEvent dataChangedEvent;
+                if (Objects.nonNull(data) && Objects.nonNull(data.getData())) {
+                    String currentPath = data.getPath();
+                    Stat stat = data.getStat();
+                    boolean isEphemeral = stat != null && stat.getEphemeralOwner() > 0;

Review Comment:
   done



##########
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/AbstractListDataChangedListener.java:
##########
@@ -248,12 +249,14 @@ public void onRuleChanged(final List<RuleData> changed, final DataEventTypeEnum
         LOG.debug("[DataChangedListener] RuleChanged {}", changeData.getRuleDataId());
     }
 
+    // fixme: 12/6/2023 需要 验证 暂时只是 编译不报错了

Review Comment:
   done



-- 
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: notifications-unsubscribe@shenyu.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org