This is an automated email from the ASF dual-hosted git repository.
edcoleman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new 2d90a5c610 Add id info to config check utility (#3141)
2d90a5c610 is described below
commit 2d90a5c6101b6228c5d4ca7d524ece9b6518f2d3
Author: EdColeman <[email protected]>
AuthorDate: Thu Jan 5 09:06:38 2023 -0500
Add id info to config check utility (#3141)
* Add id info to config check utility
---
core/pom.xml | 4 ++++
.../org/apache/accumulo/core/conf/ConfigCheckUtil.java | 12 +++++++-----
.../org/apache/accumulo/core/conf/SiteConfiguration.java | 2 +-
.../apache/accumulo/core/conf/ConfigCheckUtilTest.java | 16 ++++++++--------
.../accumulo/core/conf/DefaultConfigurationTest.java | 2 +-
.../accumulo/server/conf/ServerConfigurationFactory.java | 4 ++--
6 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/core/pom.xml b/core/pom.xml
index b04b47f565..68de14175b 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -137,6 +137,10 @@
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper-jute</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.checkerframework</groupId>
+ <artifactId>checker-qual</artifactId>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
diff --git
a/core/src/main/java/org/apache/accumulo/core/conf/ConfigCheckUtil.java
b/core/src/main/java/org/apache/accumulo/core/conf/ConfigCheckUtil.java
index b9e7ecfff3..409062dbe2 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/ConfigCheckUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/ConfigCheckUtil.java
@@ -23,6 +23,7 @@ import java.util.Map.Entry;
import java.util.Objects;
import org.apache.accumulo.core.spi.crypto.CryptoServiceFactory;
+import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,9 +44,10 @@ public class ConfigCheckUtil {
* {@link Property#INSTANCE_ZK_TIMEOUT} within a valid range.
*
* @param entries iterable through configuration keys and values
+ * @param source the namespace, table id, site or system config where for
diagnostic messages
* @throws ConfigCheckException if a fatal configuration error is found
*/
- public static void validate(Iterable<Entry<String,String>> entries) {
+ public static void validate(Iterable<Entry<String,String>> entries, @NonNull
String source) {
String instanceZkTimeoutValue = null;
for (Entry<String,String> entry : entries) {
String key = entry.getKey();
@@ -54,12 +56,12 @@ public class ConfigCheckUtil {
if (prop == null && Property.isValidPropertyKey(key)) {
continue; // unknown valid property (i.e. has proper prefix)
} else if (prop == null) {
- log.warn(PREFIX + "unrecognized property key (" + key + ")");
+ log.warn(PREFIX + "unrecognized property key ({}) for {}", key,
source);
} else if (prop.getType() == PropertyType.PREFIX) {
- fatal(PREFIX + "incomplete property key (" + key + ")");
+ fatal(PREFIX + "incomplete property key (" + key + ") for " + source);
} else if (!prop.getType().isValidFormat(value)) {
fatal(PREFIX + "improperly formatted value for key (" + key + ",
type=" + prop.getType()
- + ") : " + value);
+ + ") : " + value + " for " + source);
}
if (key.equals(Property.INSTANCE_ZK_TIMEOUT.getKey())) {
@@ -128,7 +130,7 @@ public class ConfigCheckUtil {
}
/**
- * The exception thrown when {@link ConfigCheckUtil#validate(Iterable)}
fails.
+ * The exception thrown when {@link ConfigCheckUtil#validate(Iterable,
String)} fails.
*/
public static class ConfigCheckException extends RuntimeException {
private static final long serialVersionUID = 1L;
diff --git
a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
index d0e248b2e7..d965708c93 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
@@ -209,7 +209,7 @@ public class SiteConfiguration extends
AccumuloConfiguration {
private final Map<String,String> config;
private SiteConfiguration(Map<String,String> config) {
- ConfigCheckUtil.validate(config.entrySet());
+ ConfigCheckUtil.validate(config.entrySet(), "site config");
this.config = config;
}
diff --git
a/core/src/test/java/org/apache/accumulo/core/conf/ConfigCheckUtilTest.java
b/core/src/test/java/org/apache/accumulo/core/conf/ConfigCheckUtilTest.java
index 258e38075f..e204316c50 100644
--- a/core/src/test/java/org/apache/accumulo/core/conf/ConfigCheckUtilTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/conf/ConfigCheckUtilTest.java
@@ -40,51 +40,51 @@ public class ConfigCheckUtilTest {
m.put(Property.MANAGER_TABLET_BALANCER.getKey(),
"org.apache.accumulo.server.manager.balancer.TableLoadBalancer");
m.put(Property.MANAGER_BULK_RETRIES.getKey(), "3");
- ConfigCheckUtil.validate(m.entrySet());
+ ConfigCheckUtil.validate(m.entrySet(), "test");
}
@Test
public void testPass_Empty() {
- ConfigCheckUtil.validate(m.entrySet());
+ ConfigCheckUtil.validate(m.entrySet(), "test");
}
@Test
public void testPass_UnrecognizedValidProperty() {
m.put(Property.MANAGER_CLIENTPORT.getKey(), "9999");
m.put(Property.MANAGER_PREFIX.getKey() + "something", "abcdefg");
- ConfigCheckUtil.validate(m.entrySet());
+ ConfigCheckUtil.validate(m.entrySet(), "test");
}
@Test
public void testPass_UnrecognizedProperty() {
m.put(Property.MANAGER_CLIENTPORT.getKey(), "9999");
m.put("invalid.prefix.value", "abcdefg");
- ConfigCheckUtil.validate(m.entrySet());
+ ConfigCheckUtil.validate(m.entrySet(), "test");
}
@Test
public void testFail_Prefix() {
m.put(Property.MANAGER_CLIENTPORT.getKey(), "9999");
m.put(Property.MANAGER_PREFIX.getKey(), "oops");
- assertThrows(ConfigCheckException.class, () ->
ConfigCheckUtil.validate(m.entrySet()));
+ assertThrows(ConfigCheckException.class, () ->
ConfigCheckUtil.validate(m.entrySet(), "test"));
}
@Test
public void testFail_InstanceZkTimeoutOutOfRange() {
m.put(Property.INSTANCE_ZK_TIMEOUT.getKey(), "10ms");
- assertThrows(ConfigCheckException.class, () ->
ConfigCheckUtil.validate(m.entrySet()));
+ assertThrows(ConfigCheckException.class, () ->
ConfigCheckUtil.validate(m.entrySet(), "test"));
}
@Test
public void testFail_badCryptoFactory() {
m.put(Property.INSTANCE_CRYPTO_FACTORY.getKey(),
"DoesNotExistCryptoFactory");
- assertThrows(ConfigCheckException.class, () ->
ConfigCheckUtil.validate(m.entrySet()));
+ assertThrows(ConfigCheckException.class, () ->
ConfigCheckUtil.validate(m.entrySet(), "test"));
}
@Test
public void testPass_defaultCryptoFactory() {
m.put(Property.INSTANCE_CRYPTO_FACTORY.getKey(),
Property.INSTANCE_CRYPTO_FACTORY.getDefaultValue());
- ConfigCheckUtil.validate(m.entrySet());
+ ConfigCheckUtil.validate(m.entrySet(), "test");
}
}
diff --git
a/core/src/test/java/org/apache/accumulo/core/conf/DefaultConfigurationTest.java
b/core/src/test/java/org/apache/accumulo/core/conf/DefaultConfigurationTest.java
index 123b5bc326..8ddecfbdf3 100644
---
a/core/src/test/java/org/apache/accumulo/core/conf/DefaultConfigurationTest.java
+++
b/core/src/test/java/org/apache/accumulo/core/conf/DefaultConfigurationTest.java
@@ -52,6 +52,6 @@ public class DefaultConfigurationTest {
@Test
public void testSanityCheck() {
- ConfigCheckUtil.validate(c);
+ ConfigCheckUtil.validate(c, "test");
}
}
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
index 287e9bca44..bd2d0b1ace 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/conf/ServerConfigurationFactory.java
@@ -105,7 +105,7 @@ public class ServerConfigurationFactory extends
ServerConfiguration {
context.getPropStore().registerAsListener(TablePropKey.of(context,
tableId), deleteWatcher);
var conf =
new TableConfiguration(context, tableId,
getNamespaceConfigurationForTable(tableId));
- ConfigCheckUtil.validate(conf);
+ ConfigCheckUtil.validate(conf, tableId.toString());
return conf;
}
return null;
@@ -129,7 +129,7 @@ public class ServerConfigurationFactory extends
ServerConfiguration {
context.getPropStore().registerAsListener(NamespacePropKey.of(context,
namespaceId),
deleteWatcher);
var conf = new NamespaceConfiguration(context, namespaceId,
getSystemConfiguration());
- ConfigCheckUtil.validate(conf);
+ ConfigCheckUtil.validate(conf, namespaceId.toString());
return conf;
});
}