You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by jx...@apache.org on 2018/01/30 02:05:18 UTC
[06/11] helix git commit: [HELIX-673] Fix inconsistent behavior in
ZKCacheBaseDataAccessor
[HELIX-673] Fix inconsistent behavior in ZKCacheBaseDataAccessor
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/751f023e
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/751f023e
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/751f023e
Branch: refs/heads/master
Commit: 751f023e12c9f27c7e164c6ab1625b31e392ce5c
Parents: 9d590f4
Author: Junkai Xue <jx...@linkedin.com>
Authored: Thu Jan 25 18:12:11 2018 -0800
Committer: Junkai Xue <jx...@linkedin.com>
Committed: Mon Jan 29 18:05:04 2018 -0800
----------------------------------------------------------------------
.../manager/zk/ZkCacheBaseDataAccessor.java | 24 +++++++++++---------
1 file changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/751f023e/helix-core/src/main/java/org/apache/helix/manager/zk/ZkCacheBaseDataAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkCacheBaseDataAccessor.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkCacheBaseDataAccessor.java
index 18abe91..3a7553f 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkCacheBaseDataAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkCacheBaseDataAccessor.java
@@ -32,6 +32,7 @@ import java.util.concurrent.locks.ReentrantLock;
import org.I0Itec.zkclient.DataUpdater;
import org.I0Itec.zkclient.IZkChildListener;
import org.I0Itec.zkclient.IZkDataListener;
+import org.I0Itec.zkclient.exception.ZkBadVersionException;
import org.I0Itec.zkclient.exception.ZkNoNodeException;
import org.I0Itec.zkclient.serialize.ZkSerializer;
import org.apache.helix.AccessOption;
@@ -257,25 +258,26 @@ public class ZkCacheBaseDataAccessor<T> implements HelixPropertyStore<T> {
String serverPath = prependChroot(clientPath);
Cache<T> cache = getCache(serverPath);
- if (cache != null) {
- try {
+ boolean success = false;
+ try {
+ if (cache != null) {
cache.lockWrite();
ZkBaseDataAccessor<T>.AccessResult result =
_baseAccessor.doSet(serverPath, data, expectVersion, options);
- boolean success = result._retCode == RetCode.OK;
+ success = result._retCode == RetCode.OK;
updateCache(cache, result._pathCreated, success, serverPath, data, result._stat);
-
- return success;
- } catch (Exception e) {
- return false;
- } finally {
+ } else {
+ // no cache
+ success = _baseAccessor.set(serverPath, data, expectVersion, options);
+ }
+ } catch (Exception e) {
+ } finally {
+ if (cache != null) {
cache.unlockWrite();
}
}
-
- // no cache
- return _baseAccessor.set(serverPath, data, expectVersion, options);
+ return success;
}
@Override