public static Object getLeaderMutex(Configuration conf, TTYPE ttype, String servHost) {
    String method =
        MetastoreConf.getVar(conf, MetastoreConf.ConfVars.METASTORE_HOUSEKEEPING_LEADER_ELECTION);
    switch (method.toLowerCase()) {
    case "host":
      return servHost;
    case "lock":
      TableName mutex = ttype.getTableName();
      String namespace =
          MetastoreConf.getVar(conf, MetastoreConf.ConfVars.METASTORE_HOUSEKEEPING_LEADER_LOCK_NAMESPACE);
      if (StringUtils.isNotEmpty(namespace)) {
        return new TableName(mutex.getCat(), namespace, mutex.getTable());
      }
      return mutex;
    default:
      throw new UnsupportedOperationException(method + " not supported for leader election");
    }
  }
Types of tasks that exactly have one instance in a given warehouse.
For those tasks which belong to the same type, they will be running in the same leader.
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/leader/LeaderElectionContext.java