Skip to content

Commit

Permalink
Merge branch '2.1' into 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmarion committed Jan 17, 2025
2 parents 8f88dc8 + 87deb3a commit 33ad3f1
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.data.InstanceId;
import org.apache.accumulo.core.fate.zookeeper.ZooCache;
import org.apache.accumulo.core.fate.zookeeper.ZooReader;
import org.apache.accumulo.core.fate.zookeeper.ZooUtil;
import org.apache.accumulo.core.lock.ServiceLock;
Expand Down Expand Up @@ -91,23 +90,22 @@ static synchronized void listInstances(String keepers, boolean printAll, boolean
try (var zk = new ZooSession(ListInstances.class.getSimpleName(), keepers,
ZOOKEEPER_TIMER_MILLIS, null)) {
ZooReader rdr = zk.asReader();
ZooCache cache = new ZooCache(zk);

TreeMap<String,InstanceId> instanceNames = getInstanceNames(rdr, printErrors);

System.out.println();
printHeader();

for (Entry<String,InstanceId> entry : instanceNames.entrySet()) {
printInstanceInfo(cache, entry.getKey(), entry.getValue(), printErrors);
printInstanceInfo(zk, entry.getKey(), entry.getValue(), printErrors);
}

TreeSet<InstanceId> instancedIds = getInstanceIDs(rdr, printErrors);
instancedIds.removeAll(instanceNames.values());

if (printAll) {
for (InstanceId uuid : instancedIds) {
printInstanceInfo(cache, null, uuid, printErrors);
printInstanceInfo(zk, null, uuid, printErrors);
}
} else if (!instancedIds.isEmpty()) {
System.out.println();
Expand Down Expand Up @@ -148,9 +146,9 @@ private static void printHeader() {

}

private static void printInstanceInfo(ZooCache cache, String instanceName, InstanceId iid,
private static void printInstanceInfo(ZooSession zs, String instanceName, InstanceId iid,
boolean printErrors) {
String manager = getManager(cache, iid, printErrors);
String manager = getManager(zs, iid, printErrors);
if (instanceName == null) {
instanceName = "";
}
Expand All @@ -163,15 +161,15 @@ private static void printInstanceInfo(ZooCache cache, String instanceName, Insta
"\"" + instanceName + "\"", iid, manager);
}

private static String getManager(ZooCache cache, InstanceId iid, boolean printErrors) {
private static String getManager(ZooSession zs, InstanceId iid, boolean printErrors) {

if (iid == null) {
return null;
}

try {
var zLockManagerPath = ServiceLock.path(ZooUtil.getRoot(iid) + Constants.ZMANAGER_LOCK);
Optional<ServiceLockData> sld = ServiceLock.getLockData(cache, zLockManagerPath, null);
Optional<ServiceLockData> sld = ServiceLock.getLockData(zs, zLockManagerPath);
if (sld.isEmpty()) {
return null;
}
Expand Down

0 comments on commit 33ad3f1

Please sign in to comment.