@Override public Repo<Master> call(long tid, Master master) throws Exception { // suppress assignment of tablets to the server if (force) { ZooReaderWriter zoo = master.getContext().getZooReaderWriter(); String path = master.getZooKeeperRoot() + Constants.ZTSERVERS + "/" + server.getLocation(); ZooLock.deleteLock(zoo, path); path = master.getZooKeeperRoot() + Constants.ZDEADTSERVERS + "/" + server.getLocation(); zoo.putPersistentData(path, "forced down".getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); } return null; }
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>"); } } }
String path = tserversPath + "/" + child; if (zoo.getChildren(path).size() > 0) { if (!ZooLock.deleteLock(zoo, path, "tserver")) { message("Did not delete " + tserversPath + "/" + child, opts);
private void killMacGc() throws ProcessNotFoundException, InterruptedException, KeeperException { // kill gc started by MAC getCluster().killProcess(ServerType.GARBAGE_COLLECTOR, getCluster().getProcesses().get(ServerType.GARBAGE_COLLECTOR).iterator().next()); // delete lock in zookeeper if there, this will allow next GC to start quickly String path = ZooUtil.getRoot(new ZooKeeperInstance(getCluster().getClientConfig())) + Constants.ZGC_LOCK; ZooReaderWriter zk = new ZooReaderWriter(cluster.getZooKeepers(), 30000, OUR_SECRET); try { ZooLock.deleteLock(zk, path); } catch (IllegalStateException e) { } assertNull(getCluster().getProcesses().get(ServerType.GARBAGE_COLLECTOR)); }