Myasuka commented on a change in pull request #16035:
URL: https://github.com/apache/flink/pull/16035#discussion_r654110979



##########
File path: 
flink-state-backends/flink-statebackend-changelog/src/test/java/org/apache/flink/state/changelog/StateChangeLoggerTestBase.java
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.flink.state.changelog;
+
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.runtime.state.KeyGroupRange;
+import org.apache.flink.runtime.state.changelog.SequenceNumber;
+import org.apache.flink.runtime.state.changelog.StateChangelogWriter;
+import org.apache.flink.runtime.state.heap.InternalKeyContextImpl;
+import 
org.apache.flink.state.changelog.AbstractStateChangeLogger.StateChangeOperation;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+
+import static 
org.apache.flink.state.changelog.AbstractStateChangeLogger.StateChangeOperation.METADATA;
+import static org.junit.Assert.assertEquals;
+
+abstract class StateChangeLoggerTestBase<Namespace> {
+    /** A basic test for appending the metadata on first state access. */
+    @Test
+    public void testMetadataOperationLogged() throws IOException {
+        TestingStateChangelogWriter writer = new TestingStateChangelogWriter();
+        InternalKeyContextImpl<String> keyContext =
+                new InternalKeyContextImpl<>(KeyGroupRange.of(1, 1000), 1000);
+        StateChangeLogger<String, Namespace> logger = getLogger(writer, 
keyContext);
+
+        List<Tuple2<Integer, StateChangeOperation>> expectedAppends = new 
ArrayList<>();
+        expectedAppends.add(
+                Tuple2.of(-1 /* see AbstractStateChangeLogger#COMMON_KEY_GROUP 
*/, METADATA));

Review comment:
       It seems you did not change the magic number to `COMMON_KEY_GROUP` here 
in test code.

##########
File path: 
flink-state-backends/flink-statebackend-changelog/src/main/java/org/apache/flink/state/changelog/ChangelogKeyedStateBackend.java
##########
@@ -339,6 +343,13 @@ public void notifyCheckpointAborted(long checkpointId) 
throws Exception {
                             stateDesc.getClass(), this.getClass());
             throw new FlinkRuntimeException(message);
         }
+        RegisteredKeyValueStateBackendMetaInfo<N, S> meta =

Review comment:
       To be honest, the raw use of `RegisteredKeyValueStateBackendMetaInfo` 
constructor makes me a bit confused. 
   I have tried to change `RegisteredKeyValueStateBackendMetaInfo<N, S>` to 
`RegisteredKeyValueStateBackendMetaInfo<N, S, SEV>` and it dose not need to 
change many files.  Or shall we change the code below?
   ~~~ java
           RegisteredKeyValueStateBackendMetaInfo<N, SV> meta =
                   new RegisteredKeyValueStateBackendMetaInfo(
                           stateDesc.getType(),
                           stateDesc.getName(),
                           namespaceSerializer,
                           stateDesc.getSerializer(),
                           
(StateSnapshotTransformer.StateSnapshotTransformFactory<SV>) 
snapshotTransformFactory);
   ~~~
   




-- 
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:
[email protected]


Reply via email to