ctubbsii commented on code in PR #5192:
URL: https://github.com/apache/accumulo/pull/5192#discussion_r1901302191


##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooUtil.java:
##########
@@ -170,26 +176,78 @@ private static String getFmtTime(final long epoch) {
   }
 
   /**
-   * Get the ZooKeeper digest based on the instance secret that is used within 
ZooKeeper for
-   * authentication. This method is primary intended to be used to validate 
ZooKeeper ACLs. Use
-   * {@link #digestAuth(ZooKeeper, String)} to add authorizations to ZooKeeper.
+   * Given a zooCache and instanceId, look up the instance name.
    */
-  public static Id getZkDigestAuthId(final String secret) {
+  public static String getInstanceName(ZooSession zk, InstanceId instanceId) {
+    requireNonNull(zk);
+    var instanceIdBytes = 
requireNonNull(instanceId).canonical().getBytes(UTF_8);
+    for (String name : getInstanceNames(zk)) {
+      var bytes = getInstanceIdBytesFromName(zk, name);
+      if (Arrays.equals(bytes, instanceIdBytes)) {
+        return name;
+      }
+    }
+    return null;
+  }
+
+  private static List<String> getInstanceNames(ZooSession zk) {
     try {
-      final String scheme = "digest";
-      String auth = DigestAuthenticationProvider.generateDigest("accumulo:" + 
secret);
-      return new Id(scheme, auth);
-    } catch (NoSuchAlgorithmException ex) {
-      throw new IllegalArgumentException("Could not generate ZooKeeper digest 
string", ex);
+      return new ZooReader(zk).getChildren(Constants.ZROOT + 
Constants.ZINSTANCES);

Review Comment:
   It looks like this was leftover from a previous refactor to try to ensure 
that the ZooKeeper used for these "outside the chroot" tree operations was 
different from the one provided by ServerContext, which is intended to be 
chrooted in the future. However, that is now handled by using a different 
ZooSession object in ServerInfo/ClientInfoImpl for those particular operations.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to