Skip to content

Commit

Permalink
Merge branch '3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
dlmarion committed Jan 17, 2025
2 parents ea5e68a + 33ad3f1 commit 428f7c7
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 @@ -92,23 +91,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 @@ -149,9 +147,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 @@ -164,7 +162,7 @@ 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;
Expand All @@ -173,7 +171,7 @@ private static String getManager(ZooCache cache, InstanceId iid, boolean printEr
try {
var zLockManagerPath = ServiceLockPaths.parse(Optional.of(Constants.ZMANAGER_LOCK),
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 428f7c7

Please sign in to comment.