This is an automated email from the ASF dual-hosted git repository. DomGarguilo pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
commit b12146e232d2309128a1e97c4e2d9fd9e425970c Merge: a5979677bc 737cecdb29 Author: Dom G <[email protected]> AuthorDate: Mon Jul 20 10:51:50 2026 -0400 Merge branch '2.1' into main .../org/apache/accumulo/server/util/PropUtil.java | 76 ++++++++++++++++++++++ .../accumulo/server/util/SystemPropUtil.java | 11 +++- 2 files changed, 84 insertions(+), 3 deletions(-) diff --cc server/base/src/main/java/org/apache/accumulo/server/util/PropUtil.java index 7d8bd6f3a8,ccf7989701..869417d0ff --- a/server/base/src/main/java/org/apache/accumulo/server/util/PropUtil.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/PropUtil.java @@@ -25,11 -27,14 +27,16 @@@ import java.util.TreeSet import org.apache.accumulo.core.classloader.ClassLoaderUtil; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.server.ServerContext; ++import org.apache.accumulo.server.conf.store.IdBasedPropStoreKey; + import org.apache.accumulo.server.conf.store.NamespacePropKey; import org.apache.accumulo.server.conf.store.PropStoreKey; +import org.apache.accumulo.server.conf.store.ResourceGroupPropKey; import org.apache.accumulo.server.conf.store.SystemPropKey; + import org.apache.accumulo.server.conf.store.TablePropKey; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicyInfo; + import org.slf4j.Logger; + import org.slf4j.LoggerFactory; public final class PropUtil { @@@ -46,27 -54,28 +56,30 @@@ final Map<String,String> properties) throws IllegalArgumentException { PropUtil.validateProperties(context, propStoreKey, properties); context.getPropStore().putAll(propStoreKey, properties); + logSetProperties(propStoreKey, properties); } - public static void removeProperties(final ServerContext context, - final PropStoreKey<?> propStoreKey, final Collection<String> propertyNames) { + public static void removeProperties(final ServerContext context, final PropStoreKey propStoreKey, + final Collection<String> propertyNames) { context.getPropStore().removeProperties(propStoreKey, propertyNames); + logRemoveProperties(propStoreKey, propertyNames); } - public static void replaceProperties(final ServerContext context, - final PropStoreKey<?> propStoreKey, final long version, final Map<String,String> properties) - throws IllegalArgumentException { + public static void replaceProperties(final ServerContext context, final PropStoreKey propStoreKey, + final long version, final Map<String,String> properties) throws IllegalArgumentException { PropUtil.validateProperties(context, propStoreKey, properties); context.getPropStore().replaceAll(propStoreKey, version, properties); + logReplaceProperties(propStoreKey, version, properties); } - protected static void validateProperties(final ServerContext context, - final PropStoreKey<?> propStoreKey, final Map<String,String> properties) + public static void validateProperties(final ServerContext context, + final PropStoreKey propStoreKey, final Map<String,String> properties) throws IllegalArgumentException { for (Map.Entry<String,String> prop : properties.entrySet()) { - if (!Property.isValidProperty(prop.getKey(), prop.getValue())) { + if ((propStoreKey instanceof SystemPropKey || propStoreKey instanceof ResourceGroupPropKey) + && prop.getKey().startsWith(Property.TABLE_PREFIX.getKey())) { + throwIaeForTablePropInSysConfig(prop.getKey()); + } else if (!Property.isValidProperty(prop.getKey(), prop.getValue())) { String exceptionMessage = "Invalid property for : "; if (!Property.isValidTablePropertyKey(prop.getKey())) { exceptionMessage = "Invalid Table property for : "; @@@ -109,10 -116,65 +122,73 @@@ } } - static void logSetProperties(final PropStoreKey<?> propStoreKey, + public static void throwIaeForTablePropInSysConfig(String prop) { + throw new IllegalArgumentException( + "Table property " + prop + " cannot be set at the system or resource group level." + + " Set table properties at the namespace or table level."); + } + ++ static void logSetProperties(final PropStoreKey propStoreKey, + final Map<String,String> properties) { + if (properties.isEmpty()) { + return; + } + if (CONFIG_LOG.isInfoEnabled()) { + CONFIG_LOG.info("action=set; scope={}; target={}; properties={};", scope(propStoreKey), + target(propStoreKey), printableProperties(properties)); + } + } + - static void logRemoveProperties(final PropStoreKey<?> propStoreKey, ++ static void logRemoveProperties(final PropStoreKey propStoreKey, + final Collection<String> propertyNames) { + if (CONFIG_LOG.isInfoEnabled()) { + CONFIG_LOG.info("action=remove; scope={}; target={}; properties={};", scope(propStoreKey), + target(propStoreKey), new TreeSet<>(propertyNames)); + } + } + - static void logReplaceProperties(final PropStoreKey<?> propStoreKey, final long version, ++ static void logReplaceProperties(final PropStoreKey propStoreKey, final long version, + final Map<String,String> properties) { + if (properties.isEmpty()) { + return; + } + if (CONFIG_LOG.isInfoEnabled()) { + CONFIG_LOG.info("action=modify; scope={}; target={}; version={}; properties={};", + scope(propStoreKey), target(propStoreKey), version, printableProperties(properties)); + } + } + + private static Map<String,String> printableProperties(Map<String,String> properties) { + Map<String,String> printable = new TreeMap<>(); + for (var prop : properties.entrySet()) { + final String key = prop.getKey(); + final String printableValue = Property.isSensitive(key) ? "<hidden>" : prop.getValue(); + printable.put(key, printableValue); + } + return printable; + } + - private static String scope(PropStoreKey<?> propStoreKey) { ++ private static String scope(PropStoreKey propStoreKey) { + if (propStoreKey instanceof SystemPropKey) { + return "system"; ++ } else if (propStoreKey instanceof ResourceGroupPropKey) { ++ return "resourceGroup"; + } else if (propStoreKey instanceof NamespacePropKey) { + return "namespace"; + } else if (propStoreKey instanceof TablePropKey) { + return "table"; + } + return propStoreKey.getClass().getSimpleName(); + } + - private static String target(PropStoreKey<?> propStoreKey) { ++ private static String target(PropStoreKey propStoreKey) { + if (propStoreKey instanceof SystemPropKey) { + return "system"; - } else if (propStoreKey instanceof NamespacePropKey || propStoreKey instanceof TablePropKey) { - return propStoreKey.getId().canonical(); ++ } else if (propStoreKey instanceof IdBasedPropStoreKey<?> idKey) { ++ return idKey.getId().canonical(); + } else { + return propStoreKey.getPath(); + } + } + } diff --cc server/base/src/main/java/org/apache/accumulo/server/util/SystemPropUtil.java index 2be1c29bca,f2ea9df1e2..6fb9573cd1 --- a/server/base/src/main/java/org/apache/accumulo/server/util/SystemPropUtil.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/SystemPropUtil.java @@@ -36,9 -36,11 +36,11 @@@ public class SystemPropUtil public static void setSystemProperty(ServerContext context, String property, String value) throws IllegalArgumentException { - final SystemPropKey key = SystemPropKey.of(context); + final SystemPropKey key = SystemPropKey.of(); - context.getPropStore().putAll(key, - Map.of(validateSystemProperty(context, key, property, value), value)); + Map<String,String> properties = + Map.of(validateSystemProperty(context, key, property, value), value); + context.getPropStore().putAll(key, properties); + PropUtil.logSetProperties(key, properties); } public static void modifyProperties(ServerContext context, long version, @@@ -63,9 -66,11 +66,11 @@@ removePropWithoutDeprecationWarning(context, resolved); } - private static void removePropWithoutDeprecationWarning(ServerContext context, String property) { + public static void removePropWithoutDeprecationWarning(ServerContext context, String property) { logIfFixed(Property.getPropertyByKey(property), null); - context.getPropStore().removeProperties(SystemPropKey.of(), List.of(property)); - SystemPropKey key = SystemPropKey.of(context); ++ SystemPropKey key = SystemPropKey.of(); + context.getPropStore().removeProperties(key, List.of(property)); + PropUtil.logRemoveProperties(key, List.of(property)); } private static String validateSystemProperty(ServerContext context, SystemPropKey key,
