peterxcli commented on code in PR #8503:
URL: https://github.com/apache/ozone/pull/8503#discussion_r2148489921


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/SnapshotDiffJob.java:
##########
@@ -315,13 +316,19 @@ public Class<SnapshotDiffJob> getTypeClass() {
     }
 
     @Override
-    public byte[] toPersistedFormatImpl(SnapshotDiffJob object) throws 
IOException {
-      return MAPPER.writeValueAsBytes(object);
+    public byte[] toPersistedFormat(SnapshotDiffJob object) {

Review Comment:
   @szetszwo I’m not sure when it’s appropriate to override toPersistedFormat 
or toPersistedFormatImpl in a Codec implementation—their use seems inconsistent 
across the codebase.



##########
hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmSnapshotDiffJobCodec.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.hadoop.ozone.om.helpers;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.hadoop.hdds.utils.db.Codec;
+import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.JobStatus;
+import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.SubStatus;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Testing serialization of SnapshotDiffJobCodec objects to/from RocksDB.
+ */
+public class TestOmSnapshotDiffJobCodec {
+  private final OldSnapshotDiffJobCodecForTesting oldCodec
+      = new OldSnapshotDiffJobCodecForTesting();
+  private final Codec<SnapshotDiffJob> newCodec = SnapshotDiffJob.getCodec();

Review Comment:
   nit:
   ```suggestion
     private final SnapshotDiffJobCodec newCodec = new SnapshotDiffJobCodec();
   ```



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/SnapshotDiffJob.java:
##########
@@ -315,13 +316,19 @@ public Class<SnapshotDiffJob> getTypeClass() {
     }
 
     @Override
-    public byte[] toPersistedFormatImpl(SnapshotDiffJob object) throws 
IOException {
-      return MAPPER.writeValueAsBytes(object);
+    public byte[] toPersistedFormat(SnapshotDiffJob object) {

Review Comment:
   but I think this is ok as most of the codec do implement this.



##########
hadoop-ozone/common/src/test/java/org/apache/hadoop/ozone/om/helpers/TestOmSnapshotDiffJobCodec.java:
##########
@@ -0,0 +1,57 @@
+package org.apache.hadoop.ozone.om.helpers;
+
+import org.apache.hadoop.hdds.utils.db.Codec;
+import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.JobStatus;
+import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.SubStatus;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+/**
+ * Testing serialization of SnapshotDiffJobCodec objects to/from RocksDB.
+ */
+public class TestOmSnapshotDiffJobCodec {
+  private final OldSnapshotDiffJobCodecForTesting oldCodec
+      = new OldSnapshotDiffJobCodecForTesting();
+  private final Codec<SnapshotDiffJob> newCodec = SnapshotDiffJob.getCodec();
+
+  @Test
+  public void testOldJsonSerializedDataCanBeReadByNewCodec() throws Exception {

Review Comment:
   I was just wondering: does the fallback have to be triggered when 
`newCodec.fromPersistedFormatImpl(oldFormatData)` is called in this test, since 
the Jackson and Protobuf formats are incompatible? Or could the Protobuf codec 
parse the Jackson-encoded binary, making the fallback merely a safeguard?
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to