-
Notifications
You must be signed in to change notification settings - Fork 412
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
base: main
Are you sure you want to change the base?
feat: ignore event whose modify time is out of date #337
Conversation
@spencergibb Review,please. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
? |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
fix #334