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; } }
@SuppressFBWarnings(value = "DM_EXIT", justification = "TODO - should probably avoid System.exit here; " + "this code is used by the fate admin shell command") public boolean checkGlobalLock(IZooReaderWriter zk, String path) { try { if (ZooLock.getLockData(zk.getZooKeeper(), path) != null) { System.err.println("ERROR: Master lock is held, not running"); if (this.exitOnError) System.exit(1); else return false; } } catch (KeeperException e) { System.err.println("ERROR: Could not read master lock, not running " + e.getMessage()); if (this.exitOnError) System.exit(1); else return false; } catch (InterruptedException e) { System.err.println("ERROR: Could not read master lock, not running" + e.getMessage()); if (this.exitOnError) System.exit(1); else return false; } return true; } }
byte[] lockData = ZooLock.getLockData(getZooCache(), lockPath, stat);
public static void main(String[] args) throws Exception { try (ServerContext context = new ServerContext(new SiteConfiguration())) { String tserverPath = context.getZooKeeperRoot() + Constants.ZTSERVERS; Opts opts = new Opts(); opts.parseArgs(TabletServerLocks.class.getName(), args); ZooCache cache = context.getZooCache(); ZooReaderWriter zoo = context.getZooReaderWriter(); if (opts.list) { 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(zoo, tserverPath + "/" + args[1]); } else { System.out.println( "Usage : " + TabletServerLocks.class.getName() + " -list|-delete <tserver lock>"); } } }
public boolean checkGlobalLock(IZooReaderWriter zk, String path) { try { if (ZooLock.getLockData(zk.getZooKeeper(), path) != null) { System.err.println("ERROR: Master lock is held, not running"); if (this.exitOnError) System.exit(1); else return false; } } catch (KeeperException e) { System.err.println("ERROR: Could not read master lock, not running " + e.getMessage()); if (this.exitOnError) System.exit(1); else return false; } catch (InterruptedException e) { System.err.println("ERROR: Could not read master lock, not running" + e.getMessage()); if (this.exitOnError) System.exit(1); else return false; } return true; } }
private void waitForGCLock(Connector conn) throws InterruptedException { // Check if the GC process has the lock before wasting our retry attempts ZooKeeperInstance zki = (ZooKeeperInstance) conn.getInstance(); ZooCacheFactory zcf = new ZooCacheFactory(); ZooCache zcache = zcf.getZooCache(zki.getZooKeepers(), zki.getZooKeepersSessionTimeOut()); String zkPath = ZooUtil.getRoot(conn.getInstance()) + Constants.ZGC_LOCK; log.info("Looking for GC lock at {}", zkPath); byte[] data = ZooLock.getLockData(zcache, zkPath, null); while (null == data) { log.info("Waiting for GC ZooKeeper lock to be acquired"); Thread.sleep(1000); data = ZooLock.getLockData(zcache, zkPath, null); } }
byte[] gcLockData; do { gcLockData = ZooLock.getLockData(zcache, path, null); if (null != gcLockData) { log.info("Waiting for GC ZooKeeper lock to expire"); gcLockData = ZooLock.getLockData(zcache, path, null); if (null == gcLockData) { log.info("Waiting for GC ZooKeeper lock to be acquired");
byte[] masterLockData; do { masterLockData = ZooLock.getLockData(zcache, ZooUtil.getRoot(connector.getInstance()) + Constants.ZMASTER_LOCK, null); if (null != masterLockData) {
byte[] masterLockData; do { masterLockData = ZooLock.getLockData(zcache, ZooUtil.getRoot(c.getInstance()) + Constants.ZMASTER_LOCK, null); if (null != masterLockData) {
byte[] masterLockData; do { masterLockData = ZooLock.getLockData(zcache, ZooUtil.getRoot(c.getInstance()) + Constants.ZMASTER_LOCK, null); if (null != masterLockData) { masterLockData = ZooLock.getLockData(zcache, ZooUtil.getRoot(c.getInstance()) + Constants.ZMASTER_LOCK, null); if (null != masterLockData) {