From baae4f7201f9f464163e1ef046cd98bec9127a06 Mon Sep 17 00:00:00 2001 From: navinko Date: Fri, 19 Dec 2025 03:40:36 +0530 Subject: [PATCH 1/2] HDDS-14155. Replace ByteArrayCodec with CodecBufferCodec in OmTableInsightTask --- .../ozone/recon/tasks/OmTableInsightTask.java | 8 ++-- .../recon/tasks/TestOmTableInsightTask.java | 43 +++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/OmTableInsightTask.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/OmTableInsightTask.java index 8027966231d..2bc9bdfb4b9 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/OmTableInsightTask.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/tasks/OmTableInsightTask.java @@ -35,6 +35,8 @@ import java.util.concurrent.atomic.AtomicLong; import org.apache.commons.lang3.tuple.Triple; import org.apache.hadoop.hdds.utils.db.ByteArrayCodec; +import org.apache.hadoop.hdds.utils.db.CodecBuffer; +import org.apache.hadoop.hdds.utils.db.CodecBufferCodec; import org.apache.hadoop.hdds.utils.db.DBStore; import org.apache.hadoop.hdds.utils.db.RDBBatchOperation; import org.apache.hadoop.hdds.utils.db.StringCodec; @@ -177,9 +179,9 @@ private boolean usesNonStringKeys(String tableName) { private void processTableSequentially(String tableName, OMMetadataManager omMetadataManager) throws IOException { LOG.info("{}: Processing table {} sequentially (non-String keys)", getTaskName(), tableName); - Table table = omMetadataManager.getStore() - .getTable(tableName, ByteArrayCodec.get(), ByteArrayCodec.get(), TableCache.CacheType.NO_CACHE); - try (TableIterator keyIterator = table.keyIterator()) { + Table table = omMetadataManager.getStore() + .getTable(tableName, CodecBufferCodec.get(true), CodecBufferCodec.get(true), TableCache.CacheType.NO_CACHE); + try (TableIterator keyIterator = table.keyIterator()) { long count = Iterators.size(keyIterator); objectCountMap.put(getTableCountKeyFromTable(tableName), count); } diff --git a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java index 4f64d27297b..017df0aa69a 100644 --- a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java +++ b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java @@ -18,6 +18,7 @@ package org.apache.hadoop.ozone.recon.tasks; import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.BUCKET_TABLE; +import static org.apache.hadoop.ozone.om.codec.OMDBDefinition.DELEGATION_TOKEN_TABLE; 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.KEY_TABLE; @@ -48,6 +49,7 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.UUID; @@ -55,9 +57,13 @@ import org.apache.hadoop.hdds.client.RatisReplicationConfig; import org.apache.hadoop.hdds.client.StandaloneReplicationConfig; import org.apache.hadoop.hdds.protocol.proto.HddsProtos; +import org.apache.hadoop.hdds.utils.db.CodecBuffer; +import org.apache.hadoop.hdds.utils.db.CodecBufferCodec; import org.apache.hadoop.hdds.utils.db.DBStore; import org.apache.hadoop.hdds.utils.db.Table; +import org.apache.hadoop.hdds.utils.db.TableIterator; import org.apache.hadoop.hdds.utils.db.TypedTable; +import org.apache.hadoop.hdds.utils.db.cache.TableCache; import org.apache.hadoop.ozone.om.OMMetadataManager; import org.apache.hadoop.ozone.om.OmMetadataManagerImpl; import org.apache.hadoop.ozone.om.helpers.BucketLayout; @@ -861,4 +867,41 @@ private OmKeyInfo getOmKeyInfo(String volumeName, String bucketName, .setObjectID(objectID) .build(); } + + @Test + public void testSequentialProcessingWithCodecBuffer_CountVerified() + throws Exception { + OmTableInsightTask task = + new OmTableInsightTask(reconGlobalStatsManager, reconOMMetadataManager) { + @Override + public Collection getTaskTables() { + return Collections.singletonList(DELEGATION_TOKEN_TABLE); + } + }; + OMMetadataManager omMetadataManager = mock(OMMetadataManager.class); + DBStore store = mock(DBStore.class); + when(omMetadataManager.getStore()).thenReturn(store); + @SuppressWarnings("unchecked") + Table table = + (Table) mock(Table.class); + @SuppressWarnings("unchecked") + TableIterator iterator = + (TableIterator) mock(TableIterator.class); + when(store.getTable( + eq(DELEGATION_TOKEN_TABLE), + any(CodecBufferCodec.class), + any(CodecBufferCodec.class), + eq(TableCache.CacheType.NO_CACHE))) + .thenReturn((Table) table); + when(table.keyIterator()).thenReturn(iterator); + when(iterator.hasNext()).thenReturn(true, true, true, false); + ReconOmTask.TaskResult result = task.reprocess(omMetadataManager); + assertTrue(result.isTaskSuccess(), + "Sequential processing should succeed"); + String countKey = + OmTableInsightTask.getTableCountKeyFromTable(DELEGATION_TOKEN_TABLE); + Long count = task.initializeCountMap().get(countKey); + assertEquals(3L, count, + "Sequential iterator must count all keys"); + } } From 3b2d4e915854da65528053b081692cbcf44199ea Mon Sep 17 00:00:00 2001 From: navinko Date: Fri, 19 Dec 2025 03:47:22 +0530 Subject: [PATCH 2/2] HDDS-14155. Replace ByteArrayCodec with CodecBufferCodec in OmTableInsightTask --- .../apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java index 017df0aa69a..1b504da0053 100644 --- a/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java +++ b/hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/tasks/TestOmTableInsightTask.java @@ -869,7 +869,7 @@ private OmKeyInfo getOmKeyInfo(String volumeName, String bucketName, } @Test - public void testSequentialProcessingWithCodecBuffer_CountVerified() + public void testSequentialProcessingWithCodecBuffer() throws Exception { OmTableInsightTask task = new OmTableInsightTask(reconGlobalStatsManager, reconOMMetadataManager) {