private static String getMaster(ZooCache cache, UUID iid, boolean printErrors) { if (iid == null) { return null; } try { String masterLocPath = Constants.ZROOT + "/" + iid + Constants.ZMASTER_LOCK; byte[] master = ZooLock.getLockData(cache, masterLocPath, null); if (master == null) { return null; } return new String(master, UTF_8); } catch (Exception e) { handleException(e, printErrors); return null; } }
private static String getMaster(ZooCache cache, UUID iid) { if (iid == null) { return null; } try { String masterLocPath = Constants.ZROOT + "/" + iid + Constants.ZMASTER_LOCK; byte[] master = ZooLock.getLockData(cache, masterLocPath, null); if (master == null) { return null; } return new String(master, UTF_8); } catch (Exception e) { handleException(e); return null; } }
@Override public List<String> getMasterLocations() { String masterLocPath = ZooUtil.getRoot(this) + Constants.ZMASTER_LOCK; OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up master location in zoocache."); byte[] loc = ZooLock.getLockData(zooCache, masterLocPath, null); opTimer.stop("Found master at " + (loc == null ? null : new String(loc, UTF_8)) + " in %DURATION%"); if (loc == null) { return Collections.emptyList(); } return Collections.singletonList(new String(loc, UTF_8)); }
@Override public List<String> getMasterLocations() { String masterLocPath = ZooUtil.getRoot(this) + Constants.ZMASTER_LOCK; OpTimer timer = null; if (log.isTraceEnabled()) { log.trace("tid={} Looking up master location in zoocache.", Thread.currentThread().getId()); timer = new OpTimer().start(); } byte[] loc = ZooLock.getLockData(zooCache, masterLocPath, null); if (timer != null) { timer.stop(); log.trace("tid={} Found master at {} in {}", Thread.currentThread().getId(), (loc == null ? "null" : new String(loc, UTF_8)), String.format("%.3f secs", timer.scale(TimeUnit.SECONDS))); } if (loc == null) { return Collections.emptyList(); } return Collections.singletonList(new String(loc, UTF_8)); }
byte[] lockData = ZooLock.getLockData(getZooCache(), lockPath, stat);
byte[] lockData = ZooLock.getLockData(getZooCache(), lockPath, stat);
public static void main(String[] args) throws Exception { Instance instance = HdfsZooInstance.getInstance(); String tserverPath = ZooUtil.getRoot(instance) + Constants.ZTSERVERS; Opts opts = new Opts(); opts.parseArgs(TabletServerLocks.class.getName(), args); ZooCache cache = new ZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); if (opts.list) { IZooReaderWriter zoo = ZooReaderWriter.getInstance(); List<String> tabletServers = zoo.getChildren(tserverPath); for (String tabletServer : tabletServers) { byte[] lockData = ZooLock.getLockData(cache, tserverPath + "/" + tabletServer, null); String holder = null; if (lockData != null) { holder = new String(lockData, UTF_8); } System.out.printf("%32s %16s%n", tabletServer, holder); } } else if (opts.delete != null) { ZooLock.deleteLock(tserverPath + "/" + args[1]); } else { System.out.println( "Usage : " + TabletServerLocks.class.getName() + " -list|-delete <tserver lock>"); } }
public static void main(String[] args) throws Exception { Instance instance = HdfsZooInstance.getInstance(); String tserverPath = ZooUtil.getRoot(instance) + Constants.ZTSERVERS; Opts opts = new Opts(); opts.parseArgs(TabletServerLocks.class.getName(), args); ZooCache cache = new ZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); if (opts.list) { IZooReaderWriter zoo = ZooReaderWriter.getInstance(); List<String> tabletServers = zoo.getChildren(tserverPath); for (String tabletServer : tabletServers) { byte[] lockData = ZooLock.getLockData(cache, tserverPath + "/" + tabletServer, null); String holder = null; if (lockData != null) { holder = new String(lockData, UTF_8); } System.out.printf("%32s %16s%n", tabletServer, holder); } } else if (opts.delete != null) { ZooLock.deleteLock(tserverPath + "/" + args[1]); } else { System.out.println("Usage : " + TabletServerLocks.class.getName() + " -list|-delete <tserver lock>"); } }