You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2014/05/23 14:49:12 UTC
[1/3] git commit: comment udpate
Repository: curator
Updated Branches:
refs/heads/CURATOR-107 4e548a29e -> 0dcf83357
comment udpate
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/290186af
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/290186af
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/290186af
Branch: refs/heads/CURATOR-107
Commit: 290186af13dca06fd15868b422583dfdae5b594e
Parents: 4e548a2
Author: randgalt <ra...@apache.org>
Authored: Fri May 23 07:47:30 2014 -0500
Committer: randgalt <ra...@apache.org>
Committed: Fri May 23 07:47:30 2014 -0500
----------------------------------------------------------------------
.../org/apache/curator/framework/recipes/locks/LockInternals.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/290186af/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
index 812cfd8..706b242 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
@@ -296,7 +296,7 @@ public class LockInternals
{
try
{
- // use getData instead of exists to avoid leaving unneeded watchers which is a type of resource leak
+ // use getData() instead of exists() to avoid leaving unneeded watchers which is a type of resource leak
client.getData().usingWatcher(watcher).forPath(previousSequencePath);
if ( millisToWait != null )
{
[3/3] git commit: use getData() instead of exists() to avoid leaving
unneeded watchers which is a type of resource leak. However,
this might have performance affects. Therefore,
added system proprety "curator-path-children-cache-use-exists" to use the ol
Posted by ra...@apache.org.
use getData() instead of exists() to avoid leaving unneeded watchers which is a type of resource leak. However, this might have
performance affects. Therefore, added system proprety "curator-path-children-cache-use-exists" to use the old behavior. i.e.
add -Dcurator-path-children-cache-use-exists=true or call System.setProperty("curator-path-children-cache-use-exists", "true") to
use the old behavior of calling exists() instead.
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/0dcf8335
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/0dcf8335
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/0dcf8335
Branch: refs/heads/CURATOR-107
Commit: 0dcf8335745003c578dbaf09b3be658b89b4a045
Parents: 91d6503
Author: randgalt <ra...@apache.org>
Authored: Fri May 23 07:48:11 2014 -0500
Committer: randgalt <ra...@apache.org>
Committed: Fri May 23 07:48:11 2014 -0500
----------------------------------------------------------------------
.../recipes/cache/PathChildrenCache.java | 30 ++++++++------------
1 file changed, 12 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/0dcf8335/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
index 855d060..dc23e04 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
@@ -89,6 +89,8 @@ public class PathChildrenCache implements Closeable
private static final ChildData NULL_CHILD_DATA = new ChildData(null, null, null);
+ private static final boolean USE_EXISTS = Boolean.getBoolean("curator-path-children-cache-use-exists");
+
private final Watcher childrenWatcher = new Watcher()
{
@Override
@@ -508,39 +510,31 @@ public class PathChildrenCache implements Closeable
void getDataAndStat(final String fullPath) throws Exception
{
- BackgroundCallback existsCallback = new BackgroundCallback()
+ BackgroundCallback callback = new BackgroundCallback()
{
@Override
public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
{
- applyNewData(fullPath, event.getResultCode(), event.getStat(), null);
+ applyNewData(fullPath, event.getResultCode(), event.getStat(), cacheData ? event.getData() : null);
}
};
- BackgroundCallback getDataCallback = new BackgroundCallback()
+ if ( USE_EXISTS && !cacheData )
{
- @Override
- public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
- {
- applyNewData(fullPath, event.getResultCode(), event.getStat(), event.getData());
- }
- };
-
- if ( cacheData )
+ client.checkExists().usingWatcher(dataWatcher).inBackground(callback).forPath(fullPath);
+ }
+ else
{
- if ( dataIsCompressed )
+ // always use getData() instead of exists() to avoid leaving unneeded watchers which is a type of resource leak
+ if ( dataIsCompressed && cacheData )
{
- client.getData().decompressed().usingWatcher(dataWatcher).inBackground(getDataCallback).forPath(fullPath);
+ client.getData().decompressed().usingWatcher(dataWatcher).inBackground(callback).forPath(fullPath);
}
else
{
- client.getData().usingWatcher(dataWatcher).inBackground(getDataCallback).forPath(fullPath);
+ client.getData().usingWatcher(dataWatcher).inBackground(callback).forPath(fullPath);
}
}
- else
- {
- client.checkExists().usingWatcher(dataWatcher).inBackground(existsCallback).forPath(fullPath);
- }
}
/**
[2/3] git commit: use getData() instead of exists() to avoid leaving
unneeded watchers which is a type of resource leak
Posted by ra...@apache.org.
use getData() instead of exists() to avoid leaving unneeded watchers which is a type of resource leak
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/91d65037
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/91d65037
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/91d65037
Branch: refs/heads/CURATOR-107
Commit: 91d65037bf28947b5b28b75ec83614bb70a3e12a
Parents: 290186a
Author: randgalt <ra...@apache.org>
Authored: Fri May 23 07:47:56 2014 -0500
Committer: randgalt <ra...@apache.org>
Committed: Fri May 23 07:47:56 2014 -0500
----------------------------------------------------------------------
.../org/apache/curator/framework/recipes/leader/LeaderLatch.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/91d65037/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
index ecdd903..88456af 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
@@ -519,7 +519,8 @@ public class LeaderLatch implements Closeable
}
}
};
- client.checkExists().usingWatcher(watcher).inBackground(callback).forPath(ZKPaths.makePath(latchPath, watchPath));
+ // use getData() instead of exists() to avoid leaving unneeded watchers which is a type of resource leak
+ client.getData().usingWatcher(watcher).inBackground(callback).forPath(ZKPaths.makePath(latchPath, watchPath));
}
}