You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/11/14 10:02:46 UTC

[GitHub] [zookeeper] eolivelli commented on a change in pull request #1491: ZOOKEEPER-3964: Introduce RocksDB snap and implement change data capture to enable incremental snapshot

eolivelli commented on a change in pull request #1491:
URL: https://github.com/apache/zookeeper/pull/1491#discussion_r523401432



##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/persistence/SnapshotFactory.java
##########
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.zookeeper.server.persistence;
+
+import java.io.File;
+import java.io.IOException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class SnapshotFactory {
+    private static final Logger LOG = LoggerFactory.getLogger(SnapshotFactory.class);
+
+    public static final String ZOOKEEPER_SNAPSHOT_NAME = "zookeeper.snapshotName";
+
+    public static boolean shouldRecordTransactionChanges() {
+        String snapName = System.getProperty(ZOOKEEPER_SNAPSHOT_NAME);

Review comment:
       Is it possible  to make this check more object oriented?
   If in the future we are going to add new implementations this check will return possibly unwanted  results.
   
   I am already imagining a no-op SnapLog to run an in memory only ZK node for unit tests

##########
File path: zookeeper-server/src/test/java/org/apache/zookeeper/server/DataTreeTest.java
##########
@@ -301,7 +335,9 @@ public void run() {
             }
         };
 
-        tree.serialize(oa, "test");
+        SnapShot snapLog = new FileSnap(null, oa);

Review comment:
       What  about implementing AutoCloseable and use try-with-resources ?

##########
File path: zookeeper-server/src/test/java/org/apache/zookeeper/server/ReferenceCountedACLCacheTest.java
##########
@@ -284,4 +319,29 @@ private Long convertACLsNTimes(ReferenceCountedACLCache cache, List<ACL> acl, in
         return acl1;
     }
 
+    private void serializeAndDeserializeACL(ReferenceCountedACLCache cache,
+                                            ReferenceCountedACLCache deserializedCache) throws IOException {
+        if (System.getProperty(SnapshotFactory.ZOOKEEPER_SNAPSHOT_NAME).equals(
+                FileSnap.class.getName())) {
+            LOG.info("Testing FileSnap:");
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            BinaryOutputArchive archive = BinaryOutputArchive.getArchive(baos);
+            FileSnap snapLog = new FileSnap(null, archive);
+            snapLog.serializeACL(cache);
+            BinaryInputArchive inArchive = BinaryInputArchive.getArchive(new ByteArrayInputStream(baos.toByteArray()));
+            snapLog = new FileSnap(null, inArchive);
+            snapLog.deserializeACL(deserializedCache);
+            snapLog.close();
+        } else {
+            LOG.info("Testing RocksDBSnap:");

Review comment:
       Please test for the expected value, in the future we will have new implementations




----------------------------------------------------------------
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:
users@infra.apache.org