feat: ignore event whose modify time is out of date#337
Open
24kpure wants to merge 1 commit intospring-cloud:mainfrom
Open
feat: ignore event whose modify time is out of date#33724kpure wants to merge 1 commit intospring-cloud:mainfrom
24kpure wants to merge 1 commit intospring-cloud:mainfrom
Conversation
Author
|
@spencergibb Review,please. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Author
|
? |
spencergibb
requested changes
Jan 17, 2025
Member
spencergibb
left a comment
There was a problem hiding this comment.
Please add a test so we can prevent regressions in the future.
| return; | ||
| } | ||
|
|
||
| // ignore event whose modify time is out of date |
Author
There was a problem hiding this comment.
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); |
Member
There was a problem hiding this comment.
This should be configurable. Can you say why you chose 1 minute as the definition of out of date?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #334