public Map<String, Integer> maybeStartCompactorThreads(HiveConf hiveConf) {
    Map<String, Integer> startedWorkers = new HashMap<>();
    if (MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.HIVE_METASTORE_RUNWORKER_IN).equals("hs2")) {
      Ref<Integer> numWorkers = new Ref<>(MetastoreConf.getIntVar(hiveConf, MetastoreConf.ConfVars.COMPACTOR_WORKER_THREADS));
      Map<String, Integer> customPools = CompactorUtil.getPoolConf(hiveConf);

      StringBuilder sb = new StringBuilder(2048);
      sb.append("This HS2 instance will act as Compactor with the following worker pool configuration:\n");
      sb.append("Global pool size: ").append(numWorkers.value).append("\n");

      LOG.info("Initializing the compaction pools with using the global worker limit: {} ", numWorkers.value);
      customPools.forEach((poolName, poolWorkers) -> {
        if (poolWorkers == 0) {
          LOG.warn("Pool not initialized, configured with zero workers: {}", poolName);
        }
        else if (numWorkers.value == 0) {
          LOG.warn("Pool not initialized, no available workers remained: {}", poolName);
        }
        else {
          if (poolWorkers > numWorkers.value) {
            LOG.warn("Global worker pool exhausted, compaction pool ({}) will be configured with less workers than the " +
                "required number. ({} -> {})", poolName, poolWorkers, numWorkers.value);
            poolWorkers = numWorkers.value;
          }

          LOG.info("Initializing compaction pool ({}) with {} workers.", poolName, poolWorkers);
          IntStream.range(0, poolWorkers).forEach(i -> {
            Worker w = new Worker();
            w.setPoolName(poolName);
            CompactorThread.initializeAndStartThread(w, hiveConf);
            startedWorkers.compute(poolName, (k, v) -> (v == null) ? 1 : v + 1);
            sb.append(
                String.format("Worker - Name: %s, Pool: %s, Priority: %d", w.getName(), poolName, w.getPriority())
            );
          });
          numWorkers.value -= poolWorkers;
        }
      });

      if (numWorkers.value == 0) {
        LOG.warn("No default compaction pool configured, all non-labeled compaction requests will remain unprocessed!");
        if (customPools.size() > 0) {
          sb.append("Pool not initialized, no remaining free workers: default\n");
        }
      } else {
        LOG.info("Initializing default compaction pool with {} workers.", numWorkers.value);
        IntStream.range(0, numWorkers.value).forEach(i -> {
          Worker w = new Worker();
          CompactorThread.initializeAndStartThread(w, hiveConf);
          startedWorkers.compute(Constants.COMPACTION_DEFAULT_POOL, (k, v) -> (v == null) ? 1 : v + 1);
          sb.append("Worker - Name: ").append(w.getName()).append(", Pool: default, Priority: ").append(w.getPriority()).append("\n");
        });
      }
      LOG.info(sb.toString());
    }
    return startedWorkers;
  }
Decommission HiveServer2. As a consequence, SessionManager stops
opening new sessions, OperationManager refuses running new queries and
HiveServer2 deregisters itself from Zookeeper if service discovery is enabled,
but the decommissioning has no effect on the current running queries.
service/src/java/org/apache/hive/service/server/HiveServer2.java