umamaheswararao commented on code in PR #7934:
URL: https://github.com/apache/ozone/pull/7934#discussion_r1962341019


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeStoreSchemaThreeImpl.java:
##########
@@ -131,18 +139,39 @@ public void dumpKVContainerData(long containerID, File 
dumpDir)
         prefix);
   }
 
-  public void loadKVContainerData(File dumpDir)
-      throws IOException {
-    getMetadataTable().loadFromFile(
-        getTableDumpFile(getMetadataTable(), dumpDir));
-    getBlockDataTable().loadFromFile(
-        getTableDumpFile(getBlockDataTable(), dumpDir));
-    if 
(VersionedDatanodeFeatures.isFinalized(HDDSLayoutFeature.HBASE_SUPPORT)) {
-      getLastChunkInfoTable().loadFromFile(
-          getTableDumpFile(getLastChunkInfoTable(), dumpDir));
+  public void loadKVContainerData(File dumpDir, DatanodeStoreSchemaThreeImpl 
store) throws IOException {
+    try (BatchOperation batch = store.getBatchHandler().initBatchOperation()) {
+      processTable(batch, getTableDumpFile(getMetadataTable(), dumpDir),
+          FixedLengthStringCodec.get(), LongCodec.get(), getMetadataTable());
+      processTable(batch, getTableDumpFile(getBlockDataTable(), dumpDir),
+          FixedLengthStringCodec.get(), BlockData.getCodec(), 
getBlockDataTable());
+      if 
(VersionedDatanodeFeatures.isFinalized(HDDSLayoutFeature.HBASE_SUPPORT)) {
+        processTable(batch, getTableDumpFile(getLastChunkInfoTable(), dumpDir),
+            FixedLengthStringCodec.get(), BlockData.getCodec(), 
getLastChunkInfoTable());
+      }
+      processTable(batch, getTableDumpFile(getDeleteTransactionTable(), 
dumpDir), FixedLengthStringCodec.get(),
+          Proto2Codec.get(DeletedBlocksTransaction.getDefaultInstance()), 
getDeleteTransactionTable());
+
+      store.getStore().commitBatchOperation(batch);
+    }
+  }
+
+  private <K, V> void processTable(BatchOperation batch, File tableDumpFile,
+      Codec<K> keyCodec, Codec<V> valueCodec, Table<K, V> table) throws 
IOException {
+    try (ManagedSstFileReader sstFileReader = new ManagedSstFileReader(new 
ManagedOptions());
+         ManagedSstFileReaderIterator iterator =
+             
ManagedSstFileReaderIterator.managed(sstFileReader.newIterator(new 
ManagedReadOptions()))) {
+      sstFileReader.open(tableDumpFile.getAbsolutePath());
+      for (iterator.get().seekToFirst(); iterator.get().isValid(); 
iterator.get().next()) {
+        byte[] key = iterator.get().key();
+        byte[] value = iterator.get().value();
+        K decodedKey = keyCodec.fromPersistedFormat(key);
+        V decodedValue = valueCodec.fromPersistedFormat(value);
+        table.putWithBatch(batch, decodedKey, decodedValue);
+      }
+    } catch (RocksDBException e) {

Review Comment:
   Why is this exception being eaten here? Should we need to rethrow and make a 
graceful cleanup if failed?



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