apache / accumulo

Apache Accumulo
https://accumulo.apache.org
Apache License 2.0
1.06k stars 445 forks source link

Use ZooKeeper with a base directory ("chroot") instead of always specifying full path #4809

Open ctubbsii opened 1 month ago

ctubbsii commented 1 month ago

This issue was originally described at https://issues.apache.org/jira/browse/ACCUMULO-4407

We pass around the instanceId a lot in Accumulo, and the vast majority of the time, it's just so we can pass it as part of the path to a ZooKeeper object that is already constructed. We can avoid a lot of this, and simplify the code quite a bit if we just construct the ZooKeeper object using the instanceId as part of the connection string, so all absolute paths are then relative to the instanceId directory, similar to one might do with chroot.

Here's an example of what the code change would look like:

    // the current way
    var directZK = new ZooKeeper(zookeepers, 200, null);
    directZK.getChildren(Constants.ZROOT + "/" + instanceId + Constants.ZNAMESPACES, false)
        .forEach(System.out::println);

    // the better way
    var chrootZK = new ZooKeeper(zookeepers + Constants.ZROOT + "/" + instanceId, 200, null);
    chrootZK.getChildren(Constants.ZNAMESPACES, false).forEach(System.out::println);

We still need to connect without the instanceId when we look up the instanceId from the instance name (which is needed on the client side), but in all other cases, we don't need it.

meatballspaghetti commented 4 weeks ago

I can look into this.