swamirishi commented on code in PR #8589:
URL: https://github.com/apache/ozone/pull/8589#discussion_r2161671918


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/WitnessedContainerDBDefinition.java:
##########
@@ -22,21 +22,20 @@
 import org.apache.hadoop.hdds.scm.container.ContainerID;
 import org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition;
 import org.apache.hadoop.hdds.utils.db.DBDefinition;
-import org.apache.hadoop.hdds.utils.db.StringCodec;
 import org.apache.hadoop.ozone.OzoneConsts;
 
 /**
  * Class for defining the schema for master volume in a datanode.
  */
 public final class WitnessedContainerDBDefinition extends DBDefinition.WithMap 
{
 
-  private static final String CONTAINER_IDS_TABLE_NAME = "containerIds";
+  private static final String CONTAINER_IDS_TABLE_NAME = "containerIdsTable";

Review Comment:
   nit:
   ```suggestion
     private static final String CONTAINER_IDS_TABLE_NAME = 
"ContainerCreateInfoTable";
   ```



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/WitnessedContainerMetadataStoreImpl.java:
##########
@@ -64,13 +71,53 @@ private 
WitnessedContainerMetadataStoreImpl(ConfigurationSource config, boolean
   @Override
   protected DBStore initDBStore(DBStoreBuilder dbStoreBuilder, 
ManagedDBOptions options, ConfigurationSource config)
       throws IOException {
+    previousVersionBasedTable = new PreviousVersionBasedTable();
+    previousVersionBasedTable.addTables(dbStoreBuilder);
     final DBStore dbStore = dbStoreBuilder.build();
+    previousVersionBasedTable.init(dbStore);
     this.containerIdsTable = 
this.getDbDef().getContainerIdsTable().getTable(dbStore);
     return dbStore;
   }
 
   @Override
-  public Table<ContainerID, String> getContainerIdsTable() {
+  public Table<ContainerID, ContainerCreateInfo> getContainerIdsTable() {
+    if 
(!VersionedDatanodeFeatures.isFinalized(HDDSLayoutFeature.WITNESSED_CONTAINER_DB_PROTO_VALUE))
 {
+      return previousVersionBasedTable.getContainerIdsTable();
+    }
     return containerIdsTable;
   }
+
+  public PreviousVersionBasedTable getPreviousVersionBasedTable() {
+    return previousVersionBasedTable;
+  }
+
+  /**
+   * this will hold old version tables required during upgrade, and these are 
initialized based on version only.
+   */
+  public static class PreviousVersionBasedTable {

Review Comment:
   ```suggestion
     public static class PreviousVersionTables {
   ```



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/upgrade/ContainerTableSchemaFinalizeAction.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.container.upgrade;
+
+import static 
org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature.WITNESSED_CONTAINER_DB_PROTO_VALUE;
+import static 
org.apache.hadoop.ozone.upgrade.LayoutFeature.UpgradeActionType.ON_FINALIZE;
+import static 
org.apache.hadoop.ozone.upgrade.UpgradeActionHdds.Component.DATANODE;
+
+import org.apache.hadoop.hdds.scm.container.ContainerID;
+import org.apache.hadoop.hdds.upgrade.HDDSUpgradeAction;
+import org.apache.hadoop.hdds.utils.db.BatchOperation;
+import org.apache.hadoop.hdds.utils.db.Table;
+import org.apache.hadoop.hdds.utils.db.TableIterator;
+import 
org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine;
+import org.apache.hadoop.ozone.container.metadata.ContainerCreateInfo;
+import 
org.apache.hadoop.ozone.container.metadata.WitnessedContainerDBDefinition;
+import 
org.apache.hadoop.ozone.container.metadata.WitnessedContainerMetadataStore;
+import 
org.apache.hadoop.ozone.container.metadata.WitnessedContainerMetadataStoreImpl;
+import org.apache.hadoop.ozone.upgrade.UpgradeActionHdds;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Upgrade Action for DataNode for update the table schema data of 
containerIds Table.
+ */
+@UpgradeActionHdds(feature = WITNESSED_CONTAINER_DB_PROTO_VALUE, component = 
DATANODE, type = ON_FINALIZE)
+public class ContainerTableSchemaFinalizeAction
+    implements HDDSUpgradeAction<DatanodeStateMachine> {
+
+  private static final Logger LOG =
+      LoggerFactory.getLogger(ContainerTableSchemaFinalizeAction.class);
+
+  @Override
+  public void execute(DatanodeStateMachine arg) throws Exception {
+    WitnessedContainerMetadataStore metadataStore = 
arg.getContainer().getWitnessedContainerMetadataStore();
+    Table<ContainerID, ContainerCreateInfo> previousTable
+        = ((WitnessedContainerMetadataStoreImpl) 
metadataStore).getPreviousVersionBasedTable().getContainerIdsTable();
+    Table<ContainerID, ContainerCreateInfo> currTable =

Review Comment:
   We need to truncate the entire table before copying entries. We could do by 
individual deletes or maybe use the deleteRange api which would cover the 
entire LongRange
   [0-9]



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