This is an automated email from the ASF dual-hosted git repository.
ctubbsii pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/3.1 by this push:
new d90dfc3223 Change names of zookeepers to connectString (#5092)
d90dfc3223 is described below
commit d90dfc3223ffc99bb2d2fd641df2d1830ec82ad8
Author: Christopher Tubbs <[email protected]>
AuthorDate: Thu Nov 21 17:15:10 2024 -0500
Change names of zookeepers to connectString (#5092)
Trivial change to zookeepers parameter to indicate that it's a
connectionString
rather than merely a host or a list of hosts for zookeeper.
Co-authored-by: meatballspaghetti
<[email protected]>
---
.../accumulo/core/fate/zookeeper/ZooReader.java | 10 ++++----
.../core/fate/zookeeper/ZooReaderWriter.java | 6 ++---
.../accumulo/core/fate/zookeeper/ZooSession.java | 29 +++++++++++-----------
3 files changed, 23 insertions(+), 22 deletions(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooReader.java
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooReader.java
index 1df0b54bf3..9d9738de1b 100644
--- a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooReader.java
+++ b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooReader.java
@@ -45,20 +45,20 @@ public class ZooReader {
.incrementBy(Duration.ofMillis(250)).maxWait(Duration.ofMinutes(2)).backOffFactor(1.5)
.logInterval(Duration.ofMinutes(3)).createFactory();
- protected final String keepers;
+ protected final String connectString;
protected final int timeout;
- public ZooReader(String keepers, int timeout) {
- this.keepers = requireNonNull(keepers);
+ public ZooReader(String connectString, int timeout) {
+ this.connectString = requireNonNull(connectString);
this.timeout = timeout;
}
public ZooReaderWriter asWriter(String secret) {
- return new ZooReaderWriter(keepers, timeout, secret);
+ return new ZooReaderWriter(connectString, timeout, secret);
}
protected ZooKeeper getZooKeeper() {
- return ZooSession.getAnonymousSession(keepers, timeout);
+ return ZooSession.getAnonymousSession(connectString, timeout);
}
protected RetryFactory getRetryFactory() {
diff --git
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooReaderWriter.java
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooReaderWriter.java
index 960c890ccf..ed0566bbba 100644
---
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooReaderWriter.java
+++
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooReaderWriter.java
@@ -49,8 +49,8 @@ public class ZooReaderWriter extends ZooReader {
private final String secret;
private final byte[] auth;
- ZooReaderWriter(String keepers, int timeoutInMillis, String secret) {
- super(keepers, timeoutInMillis);
+ ZooReaderWriter(String connectString, int timeoutInMillis, String secret) {
+ super(connectString, timeoutInMillis);
this.secret = requireNonNull(secret);
this.auth = ("accumulo:" + secret).getBytes(UTF_8);
}
@@ -65,7 +65,7 @@ public class ZooReaderWriter extends ZooReader {
@Override
public ZooKeeper getZooKeeper() {
- return ZooSession.getAuthenticatedSession(keepers, timeout, "digest",
auth);
+ return ZooSession.getAuthenticatedSession(connectString, timeout,
"digest", auth);
}
/**
diff --git
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooSession.java
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooSession.java
index 91085f27cc..d3cee2bb8b 100644
--- a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooSession.java
+++ b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/ZooSession.java
@@ -100,13 +100,14 @@ public class ZooSession {
}
/**
- * @param host comma separated list of zk servers
+ * @param connectString in the form of host1:port1,host2:port2/chroot/path
* @param timeout in milliseconds
* @param scheme authentication type, e.g. 'digest', may be null
* @param auth authentication-scheme-specific token, may be null
* @param watcher ZK notifications, may be null
*/
- static ZooKeeper connect(String host, int timeout, String scheme, byte[]
auth, Watcher watcher) {
+ static ZooKeeper connect(String connectString, int timeout, String scheme,
byte[] auth,
+ Watcher watcher) {
final int TIME_BETWEEN_CONNECT_CHECKS_MS = 100;
int connectTimeWait = Math.min(10_000, timeout);
boolean tryAgain = true;
@@ -117,7 +118,7 @@ public class ZooSession {
while (tryAgain) {
try {
- zooKeeper = new ZooKeeper(host, timeout, watcher);
+ zooKeeper = new ZooKeeper(connectString, timeout, watcher);
// it may take some time to get connected to zookeeper if some of the
servers are down
for (int i = 0; i < connectTimeWait / TIME_BETWEEN_CONNECT_CHECKS_MS
&& tryAgain; i++) {
if (zooKeeper.getState().equals(States.CONNECTED)) {
@@ -155,7 +156,7 @@ public class ZooSession {
long duration = NANOSECONDS.toMillis(stopTime - startTime);
if (duration > 2L * timeout) {
- throw new IllegalStateException("Failed to connect to zookeeper (" +
host
+ throw new IllegalStateException("Failed to connect to zookeeper (" +
connectString
+ ") within 2x zookeeper timeout period " + timeout);
}
@@ -177,16 +178,16 @@ public class ZooSession {
return zooKeeper;
}
- public static ZooKeeper getAuthenticatedSession(String zooKeepers, int
timeout, String scheme,
+ public static ZooKeeper getAuthenticatedSession(String connectString, int
timeout, String scheme,
byte[] auth) {
- return getSession(zooKeepers, timeout, scheme, auth);
+ return getSession(connectString, timeout, scheme, auth);
}
- public static ZooKeeper getAnonymousSession(String zooKeepers, int timeout) {
- return getSession(zooKeepers, timeout, null, null);
+ public static ZooKeeper getAnonymousSession(String connectString, int
timeout) {
+ return getSession(connectString, timeout, null, null);
}
- private static synchronized ZooKeeper getSession(String zooKeepers, int
timeout, String scheme,
+ private static synchronized ZooKeeper getSession(String connectString, int
timeout, String scheme,
byte[] auth) {
if (sessions == null) {
@@ -195,13 +196,13 @@ public class ZooSession {
+ "caused by all AccumuloClients being closed or garbage
collected.");
}
- String sessionKey = sessionKey(zooKeepers, timeout, scheme, auth);
+ String sessionKey = sessionKey(connectString, timeout, scheme, auth);
// a read-only session can use a session with authorizations, so cache a
copy for it w/out auths
- String readOnlySessionKey = sessionKey(zooKeepers, timeout, null, null);
+ String readOnlySessionKey = sessionKey(connectString, timeout, null, null);
ZooSessionInfo zsi = sessions.get(sessionKey);
if (zsi != null && zsi.zooKeeper.getState() == States.CLOSED) {
- log.debug("Removing closed ZooKeeper session to {}", zooKeepers);
+ log.debug("Removing closed ZooKeeper session to {}", connectString);
if (auth != null && sessions.get(readOnlySessionKey) == zsi) {
sessions.remove(readOnlySessionKey);
}
@@ -211,8 +212,8 @@ public class ZooSession {
if (zsi == null) {
ZooWatcher watcher = new ZooWatcher();
- log.debug("Connecting to {} with timeout {} with auth", zooKeepers,
timeout);
- zsi = new ZooSessionInfo(connect(zooKeepers, timeout, scheme, auth,
watcher));
+ log.debug("Connecting to {} with timeout {} with auth", connectString,
timeout);
+ zsi = new ZooSessionInfo(connect(connectString, timeout, scheme, auth,
watcher));
sessions.put(sessionKey, zsi);
if (auth != null && !sessions.containsKey(readOnlySessionKey)) {
sessions.put(readOnlySessionKey, zsi);