You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "ddanielr (via GitHub)" <gi...@apache.org> on 2026/04/24 16:37:09 UTC

[PR] Backported Configuration method from accumulo 4 [accumulo]

ddanielr opened a new pull request, #6336:
URL: https://github.com/apache/accumulo/pull/6336

   Backported the  `Configuration.from` method from accumulo 4 to allow clients the ability to generate a Configuration without needing to fully create a separate Configuration wrapper implementation.
   
   Added some test cases as well.


-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Backported Configuration method from accumulo 4 [accumulo]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #6336:
URL: https://github.com/apache/accumulo/pull/6336#discussion_r4298481649


##########
core/src/test/java/org/apache/accumulo/core/client/PluginEnvironmentTest.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
+ *
+ *   https://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.accumulo.core.client;
+
+import static org.apache.accumulo.core.client.PluginEnvironment.Configuration;
+import static org.apache.accumulo.core.conf.Property.TABLE_MAJC_RATIO;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.junit.jupiter.api.Test;
+
+public class PluginEnvironmentTest {
+
+  @Test
+  public void testFromWithoutDefaultsContainsOnlySuppliedProps() {
+    Map<String,String> props = new HashMap<>();
+    props.put("table.custom.foo", "true");
+    props.put("table.custom.bar", "false");
+
+    Configuration config = Configuration.from(props, false);
+
+    assertEquals("true", config.get("table.custom.foo"));
+    assertEquals("false", config.get("table.custom.bar"));
+
+    assertNull(config.get(TABLE_MAJC_RATIO.getKey()));
+    assertNull(config.get("table.custom.test.missing"));
+  }
+
+  @Test
+  public void testFromWithDefaults() {
+    Map<String,String> props = new HashMap<>();
+    props.put("table.custom.foo", "bar");
+
+    Configuration config = Configuration.from(props, true);
+    assertEquals("bar", config.get("table.custom.foo"));
+    assertEquals(TABLE_MAJC_RATIO.getDefaultValue(), config.get(TABLE_MAJC_RATIO.getKey()));

Review Comment:
   could pull the changes from #6597 and that should make isSet work.



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Backported Configuration method from accumulo 4 [accumulo]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #6336:
URL: https://github.com/apache/accumulo/pull/6336#discussion_r3139158007


##########
core/src/test/java/org/apache/accumulo/core/client/PluginEnvironmentTest.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
+ *
+ *   https://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.accumulo.core.client;
+
+import static org.apache.accumulo.core.client.PluginEnvironment.Configuration;
+import static org.apache.accumulo.core.conf.Property.TABLE_MAJC_RATIO;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.junit.jupiter.api.Test;
+
+public class PluginEnvironmentTest {
+
+  @Test
+  public void testFromWithoutDefaultsContainsOnlySuppliedProps() {
+    Map<String,String> props = new HashMap<>();
+    props.put("table.custom.foo", "true");
+    props.put("table.custom.bar", "false");
+
+    Configuration config = Configuration.from(props, false);
+
+    assertEquals("true", config.get("table.custom.foo"));
+    assertEquals("false", config.get("table.custom.bar"));
+
+    assertNull(config.get(TABLE_MAJC_RATIO.getKey()));
+    assertNull(config.get("table.custom.test.missing"));
+  }
+
+  @Test
+  public void testFromWithDefaults() {
+    Map<String,String> props = new HashMap<>();
+    props.put("table.custom.foo", "bar");
+
+    Configuration config = Configuration.from(props, true);
+    assertEquals("bar", config.get("table.custom.foo"));
+    assertEquals(TABLE_MAJC_RATIO.getDefaultValue(), config.get(TABLE_MAJC_RATIO.getKey()));

Review Comment:
   ```suggestion
       assertEquals(TABLE_MAJC_RATIO.getDefaultValue(), config.get(TABLE_MAJC_RATIO.getKey()));
       assertTrue(config.isSet("table.custom.foo"));
       assertFalse(config.isSet(TABLE_MAJC_RATIO.getKey()));
   ```
   
   
   I think this test would fail, so the behavior is not as realistic. This is an existing problem w/ the 4.0 code.  Maybe we can add a new constructor like the following to support this. Where `isSet()` would only return true if a prop is in `copy` or parent.isSet is true.  We can pass in the DefaultConfiguration object which always returns false for `isSet()`. We would need to make the get methods on ConfigurationCopy read from copy then parent.
   
   ```java
     public ConfigurationCopy(AccumuloConfiguration parent, Map<String,String> config) {
       this.parent = parent;
       copy.putAll(config);
     }
   ```
   



-- 
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: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org