This is an automated email from the ASF dual-hosted git repository.

DomGarguilo pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new 737cecdb29 Log ZooKeeper-backed property changes (#6465)
737cecdb29 is described below

commit 737cecdb2986de1ebdfb1cc1c87638f1f94ec277
Author: Dom G. <[email protected]>
AuthorDate: Mon Jul 20 10:26:19 2026 -0400

    Log ZooKeeper-backed property changes (#6465)
    
    Add a logger to log when zookeeper-backed properties are changed along with 
details about the change
---
 .../org/apache/accumulo/server/util/PropUtil.java  | 75 ++++++++++++++++++++++
 .../accumulo/server/util/SystemPropUtil.java       | 11 +++-
 2 files changed, 83 insertions(+), 3 deletions(-)

diff --git 
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
index d5776a5850..ccf7989701 100644
--- 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
@@ -21,16 +21,26 @@ package org.apache.accumulo.server.util;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Map;
+import java.util.TreeMap;
+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.NamespacePropKey;
 import org.apache.accumulo.server.conf.store.PropStoreKey;
+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 {
 
+  private static final Logger CONFIG_LOG =
+      LoggerFactory.getLogger("org.apache.accumulo.configuration");
+
   private PropUtil() {}
 
   /**
@@ -44,11 +54,13 @@ public final class PropUtil {
       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) {
     context.getPropStore().removeProperties(propStoreKey, propertyNames);
+    logRemoveProperties(propStoreKey, propertyNames);
   }
 
   public static void replaceProperties(final ServerContext context,
@@ -56,6 +68,7 @@ public final class PropUtil {
       throws IllegalArgumentException {
     PropUtil.validateProperties(context, propStoreKey, properties);
     context.getPropStore().replaceAll(propStoreKey, version, properties);
+    logReplaceProperties(propStoreKey, version, properties);
   }
 
   protected static void validateProperties(final ServerContext context,
@@ -102,4 +115,66 @@ public final class PropUtil {
       }
     }
   }
+
+  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,
+      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,
+      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) {
+    if (propStoreKey instanceof SystemPropKey) {
+      return "system";
+    } else if (propStoreKey instanceof NamespacePropKey) {
+      return "namespace";
+    } else if (propStoreKey instanceof TablePropKey) {
+      return "table";
+    }
+    return propStoreKey.getClass().getSimpleName();
+  }
+
+  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 {
+      return propStoreKey.getPath();
+    }
+  }
+
 }
diff --git 
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
index 1adc07a53c..f2ea9df1e2 100644
--- 
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
@@ -37,8 +37,10 @@ public class SystemPropUtil {
   public static void setSystemProperty(ServerContext context, String property, 
String value)
       throws IllegalArgumentException {
     final SystemPropKey key = SystemPropKey.of(context);
-    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,
@@ -50,6 +52,7 @@ public class SystemPropUtil {
                 entry -> validateSystemProperty(context, key, entry.getKey(), 
entry.getValue()),
                 Map.Entry::getValue));
     context.getPropStore().replaceAll(key, version, checkedProperties);
+    PropUtil.logReplaceProperties(key, version, checkedProperties);
   }
 
   public static void removeSystemProperty(ServerContext context, String 
property) {
@@ -65,7 +68,9 @@ public class SystemPropUtil {
 
   private static void removePropWithoutDeprecationWarning(ServerContext 
context, String property) {
     logIfFixed(Property.getPropertyByKey(property), null);
-    context.getPropStore().removeProperties(SystemPropKey.of(context), 
List.of(property));
+    SystemPropKey key = SystemPropKey.of(context);
+    context.getPropStore().removeProperties(key, List.of(property));
+    PropUtil.logRemoveProperties(key, List.of(property));
   }
 
   private static String validateSystemProperty(ServerContext context, 
SystemPropKey key,

Reply via email to