StefanRRichter commented on a change in pull request #7674: [FLINK-10043] 
[State Backends] Refactor RocksDBKeyedStateBackend object 
construction/initialization/restore code
URL: https://github.com/apache/flink/pull/7674#discussion_r257718904
 
 

 ##########
 File path: 
flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/restore/RocksDBFullRestoreOperation.java
 ##########
 @@ -0,0 +1,276 @@
+/*
+ * 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.contrib.streaming.state.restore;
+
+import org.apache.flink.api.common.typeutils.TypeSerializerSchemaCompatibility;
+import 
org.apache.flink.api.common.typeutils.base.array.BytePrimitiveArraySerializer;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.configuration.ConfigConstants;
+import org.apache.flink.contrib.streaming.state.RocksDBKeyedStateBackend;
+import org.apache.flink.contrib.streaming.state.RocksDBNativeMetricMonitor;
+import org.apache.flink.contrib.streaming.state.RocksDBWriteBatchWrapper;
+import org.apache.flink.contrib.streaming.state.StateColumnFamilyHandle;
+import org.apache.flink.core.fs.CloseableRegistry;
+import org.apache.flink.core.fs.FSDataInputStream;
+import org.apache.flink.core.memory.DataInputView;
+import org.apache.flink.core.memory.DataInputViewStreamWrapper;
+import org.apache.flink.runtime.state.KeyGroupRange;
+import org.apache.flink.runtime.state.KeyGroupsStateHandle;
+import org.apache.flink.runtime.state.KeyedBackendSerializationProxy;
+import org.apache.flink.runtime.state.KeyedStateHandle;
+import org.apache.flink.runtime.state.RegisteredStateMetaInfoBase;
+import org.apache.flink.runtime.state.SnappyStreamCompressionDecorator;
+import org.apache.flink.runtime.state.StateSerializerProvider;
+import org.apache.flink.runtime.state.StreamCompressionDecorator;
+import org.apache.flink.runtime.state.UncompressedStreamCompressionDecorator;
+import org.apache.flink.runtime.state.metainfo.StateMetaInfoSnapshot;
+import org.apache.flink.util.IOUtils;
+import org.apache.flink.util.Preconditions;
+import org.apache.flink.util.StateMigrationException;
+
+import org.rocksdb.ColumnFamilyDescriptor;
+import org.rocksdb.ColumnFamilyHandle;
+import org.rocksdb.ColumnFamilyOptions;
+import org.rocksdb.DBOptions;
+import org.rocksdb.RocksDB;
+import org.rocksdb.RocksDBException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.contrib.streaming.state.snapshot.RocksSnapshotUtil.END_OF_KEY_GROUP_MARK;
+import static 
org.apache.flink.contrib.streaming.state.snapshot.RocksSnapshotUtil.clearMetaDataFollowsFlag;
+import static 
org.apache.flink.contrib.streaming.state.snapshot.RocksSnapshotUtil.hasMetaDataFollowsFlag;
+
+/**
+ * Encapsulates the process of restoring a RocksDB instance from a full 
snapshot.
+ */
+public class RocksDBFullRestoreOperation<K> extends 
AbstractRocksDBRestoreOperation<K> {
+       /**
+        * Current key-groups state handle from which we restore key-groups.
+        */
+       private KeyGroupsStateHandle currentKeyGroupsStateHandle;
+       /**
+        * Current input stream we obtained from currentKeyGroupsStateHandle.
+        */
+       private FSDataInputStream currentStateHandleInStream;
+       /**
+        * Current data input view that wraps currentStateHandleInStream.
+        */
+       private DataInputView currentStateHandleInView;
+       /**
+        * Current list of ColumnFamilyHandles for all column families we 
restore from currentKeyGroupsStateHandle.
+        */
+       private List<ColumnFamilyHandle> 
currentStateHandleKVStateColumnFamilies;
+       /**
+        * The compression decorator that was used for writing the state, as 
determined by the meta data.
+        */
+       private StreamCompressionDecorator keygroupStreamCompressionDecorator;
+
+       private boolean isKeySerializerCompatibilityChecked;
+
+       public RocksDBFullRestoreOperation(KeyGroupRange keyGroupRange,
+                                                                       int 
keyGroupPrefixBytes,
+                                                                       int 
numberOfTransferringThreads,
+                                                                       
CloseableRegistry cancelStreamRegistry,
+                                                                       
ClassLoader userCodeClassLoader,
+                                                                       
Map<String, StateColumnFamilyHandle> kvStateInformation,
+                                                                       
StateSerializerProvider<K> keySerializerProvider,
+                                                                       File 
instanceBasePath,
+                                                                       File 
instanceRocksDBPath,
+                                                                       
DBOptions dbOptions,
+                                                                       
ColumnFamilyOptions columnOptions,
+                                                                       
RocksDBNativeMetricMonitor nativeMetricMonitor) {
+               super(keyGroupRange,
+                       keyGroupPrefixBytes,
+                       numberOfTransferringThreads,
+                       cancelStreamRegistry,
+                       userCodeClassLoader,
+                       kvStateInformation,
+                       keySerializerProvider,
+                       instanceBasePath,
+                       instanceRocksDBPath,
+                       dbOptions,
+                       columnOptions,
+                       nativeMetricMonitor);
+       }
+
+       /**
+        * Restores all key-groups data that is referenced by the passed state 
handles.
+        *  @param keyedStateHandles List of all key groups state handles that 
shall be restored.
+        * @param db
 
 Review comment:
   Ok then, if you want to keep the detailed comment here, we can just add the 
missing description for `@param db`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to