-
Notifications
You must be signed in to change notification settings - Fork 291
Replace non-public ConfigurationImpl with test utility #3381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: integration
Are you sure you want to change the base?
Changes from all commits
dffc1f6
e67157f
b94533e
e58c1e0
7ae6953
4c2e5ae
4e57d32
bd435b3
b496c15
b8e53d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| package datawave.accumulo.core.util; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Iterator; | ||
| import java.util.Map; | ||
| import java.util.function.Function; | ||
| import java.util.function.Supplier; | ||
|
|
||
| import org.apache.accumulo.core.client.PluginEnvironment; | ||
| import org.apache.accumulo.core.conf.AccumuloConfiguration; | ||
| import org.apache.accumulo.core.conf.Property; | ||
| import org.apache.accumulo.core.conf.PropertyType; | ||
|
|
||
| /** | ||
| * A utility class that wraps an AccumuloConfiguration and implements PluginEnvironment.Configuration. This replaces the non-public | ||
| * org.apache.accumulo.core.util.ConfigurationImpl class. | ||
| */ | ||
| public class AccumuloConfigurationWrapper implements PluginEnvironment.Configuration { | ||
|
|
||
| private final AccumuloConfiguration conf; | ||
|
|
||
| public AccumuloConfigurationWrapper(AccumuloConfiguration conf) { | ||
| this.conf = conf; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isSet(String key) { | ||
| return conf.get(key) != null; | ||
| } | ||
|
|
||
| @Override | ||
| public String get(String key) { | ||
| return conf.get(key); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String,String> getWithPrefix(String prefix) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method needs to add validation for the property and call The code in AccumuloConfiguration is special since most properties that use a defined accumulo prefix must be returned as a snapshot set. This is handled in |
||
| // For a defined prefix property, defer to AccumuloConfiguration.getAllPropertiesWithPrefix, which returns a | ||
| // consistent snapshot taken under the configuration's lock. Mirrors the non-public ConfigurationImpl behavior. | ||
| Property propertyPrefix = Property.getPropertyByKey(prefix); | ||
| if (propertyPrefix != null && propertyPrefix.getType() == PropertyType.PREFIX) { | ||
| return conf.getAllPropertiesWithPrefix(propertyPrefix); | ||
| } | ||
| Map<String,String> result = new HashMap<>(); | ||
| for (Map.Entry<String,String> entry : conf) { | ||
| if (entry.getKey().startsWith(prefix)) { | ||
| result.put(entry.getKey(), entry.getValue()); | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String,String> getCustom() { | ||
| return getWithPrefix("general.custom."); | ||
| } | ||
|
|
||
| @Override | ||
| public String getCustom(String keySuffix) { | ||
| return get("general.custom." + keySuffix); | ||
| } | ||
|
|
||
| @Override | ||
| public Map<String,String> getTableCustom() { | ||
| return getWithPrefix("table.custom."); | ||
| } | ||
|
|
||
| @Override | ||
| public String getTableCustom(String keySuffix) { | ||
| return get("table.custom." + keySuffix); | ||
| } | ||
|
|
||
| @Override | ||
| public Iterator<Map.Entry<String,String>> iterator() { | ||
| return conf.iterator(); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> Supplier<T> getDerived(Function<PluginEnvironment.Configuration,T> computeDerivedValue) { | ||
| T value = computeDerivedValue.apply(this); | ||
| return () -> value; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.