i3wangyi commented on a change in pull request #688: Fix the watcher leakage
issue
URL: https://github.com/apache/helix/pull/688#discussion_r372120634
##########
File path:
helix-core/src/main/java/org/apache/helix/manager/zk/zookeeper/ZkClient.java
##########
@@ -145,32 +145,28 @@ public int hashCode() {
private class ZkPathStatRecord {
private final String _path;
- private Stat _stat = null;
- private boolean _checked = false;
+ private AtomicBoolean _isChecked = new AtomicBoolean(false);
- public ZkPathStatRecord(String path) {
+ ZkPathStatRecord(String path) {
_path = path;
}
- public boolean pathExists() {
- return _stat != null;
- }
-
- public boolean pathChecked() {
- return _checked;
+ boolean isPathChecked() {
+ return _isChecked.get();
}
/*
* Note this method is not thread safe.
*/
- public void recordPathStat(Stat stat, OptionalLong notificationTime) {
- _checked = true;
- _stat = stat;
-
- if (_monitor != null && stat != null && notificationTime.isPresent()) {
+ void recordPathStat(Stat stat, long notificationTime) {
+ if (isPathChecked()) {
+ return;
+ }
+ _isChecked.set(true);
+ if (_monitor != null && stat != null) {
long updateTime = Math.max(stat.getCtime(), stat.getMtime());
- if (notificationTime.getAsLong() > updateTime) {
- _monitor.recordDataPropagationLatency(_path,
notificationTime.getAsLong() - updateTime);
+ if (notificationTime > updateTime) {
+ _monitor.recordDataPropagationLatency(_path, notificationTime -
updateTime);
Review comment:
The latest changes will not need to touch the existing codes too much, so
it's no longer valid. Could you take another look, thanks?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]