You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2013/07/17 17:34:11 UTC
[6/8] git commit: ACCUMULO-1575
ACCUMULO-1575
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/8ef04012
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/8ef04012
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/8ef04012
Branch: refs/heads/master
Commit: 8ef040122228a459a16243e6456ebb03f27d0047
Parents: a1fda97
Author: Eric Newton <er...@gmail.com>
Authored: Wed Jul 17 11:27:23 2013 -0400
Committer: Eric Newton <er...@gmail.com>
Committed: Wed Jul 17 11:27:23 2013 -0400
----------------------------------------------------------------------
.../apache/accumulo/fate/zookeeper/ZooLock.java | 12 ++-----
.../accumulo/server/util/ListInstances.java | 35 ++++++++++----------
2 files changed, 19 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8ef04012/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
----------------------------------------------------------------------
diff --git a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
index cb0d902..961539a 100644
--- a/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
+++ b/fate/src/main/java/org/apache/accumulo/fate/zookeeper/ZooLock.java
@@ -431,16 +431,6 @@ public class ZooLock implements Watcher {
return zc.get(path + "/" + lockNode, stat);
}
- private static ZooCache getLockDataZooCache;
-
- public static byte[] getLockData(String path) {
- return getLockData(path, null);
- }
-
- public static byte[] getLockData(String path, Stat stat) {
- return getLockData(getLockDataZooCache, path, stat);
- }
-
public static long getSessionId(ZooCache zc, String path) throws KeeperException, InterruptedException {
List<String> children = zc.getChildren(path);
@@ -459,6 +449,8 @@ public class ZooLock implements Watcher {
return 0;
}
+ private static ZooCache getLockDataZooCache;
+
public long getSessionId() throws KeeperException, InterruptedException {
return getSessionId(getLockDataZooCache, path);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/8ef04012/server/src/main/java/org/apache/accumulo/server/util/ListInstances.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/accumulo/server/util/ListInstances.java b/server/src/main/java/org/apache/accumulo/server/util/ListInstances.java
index 64c5dd3..daab268 100644
--- a/server/src/main/java/org/apache/accumulo/server/util/ListInstances.java
+++ b/server/src/main/java/org/apache/accumulo/server/util/ListInstances.java
@@ -27,10 +27,10 @@ import java.util.UUID;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.cli.Help;
import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.fate.zookeeper.IZooReaderWriter;
+import org.apache.accumulo.fate.zookeeper.ZooCache;
+import org.apache.accumulo.fate.zookeeper.ZooReader;
import org.apache.accumulo.server.conf.ServerConfiguration;
import org.apache.accumulo.server.zookeeper.ZooLock;
-import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
import org.apache.log4j.Logger;
import com.beust.jcommander.Parameter;
@@ -43,6 +43,8 @@ public class ListInstances {
private static final int UUID_WIDTH = 37;
private static final int MASTER_WIDTH = 30;
+ private static final int ZOOKEEPER_TIMER_MILLIS = 30 * 1000;
+
static class Opts extends Help {
@Parameter(names="--print-errors", description="display errors while listing instances")
boolean printErrors = false;
@@ -62,22 +64,24 @@ public class ListInstances {
}
System.out.println("INFO : Using ZooKeepers " + opts.keepers);
-
- TreeMap<String,UUID> instanceNames = getInstanceNames();
+ ZooReader rdr = new ZooReader(opts.keepers, ZOOKEEPER_TIMER_MILLIS);
+ ZooCache cache = new ZooCache(opts.keepers, ZOOKEEPER_TIMER_MILLIS);
+
+ TreeMap<String,UUID> instanceNames = getInstanceNames(rdr);
System.out.println();
printHeader();
for (Entry<String,UUID> entry : instanceNames.entrySet()) {
- printInstanceInfo(entry.getKey(), entry.getValue());
+ printInstanceInfo(cache, entry.getKey(), entry.getValue());
}
- TreeSet<UUID> instancedIds = getInstanceIDs();
+ TreeSet<UUID> instancedIds = getInstanceIDs(rdr);
instancedIds.removeAll(instanceNames.values());
if (opts.printAll) {
for (UUID uuid : instancedIds) {
- printInstanceInfo(null, uuid);
+ printInstanceInfo(cache, null, uuid);
}
} else if (instancedIds.size() > 0) {
System.out.println();
@@ -118,8 +122,8 @@ public class ListInstances {
}
- private static void printInstanceInfo(String instanceName, UUID iid) {
- String master = getMaster(iid);
+ private static void printInstanceInfo(ZooCache cache, String instanceName, UUID iid) {
+ String master = getMaster(cache, iid);
if (instanceName == null) {
instanceName = "";
}
@@ -130,8 +134,7 @@ public class ListInstances {
System.out.printf("%" + NAME_WIDTH + "s |%" + UUID_WIDTH + "s |%" + MASTER_WIDTH + "s%n", "\"" + instanceName + "\"", iid, master);
}
-
- private static String getMaster(UUID iid) {
+ private static String getMaster(ZooCache cache, UUID iid) {
if (iid == null) {
return null;
@@ -139,8 +142,7 @@ public class ListInstances {
try {
String masterLocPath = Constants.ZROOT + "/" + iid + Constants.ZMASTER_LOCK;
-
- byte[] master = ZooLock.getLockData(masterLocPath);
+ byte[] master = ZooLock.getLockData(cache, masterLocPath, null);
if (master == null) {
return null;
}
@@ -151,9 +153,8 @@ public class ListInstances {
}
}
- private static TreeMap<String,UUID> getInstanceNames() {
+ private static TreeMap<String,UUID> getInstanceNames(ZooReader zk) {
- IZooReaderWriter zk = ZooReaderWriter.getInstance();
String instancesPath = Constants.ZROOT + Constants.ZINSTANCES;
TreeMap<String,UUID> tm = new TreeMap<String,UUID>();
@@ -181,11 +182,9 @@ public class ListInstances {
return tm;
}
- private static TreeSet<UUID> getInstanceIDs() {
+ private static TreeSet<UUID> getInstanceIDs(ZooReader zk) {
TreeSet<UUID> ts = new TreeSet<UUID>();
- IZooReaderWriter zk = ZooReaderWriter.getInstance();
-
try {
List<String> children = zk.getChildren(Constants.ZROOT);