Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ignore event whose modify time is out of date #337

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

24kpure
Copy link

@24kpure 24kpure commented Nov 13, 2024

fix #334

@24kpure
Copy link
Author

24kpure commented Nov 13, 2024

@spencergibb Review,please.

@24kpure

This comment has been minimized.

@24kpure

This comment has been minimized.

@24kpure
Copy link
Author

24kpure commented Jan 17, 2025

?

Copy link
Member

@spencergibb spencergibb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test so we can prevent regressions in the future.

}

// ignore event whose modify time is out of date
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "out of date"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every exist node in zookeeper will trigger a add event. Maybe we can ignore these add event for we have get all data when start up. That's my test:

    @Override
    public void childEvent(CuratorFramework client, TreeCacheEvent event)
            throws Exception {
        TreeCacheEvent.Type eventType = event.getType();
        if (eventType != NODE_ADDED && eventType != NODE_REMOVED
                && eventType != NODE_UPDATED) {
            return;
        }

        String path = event.getData().getPath();
        long currentTime = System.currentTimeMillis();
        long validTime = currentTime - TimeUnit.MINUTES.toMillis(1);
        if (eventType == NODE_ADDED
                && event.getData().getStat().getMtime() < validTime) {
            log.info("currentTime:{},dataModifyTime:{},difference:{} second", currentTime, event.getData().getStat().getMtime(),
                    (currentTime - event.getData().getStat().getMtime()) / 1000);
            return;
        }
}

And loginfo is below

currentTime:1737443876150,dataModifyTime:1709799075357,difference:27644800 second
currentTime:1737443876152,dataModifyTime:1701227490791,difference:36216385 second
currentTime:1737443876153,dataModifyTime:1672281805849,difference:65162070 second
currentTime:1737443876154,dataModifyTime:1734484683314,difference:2959192 second
currentTime:1737443876154,dataModifyTime:1734404672179,difference:3039203 second
currentTime:1737443876155,dataModifyTime:1733982210881,difference:3461665 second


// ignore event whose modify time is out of date
String path = event.getData().getPath();
long validTime = System.currentTimeMillis() - TimeUnit.MINUTES.toMillis(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be configurable. Can you say why you chose 1 minute as the definition of out of date?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected notice for zk data change
3 participants