This is an automated email from the ASF dual-hosted git repository. dlmarion 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 94c4e664af Use ZooCache in ExternalCompactionUtil.findCompactionCoordinator (#3813) 94c4e664af is described below commit 94c4e664afb7bec56e6debb58027576b896c129e Author: Dave Marion <dlmar...@apache.org> AuthorDate: Thu Oct 5 08:11:40 2023 -0400 Use ZooCache in ExternalCompactionUtil.findCompactionCoordinator (#3813) Closes #3783 --- .../core/util/compaction/ExternalCompactionUtil.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java b/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java index 4946027fe5..6f336f0c2b 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java +++ b/core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java @@ -18,6 +18,8 @@ */ package org.apache.accumulo.core.util.compaction; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -34,8 +36,8 @@ import org.apache.accumulo.core.clientImpl.ClientContext; import org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException; import org.apache.accumulo.core.compaction.thrift.CompactorService; import org.apache.accumulo.core.fate.zookeeper.ServiceLock; +import org.apache.accumulo.core.fate.zookeeper.ZooCache.ZcStat; import org.apache.accumulo.core.fate.zookeeper.ZooReader; -import org.apache.accumulo.core.fate.zookeeper.ZooSession; import org.apache.accumulo.core.metadata.schema.ExternalCompactionId; import org.apache.accumulo.core.rpc.ThriftUtil; import org.apache.accumulo.core.rpc.clients.ThriftClientTypes; @@ -98,17 +100,12 @@ public class ExternalCompactionUtil { */ public static Optional<HostAndPort> findCompactionCoordinator(ClientContext context) { final String lockPath = context.getZooKeeperRoot() + Constants.ZCOORDINATOR_LOCK; - try { - var zk = ZooSession.getAnonymousSession(context.getZooKeepers(), - context.getZooKeepersSessionTimeOut()); - byte[] address = ServiceLock.getLockData(zk, ServiceLock.path(lockPath)); - if (null == address) { - return Optional.empty(); - } - return Optional.of(HostAndPort.fromString(new String(address))); - } catch (KeeperException | InterruptedException e) { - throw new RuntimeException(e); + byte[] address = + ServiceLock.getLockData(context.getZooCache(), ServiceLock.path(lockPath), new ZcStat()); + if (null == address) { + return Optional.empty(); } + return Optional.of(HostAndPort.fromString(new String(address, UTF_8))); } /**