adoroszlai commented on code in PR #8541:
URL: https://github.com/apache/ozone/pull/8541#discussion_r2125860109


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/codec/ReconOMDBDefinition.java:
##########
@@ -0,0 +1,405 @@
+/*
+ * 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.recon.codec;
+
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.BUCKET_TABLE;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.COMPACTION_LOG_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.DELEGATION_TOKEN_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.DELETED_DIR_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.DELETED_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.DIRECTORY_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.FILE_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.KEY_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.META_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.MULTIPART_INFO_TABLE_DEF;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.OPEN_FILE_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.OPEN_KEY_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.PREFIX_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.PRINCIPAL_TO_ACCESS_IDS_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.S3_SECRET_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.SNAPSHOT_INFO_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.SNAPSHOT_RENAMED_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.TENANT_ACCESS_ID_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.TENANT_STATE_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.TRANSACTION_INFO_TABLE_DEF;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.USER_TABLE_DEF;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.VOLUME_TABLE;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.hadoop.fs.FileChecksum;
+import org.apache.hadoop.hdds.client.DefaultReplicationConfig;
+import org.apache.hadoop.hdds.client.ReplicationConfig;
+import org.apache.hadoop.hdds.protocol.StorageType;
+import org.apache.hadoop.hdds.utils.db.Codec;
+import org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition;
+import org.apache.hadoop.hdds.utils.db.DBDefinition;
+import org.apache.hadoop.hdds.utils.db.DelegatedCodec;
+import org.apache.hadoop.hdds.utils.db.Proto2Codec;
+import org.apache.hadoop.hdds.utils.db.StringCodec;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.OzoneConsts;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.helpers.KeyValueUtil;
+import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
+import org.apache.hadoop.ozone.om.helpers.OmDirectoryInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup;
+import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
+import org.apache.hadoop.ozone.om.helpers.OzoneFSUtils;
+import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
+import org.apache.hadoop.ozone.protocolPB.OMPBHelper;
+
+/**
+ * OM database definitions.
+ * <pre>
+ * {@code
+ * User, Token and Secret Tables:
+ * |------------------------------------------------------------------------|
+ * |        Column Family |                 Mapping                         |
+ * |------------------------------------------------------------------------|
+ * |            userTable |             /user :- UserVolumeInfo             |
+ * |          dTokenTable |      OzoneTokenID :- renew_time                 |
+ * |        s3SecretTable | s3g_access_key_id :- s3Secret                   |
+ * |------------------------------------------------------------------------|
+ * }
+ * </pre>
+ *
+ * <pre>
+ * {@code
+ * Volume, Bucket, Prefix and Transaction Tables:
+ * |------------------------------------------------------------------------|
+ * |        Column Family |                 Mapping                         |
+ * |------------------------------------------------------------------------|
+ * |          volumeTable |           /volume :- VolumeInfo                 |
+ * |          bucketTable |    /volume/bucket :- BucketInfo                 |
+ * |------------------------------------------------------------------------|
+ * |          prefixTable |            prefix :- PrefixInfo                 |
+ * |------------------------------------------------------------------------|
+ * | transactionInfoTable |  #TRANSACTIONINFO :- OMTransactionInfo          |
+ * |            metaTable |       metaDataKey :- metaDataValue              |
+ * |------------------------------------------------------------------------|
+ * }
+ * </pre>
+ *
+ * <pre>
+ * {@code
+ * Object Store (OBS) Tables:
+ * |-----------------------------------------------------------------------|
+ * |        Column Family |                           Mapping              |
+ * |-----------------------------------------------------------------------|
+ * |             keyTable | /volume/bucket/key          :- KeyInfo         |
+ * |         deletedTable | /volume/bucket/key          :- RepeatedKeyInfo |
+ * |         openKeyTable | /volume/bucket/key/id       :- KeyInfo         |
+ * |   multipartInfoTable | /volume/bucket/key/uploadId :- parts           |
+ * |-----------------------------------------------------------------------|
+ * }
+ * </pre>
+ * Note that "volume", "bucket" and "key" in OBS tables are names.
+ *
+ * <pre>
+ * {@code
+ * File System Optimized (FSO) Tables:
+ * 
|-----------------------------------------------------------------------------------|
+ * |          Column Family |                                            
Mapping       |
+ * 
|-----------------------------------------------------------------------------------|
+ * |              fileTable | /volumeId/bucketId/parentId/fileName         :- 
KeyInfo  |
+ * |          openFileTable | /volumeId/bucketId/parentId/fileName/id      :- 
KeyInfo  |
+ * |         directoryTable | /volumeId/bucketId/parentId/dirName          :- 
DirInfo  |
+ * |  deletedDirectoryTable | /volumeId/bucketId/parentId/dirName/objectId :- 
KeyInfo  |
+ * 
|-----------------------------------------------------------------------------------|
+ * }
+ * </pre>
+ *
+ * <pre>
+ * {@code
+ * S3 Multi-Tenant Tables:
+ * |----------------------------------------------------------------------|
+ * |             Column Family |             Mapping                      |
+ * |----------------------------------------------------------------------|
+ * |          tenantStateTable |      tenantId :- OmDBTenantState         |
+ * |       tenantAccessIdTable |      accessId :- OmDBAccessIdInfo        |
+ * | principalToAccessIdsTable | userPrincipal :- OmDBUserPrincipalInfo   |
+ * |----------------------------------------------------------------------|
+ * }
+ * </pre>
+ *
+ * <pre>
+ * {@code
+ * Snapshot Tables:
+ * 
|----------------------------------------------------------------------------------|
+ * |        Column Family |                                   Mapping          
       |
+ * 
|----------------------------------------------------------------------------------|
+ * |    snapshotInfoTable | /volumeName/bucketName/snapshotName :- 
SnapshotInfo       |
+ * | snapshotRenamedTable | /volumeName/bucketName/objectID     :- renameFrom  
       |
+ * |   compactionLogTable | dbTrxId-compactionTime              :- 
compactionLogEntry |
+ * 
|----------------------------------------------------------------------------------|
+ * }
+ * </pre>
+ * Note that renameFrom is one of the following:
+ *   1. /volumeId/bucketId/parentId/dirName
+ *   2. /volumeId/bucketId/parentId/fileName
+ *   3. /volumeName/bucketName/keyName
+ */
+public final class ReconOMDBDefinition extends DBDefinition.WithMap {
+
+  //---------------------------------------------------------------------------
+  // Volume, Bucket, Prefix and Transaction Tables:
+  /** volumeTable: /volume :- VolumeInfo. */
+  public static final DBColumnFamilyDefinition<String, OmVolumeArgs> 
VOLUME_TABLE_DEF
+      = new DBColumnFamilyDefinition<>(VOLUME_TABLE,
+          StringCodec.get(),
+          OmVolumeArgs.getCodec());

Review Comment:
   Can remove and use from `OMDBDefinition`?



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/codec/ReconOMDBDefinition.java:
##########
@@ -0,0 +1,405 @@
+/*
+ * 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.recon.codec;
+
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.BUCKET_TABLE;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.COMPACTION_LOG_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.DELEGATION_TOKEN_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.DELETED_DIR_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.DELETED_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.DIRECTORY_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.FILE_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.KEY_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.META_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.MULTIPART_INFO_TABLE_DEF;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.OPEN_FILE_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.OPEN_KEY_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.PREFIX_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.PRINCIPAL_TO_ACCESS_IDS_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.S3_SECRET_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.SNAPSHOT_INFO_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.SNAPSHOT_RENAMED_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.TENANT_ACCESS_ID_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.TENANT_STATE_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.TRANSACTION_INFO_TABLE_DEF;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.USER_TABLE_DEF;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.VOLUME_TABLE;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.hadoop.fs.FileChecksum;
+import org.apache.hadoop.hdds.client.DefaultReplicationConfig;
+import org.apache.hadoop.hdds.client.ReplicationConfig;
+import org.apache.hadoop.hdds.protocol.StorageType;
+import org.apache.hadoop.hdds.utils.db.Codec;
+import org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition;
+import org.apache.hadoop.hdds.utils.db.DBDefinition;
+import org.apache.hadoop.hdds.utils.db.DelegatedCodec;
+import org.apache.hadoop.hdds.utils.db.Proto2Codec;
+import org.apache.hadoop.hdds.utils.db.StringCodec;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.OzoneConsts;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.helpers.KeyValueUtil;
+import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
+import org.apache.hadoop.ozone.om.helpers.OmDirectoryInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup;
+import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
+import org.apache.hadoop.ozone.om.helpers.OzoneFSUtils;
+import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
+import org.apache.hadoop.ozone.protocolPB.OMPBHelper;
+
+/**
+ * OM database definitions.

Review Comment:
   Please don't duplicate javadoc from `OMDBDefinition`.  Instead, add a short 
explanation of how this is different and why it is needed.



##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/codec/ReconOMDBDefinition.java:
##########
@@ -0,0 +1,405 @@
+/*
+ * 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.recon.codec;
+
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.BUCKET_TABLE;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.COMPACTION_LOG_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.DELEGATION_TOKEN_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.DELETED_DIR_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.DELETED_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.DIRECTORY_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.FILE_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.KEY_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.META_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.MULTIPART_INFO_TABLE_DEF;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.OPEN_FILE_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.OPEN_KEY_TABLE;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.PREFIX_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.PRINCIPAL_TO_ACCESS_IDS_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.S3_SECRET_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.SNAPSHOT_INFO_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.SNAPSHOT_RENAMED_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.TENANT_ACCESS_ID_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.TENANT_STATE_TABLE_DEF;
+import static 
org.apache.hadoop.ozone.om.codec.OMDBDefinition.TRANSACTION_INFO_TABLE_DEF;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.USER_TABLE_DEF;
+import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.VOLUME_TABLE;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.hadoop.fs.FileChecksum;
+import org.apache.hadoop.hdds.client.DefaultReplicationConfig;
+import org.apache.hadoop.hdds.client.ReplicationConfig;
+import org.apache.hadoop.hdds.protocol.StorageType;
+import org.apache.hadoop.hdds.utils.db.Codec;
+import org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition;
+import org.apache.hadoop.hdds.utils.db.DBDefinition;
+import org.apache.hadoop.hdds.utils.db.DelegatedCodec;
+import org.apache.hadoop.hdds.utils.db.Proto2Codec;
+import org.apache.hadoop.hdds.utils.db.StringCodec;
+import org.apache.hadoop.ozone.ClientVersion;
+import org.apache.hadoop.ozone.OzoneConsts;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.hadoop.ozone.om.helpers.BucketLayout;
+import org.apache.hadoop.ozone.om.helpers.KeyValueUtil;
+import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
+import org.apache.hadoop.ozone.om.helpers.OmDirectoryInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup;
+import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
+import org.apache.hadoop.ozone.om.helpers.OzoneFSUtils;
+import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
+import org.apache.hadoop.ozone.protocolPB.OMPBHelper;
+
+/**
+ * OM database definitions.
+ * <pre>
+ * {@code
+ * User, Token and Secret Tables:
+ * |------------------------------------------------------------------------|
+ * |        Column Family |                 Mapping                         |
+ * |------------------------------------------------------------------------|
+ * |            userTable |             /user :- UserVolumeInfo             |
+ * |          dTokenTable |      OzoneTokenID :- renew_time                 |
+ * |        s3SecretTable | s3g_access_key_id :- s3Secret                   |
+ * |------------------------------------------------------------------------|
+ * }
+ * </pre>
+ *
+ * <pre>
+ * {@code
+ * Volume, Bucket, Prefix and Transaction Tables:
+ * |------------------------------------------------------------------------|
+ * |        Column Family |                 Mapping                         |
+ * |------------------------------------------------------------------------|
+ * |          volumeTable |           /volume :- VolumeInfo                 |
+ * |          bucketTable |    /volume/bucket :- BucketInfo                 |
+ * |------------------------------------------------------------------------|
+ * |          prefixTable |            prefix :- PrefixInfo                 |
+ * |------------------------------------------------------------------------|
+ * | transactionInfoTable |  #TRANSACTIONINFO :- OMTransactionInfo          |
+ * |            metaTable |       metaDataKey :- metaDataValue              |
+ * |------------------------------------------------------------------------|
+ * }
+ * </pre>
+ *
+ * <pre>
+ * {@code
+ * Object Store (OBS) Tables:
+ * |-----------------------------------------------------------------------|
+ * |        Column Family |                           Mapping              |
+ * |-----------------------------------------------------------------------|
+ * |             keyTable | /volume/bucket/key          :- KeyInfo         |
+ * |         deletedTable | /volume/bucket/key          :- RepeatedKeyInfo |
+ * |         openKeyTable | /volume/bucket/key/id       :- KeyInfo         |
+ * |   multipartInfoTable | /volume/bucket/key/uploadId :- parts           |
+ * |-----------------------------------------------------------------------|
+ * }
+ * </pre>
+ * Note that "volume", "bucket" and "key" in OBS tables are names.
+ *
+ * <pre>
+ * {@code
+ * File System Optimized (FSO) Tables:
+ * 
|-----------------------------------------------------------------------------------|
+ * |          Column Family |                                            
Mapping       |
+ * 
|-----------------------------------------------------------------------------------|
+ * |              fileTable | /volumeId/bucketId/parentId/fileName         :- 
KeyInfo  |
+ * |          openFileTable | /volumeId/bucketId/parentId/fileName/id      :- 
KeyInfo  |
+ * |         directoryTable | /volumeId/bucketId/parentId/dirName          :- 
DirInfo  |
+ * |  deletedDirectoryTable | /volumeId/bucketId/parentId/dirName/objectId :- 
KeyInfo  |
+ * 
|-----------------------------------------------------------------------------------|
+ * }
+ * </pre>
+ *
+ * <pre>
+ * {@code
+ * S3 Multi-Tenant Tables:
+ * |----------------------------------------------------------------------|
+ * |             Column Family |             Mapping                      |
+ * |----------------------------------------------------------------------|
+ * |          tenantStateTable |      tenantId :- OmDBTenantState         |
+ * |       tenantAccessIdTable |      accessId :- OmDBAccessIdInfo        |
+ * | principalToAccessIdsTable | userPrincipal :- OmDBUserPrincipalInfo   |
+ * |----------------------------------------------------------------------|
+ * }
+ * </pre>
+ *
+ * <pre>
+ * {@code
+ * Snapshot Tables:
+ * 
|----------------------------------------------------------------------------------|
+ * |        Column Family |                                   Mapping          
       |
+ * 
|----------------------------------------------------------------------------------|
+ * |    snapshotInfoTable | /volumeName/bucketName/snapshotName :- 
SnapshotInfo       |
+ * | snapshotRenamedTable | /volumeName/bucketName/objectID     :- renameFrom  
       |
+ * |   compactionLogTable | dbTrxId-compactionTime              :- 
compactionLogEntry |
+ * 
|----------------------------------------------------------------------------------|
+ * }
+ * </pre>
+ * Note that renameFrom is one of the following:
+ *   1. /volumeId/bucketId/parentId/dirName
+ *   2. /volumeId/bucketId/parentId/fileName
+ *   3. /volumeName/bucketName/keyName
+ */
+public final class ReconOMDBDefinition extends DBDefinition.WithMap {
+
+  //---------------------------------------------------------------------------
+  // Volume, Bucket, Prefix and Transaction Tables:
+  /** volumeTable: /volume :- VolumeInfo. */
+  public static final DBColumnFamilyDefinition<String, OmVolumeArgs> 
VOLUME_TABLE_DEF
+      = new DBColumnFamilyDefinition<>(VOLUME_TABLE,
+          StringCodec.get(),
+          OmVolumeArgs.getCodec());
+
+  private static final Codec<OmBucketInfo> CUSTOM_CODEC_FOR_BUCKET_TABLE = new 
DelegatedCodec<>(
+      
Proto2Codec.get(OzoneManagerProtocolProtos.BucketInfo.getDefaultInstance()),
+      ReconOMDBDefinition::getOmBucketInfoFromProtobuf,
+      null,
+      OmBucketInfo.class);
+  /** bucketTable: /volume/bucket :- BucketInfo. */
+  public static final DBColumnFamilyDefinition<String, OmBucketInfo> 
BUCKET_TABLE_DEF
+      = new DBColumnFamilyDefinition<>(BUCKET_TABLE, StringCodec.get(), 
CUSTOM_CODEC_FOR_BUCKET_TABLE);
+
+  public static final Codec<OmKeyInfo> CUSTOM_CODEC_FOR_KEY_TABLE = new 
DelegatedCodec<>(
+      Proto2Codec.get(OzoneManagerProtocolProtos.KeyInfo.getDefaultInstance()),
+      ReconOMDBDefinition::getOmKeyInfoFromProtobuf,
+      k -> k.getProtobuf(true, ClientVersion.CURRENT_VERSION),
+      OmKeyInfo.class);
+  // Object Store (OBS) Tables:
+  /** keyTable: /volume/bucket/key :- KeyInfo. */
+  public static final DBColumnFamilyDefinition<String, OmKeyInfo> KEY_TABLE_DEF
+      = new DBColumnFamilyDefinition<>(KEY_TABLE, StringCodec.get(), 
CUSTOM_CODEC_FOR_KEY_TABLE);
+
+  private static final Codec<RepeatedOmKeyInfo> CUSTOM_CODEC_FOR_DELETED_TABLE 
= new DelegatedCodec<>(
+      
Proto2Codec.get(OzoneManagerProtocolProtos.RepeatedKeyInfo.getDefaultInstance()),
+      ReconOMDBDefinition::getRepeatedOmKeyInfoFromProto,
+      k -> k.getProto(true, ClientVersion.CURRENT_VERSION),
+      RepeatedOmKeyInfo.class);
+
+  /** deletedTable: /volume/bucket/key :- RepeatedKeyInfo. */
+  public static final DBColumnFamilyDefinition<String, RepeatedOmKeyInfo> 
DELETED_TABLE_DEF
+      = new DBColumnFamilyDefinition<>(DELETED_TABLE, StringCodec.get(), 
CUSTOM_CODEC_FOR_DELETED_TABLE);
+
+  /** openKeyTable: /volume/bucket/key/id :- KeyInfo. */
+  public static final DBColumnFamilyDefinition<String, OmKeyInfo> 
OPEN_KEY_TABLE_DEF
+      = new DBColumnFamilyDefinition<>(OPEN_KEY_TABLE, StringCodec.get(), 
CUSTOM_CODEC_FOR_KEY_TABLE);
+
+  //---------------------------------------------------------------------------
+  // File System Optimized (FSO) Tables:
+  /** fileTable: /volumeId/bucketId/parentId/fileName :- KeyInfo. */
+  public static final DBColumnFamilyDefinition<String, OmKeyInfo> 
FILE_TABLE_DEF
+      = new DBColumnFamilyDefinition<>(FILE_TABLE, StringCodec.get(), 
CUSTOM_CODEC_FOR_KEY_TABLE);
+
+  /** openFileTable: /volumeId/bucketId/parentId/fileName/id :- KeyInfo. */
+  public static final DBColumnFamilyDefinition<String, OmKeyInfo> 
OPEN_FILE_TABLE_DEF
+      = new DBColumnFamilyDefinition<>(OPEN_FILE_TABLE, StringCodec.get(), 
CUSTOM_CODEC_FOR_KEY_TABLE);
+
+  public static final Codec<OmDirectoryInfo> CUSTOM_CODEC_FOR_DIR_TABLE = new 
DelegatedCodec<>(
+      
Proto2Codec.get(OzoneManagerProtocolProtos.DirectoryInfo.getDefaultInstance()),
+      ReconOMDBDefinition::getOmDirInfoFromProtobuf,
+      null,
+      OmDirectoryInfo.class);
+  /** directoryTable: /volumeId/bucketId/parentId/dirName :- DirInfo. */
+  public static final DBColumnFamilyDefinition<String, OmDirectoryInfo> 
DIRECTORY_TABLE_DEF
+      = new DBColumnFamilyDefinition<>(DIRECTORY_TABLE, StringCodec.get(), 
CUSTOM_CODEC_FOR_DIR_TABLE);
+
+  /** deletedDirectoryTable: /volumeId/bucketId/parentId/dirName/objectId :- 
KeyInfo. */
+  public static final DBColumnFamilyDefinition<String, OmKeyInfo> 
DELETED_DIR_TABLE_DEF
+      = new DBColumnFamilyDefinition<>(DELETED_DIR_TABLE, StringCodec.get(), 
CUSTOM_CODEC_FOR_KEY_TABLE);
+
+  //---------------------------------------------------------------------------
+  public static final Map<String, DBColumnFamilyDefinition<?, ?>> 
COLUMN_FAMILIES
+      = DBColumnFamilyDefinition.newUnmodifiableMap(
+      BUCKET_TABLE_DEF,
+      DELETED_DIR_TABLE_DEF,
+      DELETED_TABLE_DEF,
+      DIRECTORY_TABLE_DEF,
+      DELEGATION_TOKEN_TABLE_DEF,
+      FILE_TABLE_DEF,
+      KEY_TABLE_DEF,
+      META_TABLE_DEF,
+      MULTIPART_INFO_TABLE_DEF,
+      OPEN_FILE_TABLE_DEF,
+      OPEN_KEY_TABLE_DEF,
+      PREFIX_TABLE_DEF,
+      PRINCIPAL_TO_ACCESS_IDS_TABLE_DEF,
+      S3_SECRET_TABLE_DEF,
+      SNAPSHOT_INFO_TABLE_DEF,
+      SNAPSHOT_RENAMED_TABLE_DEF,
+      COMPACTION_LOG_TABLE_DEF,
+      TENANT_ACCESS_ID_TABLE_DEF,
+      TENANT_STATE_TABLE_DEF,
+      TRANSACTION_INFO_TABLE_DEF,
+      USER_TABLE_DEF,
+      VOLUME_TABLE_DEF);
+
+  private static final ReconOMDBDefinition INSTANCE = new 
ReconOMDBDefinition();
+
+  /**
+   * Parses BucketInfo protobuf and creates OmBucketInfo without deserializing 
ACL list.
+   * @param bucketInfo
+   * @return instance of OmBucketInfo
+   */
+  public static OmBucketInfo 
getOmBucketInfoFromProtobuf(OzoneManagerProtocolProtos.BucketInfo bucketInfo) {
+    OmBucketInfo.Builder obib = OmBucketInfo.newBuilder()
+        .setVolumeName(bucketInfo.getVolumeName())
+        .setBucketName(bucketInfo.getBucketName())
+        .setIsVersionEnabled(bucketInfo.getIsVersionEnabled())
+        .setStorageType(StorageType.valueOf(bucketInfo.getStorageType()))
+        .setCreationTime(bucketInfo.getCreationTime())
+        .setUsedBytes(bucketInfo.getUsedBytes())
+        .setModificationTime(bucketInfo.getModificationTime())
+        .setQuotaInBytes(bucketInfo.getQuotaInBytes())
+        .setUsedNamespace(bucketInfo.getUsedNamespace())
+        .setQuotaInNamespace(bucketInfo.getQuotaInNamespace());

Review Comment:
   Instead of re-implementing most of the conversion logic without ACL, please:
   - move this to `OmBucketInfo` as a helper that returns `OmBucketInfo.Builder`
   - let both "full" and "reduced" conversion call the helper and then 
`build()`, with "full" adding further logic between the two steps
   
   Apply the same to `OmKeyInfo`, etc.



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