@Override
    public void runInternal() {
      shutDown();
      // The timeout lock should be cleaned,
      // sleep some time to let others take the chance to become the leader
      try {
        Thread.sleep(5000);
      } catch (InterruptedException e) {
        // ignore
      }
      // Acquire the lock again
      conf = new Configuration(conf);
      conf.setBoolean(METASTORE_RENEW_LEASE, true);
      reclaim();
    }
Hive Lock based leader election.
If wins, the current instance becomes the leader,
and a heartbeat daemon will be spawned to refresh the lock before timeout.
If loses, a non-leader watcher will also be spawned to check the
lock periodically to see if he can grab the lock to be the leader.
The change of Leadership can be received by registering the
listeners through {@link LeaderElection#addStateListener}.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/leader/LeaseLeaderElection.java