You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ta...@apache.org on 2025/07/22 11:10:38 UTC

(ozone) branch HDDS-13177 updated: HDDS-13442. Replace OMKeyInfo with light-weight ReconBasicOmKeyInfo under OmTableHandlers (#8809)

This is an automated email from the ASF dual-hosted git repository.

tanvipenumudy pushed a commit to branch HDDS-13177
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/HDDS-13177 by this push:
     new 4a9cce4ccd0 HDDS-13442. Replace OMKeyInfo with light-weight ReconBasicOmKeyInfo under OmTableHandlers (#8809)
4a9cce4ccd0 is described below

commit 4a9cce4ccd0ce43c9a867a269ef36ee1a0efbf8e
Author: tanvipenumudy <46...@users.noreply.github.com>
AuthorDate: Tue Jul 22 16:40:31 2025 +0530

    HDDS-13442. Replace OMKeyInfo with light-weight ReconBasicOmKeyInfo under OmTableHandlers (#8809)
---
 .../ozone/recon/api/types/ReconBasicOmKeyInfo.java | 32 ++++++++++++++++++++++
 .../recon/tasks/MultipartInfoInsightHandler.java   | 12 ++++----
 2 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/ReconBasicOmKeyInfo.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/ReconBasicOmKeyInfo.java
index c22010580e4..df62f72c845 100644
--- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/ReconBasicOmKeyInfo.java
+++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/ReconBasicOmKeyInfo.java
@@ -247,6 +247,38 @@ public static ReconBasicOmKeyInfo getFromProtobuf(OzoneManagerProtocolProtos.Key
     return builder.build();
   }
 
+  /**
+   * Converts a KeyInfo protobuf object into a ReconBasicOmKeyInfo instance.
+   * This method extracts only the essential fields required for Recon event handling, avoiding the overhead of
+   * deserializing unused metadata such as KeyLocationList or ACLs.
+   *
+   * @param keyInfoProto required for deserialization.
+   * @return the deserialized lightweight ReconBasicOmKeyInfo object.
+   */
+  public static ReconBasicOmKeyInfo getFromProtobuf(OzoneManagerProtocolProtos.KeyInfo keyInfoProto) {
+    if (keyInfoProto == null) {
+      return null;
+    }
+
+    String keyName = keyInfoProto.getKeyName();
+
+    Builder builder = new Builder()
+        .setVolumeName(keyInfoProto.getVolumeName())
+        .setBucketName(keyInfoProto.getBucketName())
+        .setKeyName(keyName)
+        .setDataSize(keyInfoProto.getDataSize())
+        .setCreationTime(keyInfoProto.getCreationTime())
+        .setModificationTime(keyInfoProto.getModificationTime())
+        .setReplicationConfig(ReplicationConfig.fromProto(
+            keyInfoProto.getType(),
+            keyInfoProto.getFactor(),
+            keyInfoProto.getEcReplicationConfig()))
+        .setIsFile(!keyName.endsWith("/"))
+        .setParentId(keyInfoProto.getParentID());
+
+    return builder.build();
+  }
+
   public OzoneManagerProtocolProtos.KeyInfoProtoLight toProtobuf() {
     throw new UnsupportedOperationException("This method is not supported.");
   }
diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/MultipartInfoInsightHandler.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/MultipartInfoInsightHandler.java
index 2f501a33ad9..3976919ab4b 100644
--- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/MultipartInfoInsightHandler.java
+++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/MultipartInfoInsightHandler.java
@@ -21,9 +21,9 @@
 import org.apache.commons.lang3.tuple.Triple;
 import org.apache.hadoop.hdds.utils.db.Table;
 import org.apache.hadoop.hdds.utils.db.TableIterator;
-import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
 import org.apache.hadoop.ozone.om.helpers.OmMultipartKeyInfo;
 import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PartKeyInfo;
+import org.apache.hadoop.ozone.recon.api.types.ReconBasicOmKeyInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,7 +50,7 @@ public void handlePutEvent(OMDBUpdateEvent<String, Object> event, String tableNa
           (k, count) -> count + 1L);
 
       for (PartKeyInfo partKeyInfo : multipartKeyInfo.getPartKeyInfoMap()) {
-        OmKeyInfo omKeyInfo = OmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
+        ReconBasicOmKeyInfo omKeyInfo = ReconBasicOmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
         unReplicatedSizeMap.computeIfPresent(getUnReplicatedSizeKeyFromTable(tableName),
             (k, size) -> size + omKeyInfo.getDataSize());
         replicatedSizeMap.computeIfPresent(getReplicatedSizeKeyFromTable(tableName),
@@ -75,7 +75,7 @@ public void handleDeleteEvent(OMDBUpdateEvent<String, Object> event, String tabl
           (k, count) -> count > 0 ? count - 1L : 0L);
 
       for (PartKeyInfo partKeyInfo : multipartKeyInfo.getPartKeyInfoMap()) {
-        OmKeyInfo omKeyInfo = OmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
+        ReconBasicOmKeyInfo omKeyInfo = ReconBasicOmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
         unReplicatedSizeMap.computeIfPresent(getUnReplicatedSizeKeyFromTable(tableName),
             (k, size) -> {
               long newSize = size > omKeyInfo.getDataSize() ? size - omKeyInfo.getDataSize() : 0L;
@@ -121,7 +121,7 @@ public void handleUpdateEvent(OMDBUpdateEvent<String, Object> event, String tabl
 
       // Calculate old sizes
       for (PartKeyInfo partKeyInfo : oldMultipartKeyInfo.getPartKeyInfoMap()) {
-        OmKeyInfo omKeyInfo = OmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
+        ReconBasicOmKeyInfo omKeyInfo = ReconBasicOmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
         unReplicatedSizeMap.computeIfPresent(getUnReplicatedSizeKeyFromTable(tableName),
             (k, size) -> size - omKeyInfo.getDataSize());
         replicatedSizeMap.computeIfPresent(getReplicatedSizeKeyFromTable(tableName),
@@ -130,7 +130,7 @@ public void handleUpdateEvent(OMDBUpdateEvent<String, Object> event, String tabl
 
       // Calculate new sizes
       for (PartKeyInfo partKeyInfo : newMultipartKeyInfo.getPartKeyInfoMap()) {
-        OmKeyInfo omKeyInfo = OmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
+        ReconBasicOmKeyInfo omKeyInfo = ReconBasicOmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
         unReplicatedSizeMap.computeIfPresent(getUnReplicatedSizeKeyFromTable(tableName),
             (k, size) -> size + omKeyInfo.getDataSize());
         replicatedSizeMap.computeIfPresent(getReplicatedSizeKeyFromTable(tableName),
@@ -160,7 +160,7 @@ public Triple<Long, Long, Long> getTableSizeAndCount(
         if (kv != null && kv.getValue() != null) {
           OmMultipartKeyInfo multipartKeyInfo = (OmMultipartKeyInfo) kv.getValue();
           for (PartKeyInfo partKeyInfo : multipartKeyInfo.getPartKeyInfoMap()) {
-            OmKeyInfo omKeyInfo = OmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
+            ReconBasicOmKeyInfo omKeyInfo = ReconBasicOmKeyInfo.getFromProtobuf(partKeyInfo.getPartKeyInfo());
             unReplicatedSize += omKeyInfo.getDataSize();
             replicatedSize += omKeyInfo.getReplicatedSize();
           }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org