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

sammichen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d77fb4016 HDDS-10423. Datanode fails to start with invalid checksum 
size setting (#6276)
2d77fb4016 is described below

commit 2d77fb401621d295ac9f0af5a7d9c2b20bc24968
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Tue Feb 27 07:43:11 2024 +0100

    HDDS-10423. Datanode fails to start with invalid checksum size setting 
(#6276)
---
 .../hadoop/hdds/scm/TestOzoneClientConfig.java     | 38 ++++++++++++++++++++++
 .../org/apache/hadoop/hdds/conf/ConfigType.java    |  6 ++--
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git 
a/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/TestOzoneClientConfig.java
 
b/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/TestOzoneClientConfig.java
new file mode 100644
index 0000000000..88f27eae6d
--- /dev/null
+++ 
b/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/TestOzoneClientConfig.java
@@ -0,0 +1,38 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.scm;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class TestOzoneClientConfig {
+
+  @Test
+  void missingSizeSuffix() {
+    final int bytes = 1024;
+
+    OzoneConfiguration conf = new OzoneConfiguration();
+    conf.setInt("ozone.client.bytes.per.checksum", bytes);
+
+    OzoneClientConfig subject = conf.getObject(OzoneClientConfig.class);
+
+    assertEquals(bytes, subject.getBytesPerChecksum());
+  }
+}
diff --git 
a/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/ConfigType.java 
b/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/ConfigType.java
index 4ed59669a9..e121e4333a 100644
--- 
a/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/ConfigType.java
+++ 
b/hadoop-hdds/config/src/main/java/org/apache/hadoop/hdds/conf/ConfigType.java
@@ -118,7 +118,7 @@ public enum ConfigType {
   SIZE {
     @Override
     Object parse(String value, Config config, Class<?> type, String key) {
-      StorageSize measure = StorageSize.parse(value);
+      StorageSize measure = StorageSize.parse(value, config.sizeUnit());
       long val = Math.round(measure.getUnit().toBytes(measure.getValue()));
       if (type == int.class) {
         return (int) val;
@@ -130,9 +130,9 @@ public enum ConfigType {
     void set(ConfigurationTarget target, String key, Object value,
         Config config) {
       if (value instanceof Long) {
-        target.setStorageSize(key, (long) value, StorageUnit.BYTES);
+        target.setStorageSize(key, (long) value, config.sizeUnit());
       } else if (value instanceof Integer) {
-        target.setStorageSize(key, (int) value, StorageUnit.BYTES);
+        target.setStorageSize(key, (int) value, config.sizeUnit());
       } else {
         throw new ConfigurationException("Unsupported type " + value.getClass()
             + " for " + key);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to