You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by eolivelli <gi...@git.apache.org> on 2018/10/06 12:43:24 UTC
[GitHub] zookeeper pull request #632: [ZOOKEEPER-3150] Add tree digest check and veri...
Github user eolivelli commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/632#discussion_r223181364
--- Diff: zookeeper-server/src/main/java/org/apache/zookeeper/server/DataTree.java ---
@@ -1521,4 +1562,179 @@ public boolean removeWatch(String path, WatcherType type, Watcher watcher) {
public ReferenceCountedACLCache getReferenceCountedAclCache() {
return aclCache;
}
+
+ /**
+ * Add the digest to the historical list, and update the latest zxid digest.
+ */
+ private void logZxidDigest(long zxid, long digest) {
+ ZxidDigest zxidDigest = new ZxidDigest(zxid, DigestCalculator.DIGEST_VERSION, digest);
+ lastProcessedZxidDigest = zxidDigest;
+ if (zxidDigest.zxid % 128 == 0) {
+ synchronized (digestLog) {
+ digestLog.add(zxidDigest);
+ if (digestLog.size() > DIGEST_LOG_LIMIT) {
+ digestLog.poll();
+ }
+ }
+ }
+ }
+
+ /**
+ * Serializing the digest to snapshot, this is done after the data tree
+ * is being serialized, so when we replay the txns and it hits this zxid
+ * we know we should be in a non-fuzzy state, and have the same digest.
+ *
+ * @param oa the output stream to write to
+ * @return true if the digest is serialized successfully
+ */
+ public Boolean serializeZxidDigest(OutputArchive oa) throws IOException {
--- End diff --
Nit: boolean not Boolean
---