Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
sadanand48 commented on code in PR #8073:
URL: https://github.com/apache/ozone/pull/8073#discussion_r1995034523
##
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/TypedTable.java:
##
@@ -94,25 +95,33 @@ public TypedTable(RDBTable rawTable,
CodecRegistry codecRegistry, Class keyType,
Class valueType,
CacheType cacheType, String threadNamePrefix) throws IOException {
-this.rawTable = Objects.requireNonNull(rawTable, "rawTable==null");
-Objects.requireNonNull(codecRegistry, "codecRegistry == null");
-
-this.keyType = Objects.requireNonNull(keyType, "keyType == null");
-this.keyCodec = codecRegistry.getCodecFromClass(keyType);
-Objects.requireNonNull(keyCodec, "keyCodec == null");
-
-this.valueType = Objects.requireNonNull(valueType, "valueType == null");
-this.valueCodec = codecRegistry.getCodecFromClass(valueType);
-Objects.requireNonNull(valueCodec, "valueCodec == null");
-
-this.supportCodecBuffer = keyCodec.supportCodecBuffer()
Review Comment:
These null checks are bypassed, if keyType/valuetype is null it will throw
an IllegalStateException . We can keep these checks.
Objects.requireNonNull(keyType, "keyType == null");
Objects.requireNonNull(valueType, "valueType == null");
--
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]
Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
sumitagrawl commented on code in PR #8073: URL: https://github.com/apache/ozone/pull/8073#discussion_r1994796893 ## hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBStore.java: ## @@ -302,6 +302,12 @@ public TypedTable getTable(String name, valueType); } + public TypedTable getTable( Review Comment: This will be used for Recon cases in NSSummary where it just need size and parent object Id from KeyInfoTable. Similarly other places in Recon, and OM, this will be used. Will raise separate JIRA for handling this. -- 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]
Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
szetszwo commented on code in PR #8073:
URL: https://github.com/apache/ozone/pull/8073#discussion_r1994448351
##
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/TypedTable.java:
##
@@ -87,32 +88,43 @@ public TypedTable(RDBTable rawTable,
* @param keyType The key type.
* @param valueType The value type.
* @param cacheType How to cache the entries?
- * @param threadNamePrefix
+ * @param threadNamePrefix the thread name prefix
Review Comment:
Please don't change `threadNamePrefix`; see HDDS-12590.
##
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBStore.java:
##
@@ -302,6 +302,12 @@ public TypedTable getTable(String name,
valueType);
}
+ public TypedTable getTable(
Review Comment:
This new method is only used in test. How are you going to use it?
##
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableNoCache.java:
##
@@ -0,0 +1,97 @@
+/*
+ * 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.hdds.utils.db.cache;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.Set;
+import org.apache.hadoop.hdds.annotation.InterfaceAudience.Private;
+import org.apache.hadoop.hdds.annotation.InterfaceStability.Evolving;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Cache implementation for the table. Partial Table cache, where the DB state
+ * and cache state will not be same. Partial table cache holds entries until
+ * flush to DB happens.
+ * @param
+ * @param
Review Comment:
Please don't copy javadoc. No javadoc is better than incorrect/misleading
javadoc.
##
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableNoCache.java:
##
@@ -0,0 +1,97 @@
+/*
+ * 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.hdds.utils.db.cache;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.Set;
+import org.apache.hadoop.hdds.annotation.InterfaceAudience.Private;
+import org.apache.hadoop.hdds.annotation.InterfaceStability.Evolving;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Cache implementation for the table. Partial Table cache, where the DB state
+ * and cache state will not be same. Partial table cache holds entries until
+ * flush to DB happens.
+ * @param
+ * @param
+ */
+@Private
+@Evolving
+public class TableNoCache implements TableCache {
Review Comment:
`TableNoCache` should be singleton.
##
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/cache/TableNoCache.java:
##
@@ -0,0 +1,97 @@
+/*
+ * 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-
Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
adoroszlai commented on PR #8066: URL: https://github.com/apache/ozone/pull/8066#issuecomment-2722205196 @sumitagrawl No need to open new PR when changing the approach to fix/implement something. It's better to keep discussion in a single PR. -- 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]
Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
sumitagrawl commented on PR #8073: URL: https://github.com/apache/ozone/pull/8073#issuecomment-2722210824 > @sumitagrawl , if there is a more efficient codec, we should replace the existing codec with it instead adding this custom codec feature. Efficiency here is based on usecase, Suppose for iteration, if Value is not required to be deserialized, can have codec of not doing anything. But default always deserialize. Further, can have different target of deserialization, like, * Existing, byte[] --> KeyInfo --> OMKeyInfo * Can have others, byte[] --> KeyInfo --> **OMLightKeyInfo** -- 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]
Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
sumitagrawl commented on PR #8066: URL: https://github.com/apache/ozone/pull/8066#issuecomment-2722142473 > @sumitagrawl , if there is a more efficient codec, we should replace the existing codec with it instead adding this custom codec feature. > > BTW, why there is another PR #8073 ? Raised https://github.com/apache/ozone/pull/8073 as updating iterator does not seems handle all cases. Like if need for getKey(), need expose another method overloading to add valueCodec. -- 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]
Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
sumitagrawl closed pull request #8066: HDDS-12582. TypedTable support custom ValueCodec URL: https://github.com/apache/ozone/pull/8066 -- 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]
Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
sumitagrawl commented on PR #8066: URL: https://github.com/apache/ozone/pull/8066#issuecomment-2722136901 Raised https://github.com/apache/ozone/pull/8073 changing the way to support. -- 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]
Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
szetszwo commented on PR #8066: URL: https://github.com/apache/ozone/pull/8066#issuecomment-2721920871 @sumitagrawl , if there is a more efficient codec, we should replace the existing codec with it instead adding this custom codec feature. BTW, why there is another PR https://github.com/apache/ozone/pull/8073 ? -- 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]
Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
szetszwo commented on PR #8073: URL: https://github.com/apache/ozone/pull/8073#issuecomment-2721915799 @sumitagrawl , if there is a more efficient codec, we should replace the existing codec with it instead adding this custom codec feature. -- 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]
Re: [PR] HDDS-12582. TypedTable support custom ValueCodec [ozone]
sadanand48 commented on PR #8066:
URL: https://github.com/apache/ozone/pull/8066#issuecomment-2720976952
```diff
diff --git
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmMetadataManager.java
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmMetadataManager.java
index 5c0699c2cb..d7a4149c57 100644
---
a/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmMetadataManager.java
+++
b/hadoop-ozone/ozone-manager/src/test/java/org/apache/hadoop/ozone/om/TestOmMetadataManager.java
@@ -28,6 +28,7 @@
import static
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.VOLUME_NOT_FOUND;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -42,6 +43,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Random;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
@@ -49,19 +51,29 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import org.apache.hadoop.hdds.client.BlockID;
import org.apache.hadoop.hdds.client.RatisReplicationConfig;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.StorageType;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.scm.HddsTestUtils;
+import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
import org.apache.hadoop.hdds.utils.TransactionInfo;
+import org.apache.hadoop.hdds.utils.db.Codec;
+import org.apache.hadoop.hdds.utils.db.DelegatedCodec;
+import org.apache.hadoop.hdds.utils.db.Proto2Codec;
+import org.apache.hadoop.hdds.utils.db.Table;
+import org.apache.hadoop.hdds.utils.db.TableIterator;
import org.apache.hadoop.hdds.utils.db.cache.CacheKey;
import org.apache.hadoop.hdds.utils.db.cache.CacheValue;
+import org.apache.hadoop.ozone.ClientVersion;
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes;
import org.apache.hadoop.ozone.om.helpers.BucketLayout;
import org.apache.hadoop.ozone.om.helpers.ListOpenFilesResult;
import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
+import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfo;
import org.apache.hadoop.ozone.om.helpers.OmKeyLocationInfoGroup;
import org.apache.hadoop.ozone.om.helpers.OmMultipartKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmMultipartUpload;
@@ -71,6 +83,7 @@
import org.apache.hadoop.ozone.om.helpers.SnapshotInfo;
import org.apache.hadoop.ozone.om.request.OMRequestTestUtils;
import org.apache.hadoop.ozone.om.request.util.OMMultipartUploadUtils;
+import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ExpiredMultipartUploadInfo;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.ExpiredMultipartUploadsBucket;
import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OpenKey;
@@ -155,6 +168,63 @@ public void testListVolumes() throws Exception {
assertEquals(volumeList.size(), totalVol - startOrder - 1);
}
+ private OmKeyInfo getSampleKeyInfo() {
+int blockNum = 1;
+List omKeyLocationInfoList = new ArrayList<>();
+Pipeline pipeline = HddsTestUtils.getRandomPipeline();
+BlockID blockID = new BlockID(blockNum, blockNum);
+OmKeyLocationInfo keyLocationInfo =
+new
OmKeyLocationInfo.Builder().setBlockID(blockID).setPipeline(pipeline).build();
+omKeyLocationInfoList.add(keyLocationInfo);
+OmKeyLocationInfoGroup omKeyLocationInfoGroup = new
OmKeyLocationInfoGroup(0, omKeyLocationInfoList);
+return new
OmKeyInfo.Builder().setCreationTime(Time.now()).setModificationTime(Time.now())
+
.setReplicationConfig(RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.THREE))
+.setVolumeName("volume").setBucketName("bucket").setKeyName("key" +
new Random().nextInt(100))
+.setObjectID(Time.now()).setUpdateID(Time.now()).setDataSize(100)
+
.setOmKeyLocationInfos(Collections.singletonList(omKeyLocationInfoGroup)).build();
+ }
+
+ private static Codec customCodec() {
+return new DelegatedCodec<>(
+
Proto2Codec.get(OzoneManagerProtocolProtos.KeyInfo.getDefaultInstance()),
+TestOmMet
