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

kturner 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 5583129435 Return non-merged view of System config (#4120)
5583129435 is described below

commit 5583129435a639be6ee2bd1e432ab1194fb353e0
Author: Kevin Rathbun <43969518+kevinrr...@users.noreply.github.com>
AuthorDate: Thu Jan 4 18:46:35 2024 -0500

    Return non-merged view of System config (#4120)
    
    - Added getSystemProperties() to InstanceOperations which functions
      similary to getTableProperties() and getNamespaceProperties() from
    TableOperations and NamespaceOperations.
    - Added its implementation in InstanceOperationsImpl.
    - Added a test getSystemPropertiesTest() to PropStoreConfigIT to test
      that the new method functions as intended.
---
 .../core/client/admin/InstanceOperations.java      | 10 ++++++
 .../core/clientImpl/InstanceOperationsImpl.java    |  7 ++++
 .../accumulo/test/conf/PropStoreConfigIT.java      | 41 ++++++++++++++++++++++
 3 files changed, 58 insertions(+)

diff --git 
a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java
 
b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java
index 9cc3aa3658..4cb3f6d196 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/client/admin/InstanceOperations.java
@@ -166,6 +166,16 @@ public interface InstanceOperations {
    */
   Map<String,String> getSiteConfiguration() throws AccumuloException, 
AccumuloSecurityException;
 
+  /**
+   * Retrieve a map of the system properties set in Zookeeper. Note that this 
does not return a
+   * merged view of the properties from its parent configuration. See
+   * {@link #getSystemConfiguration} for a merged view.
+   *
+   * @return A map of the system properties set in Zookeeper only.
+   * @since 3.1
+   */
+  Map<String,String> getSystemProperties() throws AccumuloException, 
AccumuloSecurityException;
+
   /**
    * Returns the location(s) of the accumulo manager and any redundant servers.
    *
diff --git 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/InstanceOperationsImpl.java
 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/InstanceOperationsImpl.java
index 52389ad365..c71b79c39a 100644
--- 
a/core/src/main/java/org/apache/accumulo/core/clientImpl/InstanceOperationsImpl.java
+++ 
b/core/src/main/java/org/apache/accumulo/core/clientImpl/InstanceOperationsImpl.java
@@ -206,6 +206,13 @@ public class InstanceOperationsImpl implements 
InstanceOperations {
         .getConfiguration(TraceUtil.traceInfo(), context.rpcCreds(), 
ConfigurationType.SITE));
   }
 
+  @Override
+  public Map<String,String> getSystemProperties()
+      throws AccumuloException, AccumuloSecurityException {
+    return ThriftClientTypes.CLIENT.execute(context,
+        client -> client.getSystemProperties(TraceUtil.traceInfo(), 
context.rpcCreds()));
+  }
+
   @Override
   public List<String> getManagerLocations() {
     return context.getManagerLocations();
diff --git 
a/test/src/main/java/org/apache/accumulo/test/conf/PropStoreConfigIT.java 
b/test/src/main/java/org/apache/accumulo/test/conf/PropStoreConfigIT.java
index ea9e52f56c..0fb40ab9de 100644
--- a/test/src/main/java/org/apache/accumulo/test/conf/PropStoreConfigIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/conf/PropStoreConfigIT.java
@@ -330,6 +330,47 @@ public class PropStoreConfigIT extends 
SharedMiniClusterBase {
     }
   }
 
+  @Test
+  public void getSystemPropertiesTest() throws Exception {
+
+    // Tests that getSystemProperties() does not return a merged view (only 
returns props set at the
+    // system level).
+    // Compares this with getSystemConfiguration() which does return a merged 
view (system + site +
+    // default).
+
+    String customPropKey1 = "table.custom.prop1";
+    String customPropKey2 = "table.custom.prop2";
+    String customPropVal1 = "v1";
+    String customPropVal2 = "v2";
+    try (var client = Accumulo.newClient().from(getClientProps()).build()) {
+      // non-merged view
+      Map<String,String> sysProps = 
client.instanceOperations().getSystemProperties();
+      // merged view
+      Map<String,String> sysConfig = 
client.instanceOperations().getSystemConfiguration();
+      // sysProps is non-merged view, so should be empty at this point (no 
system props set yet)
+      assertTrue(sysProps.isEmpty());
+      // sysConfig is merged view, so will have some props already (default 
properties and those
+      // inherited from site config)
+      assertFalse(sysConfig.isEmpty());
+      client.instanceOperations().setProperty(customPropKey1, customPropVal1);
+      client.instanceOperations().setProperty(customPropKey2, customPropVal2);
+      Wait.waitFor(() -> 
client.instanceOperations().getSystemConfiguration().get(customPropKey1)
+          .equals(customPropVal1), 5000, 500);
+      Wait.waitFor(() -> 
client.instanceOperations().getSystemConfiguration().get(customPropKey2)
+          .equals(customPropVal2), 5000, 500);
+      sysProps = client.instanceOperations().getSystemProperties();
+      // The custom props should be present (and the only props) in the 
non-merged view
+      assertEquals(2, sysProps.size());
+      assertEquals(customPropVal1, sysProps.get(customPropKey1));
+      assertEquals(customPropVal2, sysProps.get(customPropKey2));
+      sysConfig = client.instanceOperations().getSystemConfiguration();
+      // The custom props should be present in the merged view
+      assertTrue(sysConfig.size() > 2);
+      assertEquals(customPropVal1, sysConfig.get(customPropKey1));
+      assertEquals(customPropVal2, sysConfig.get(customPropKey2));
+    }
+  }
+
   @Test
   public void modifyTablePropTest() throws Exception {
     String table = getUniqueNames(1)[0];

Reply via email to