public static boolean clear(Configuration conf) {
    Configuration tempConf = new Configuration(conf);
    tempConf.setInt("zookeeper.recovery.retry", 0);

    ZKWatcher zkw;
    try {
      zkw = new ZKWatcher(tempConf, "clean znode for master", new Abortable() {
        @Override
        public void abort(String why, Throwable e) {
        }

        @Override
        public boolean isAborted() {
          return false;
        }
      });
    } catch (IOException e) {
      LOG.warn("Can't connect to zookeeper to read the master znode", e);
      return false;
    }

    String znodeFileContent;
    try {
      znodeFileContent = ZNodeClearer.readMyEphemeralNodeOnDisk();
      return MasterAddressTracker.deleteIfEquals(zkw, znodeFileContent);
    } catch (FileNotFoundException fnfe) {
      // If no file, just keep going -- return success.
      LOG.warn("Can't find the znode file; presume non-fatal", fnfe);
      return true;
    } catch (IOException e) {
      LOG.warn("Can't read the content of the znode file", e);
      return false;
    } finally {
      zkw.close();
    }
  }
Delete the master znode if its content (ServerName string) is the same as the one in the znode
file. (env: HBASE_ZNODE_FILE). I case of master-rs colloaction we extract ServerName string
from rsZnode path.(HBASE-14861)
@return true on successful deletion, false otherwise.
hbase-server/src/main/java/org/apache/hadoop/hbase/ZNodeClearer.java