Skip to content

Backported Configuration method from accumulo 4#6336

Open
ddanielr wants to merge 3 commits intoapache:2.1from
ddanielr:backport/from-config
Open

Backported Configuration method from accumulo 4#6336
ddanielr wants to merge 3 commits intoapache:2.1from
ddanielr:backport/from-config

Conversation

@ddanielr
Copy link
Copy Markdown
Contributor

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.

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.

Configuration config = Configuration.from(props, true);
assertEquals("bar", config.get("table.custom.foo"));
assertEquals(TABLE_MAJC_RATIO.getDefaultValue(), config.get(TABLE_MAJC_RATIO.getKey()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertEquals(TABLE_MAJC_RATIO.getDefaultValue(), config.get(TABLE_MAJC_RATIO.getKey()));
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.

  public ConfigurationCopy(AccumuloConfiguration parent, Map<String,String> config) {
    this.parent = parent;
    copy.putAll(config);
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants