@Override
    public void run() {
      boolean b = this.conf.getBoolean(RUN_SHUTDOWN_HOOK, true);
      LOG.info("Shutdown hook starting; " + RUN_SHUTDOWN_HOOK + "=" + b + "; fsShutdownHook="
        + this.fsShutdownHook);
      if (b) {
        this.stop.stop("Shutdown hook");
        Threads.shutdown(this.threadToJoin);
        if (this.fsShutdownHook != null) {
          synchronized (fsShutdownHooks) {
            int refs = fsShutdownHooks.get(fsShutdownHook);
            if (refs == 1) {
              LOG.info("Starting fs shutdown hook thread.");
              Thread fsShutdownHookThread = (fsShutdownHook instanceof Thread)
                ? (Thread) fsShutdownHook
                : new Thread(fsShutdownHook,
                  fsShutdownHook.getClass().getSimpleName() + "-shutdown-hook");
              fsShutdownHookThread.start();
              Threads.shutdown(fsShutdownHookThread,
                this.conf.getLong(FS_SHUTDOWN_HOOK_WAIT, 30000));
            }
            if (refs > 0) {
              fsShutdownHooks.put(fsShutdownHook, refs - 1);
            }
          }
        }
      }
      LOG.info("Shutdown hook finished.");
    }
Install a shutdown hook that calls stop on the passed Stoppable and then thread joins against
the passed <code>threadToJoin</code>. When this thread completes, it then runs the hdfs thread
(This install removes the hdfs shutdown hook keeping a handle on it to run it after
<code>threadToJoin</code> has stopped).
<p>
To suppress all shutdown hook handling -- both the running of the regionserver hook and of the
hdfs hook code -- set {@link ShutdownHook#RUN_SHUTDOWN_HOOK} in {@link Configuration} to
<code>false</code>. This configuration value is checked when the hook code runs.
@param fs           Instance of Filesystem used by the RegionServer
@param stop         Installed shutdown hook will call stop against this passed
                    <code>Stoppable</code> instance.
@param threadToJoin After calling stop on <code>stop</code> will then join this thread.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ShutdownHook.java