@Override
  public long mergeRegions(final RegionInfo[] regionsToMerge, final boolean forcible, final long ng,
    final long nonce) throws IOException {
    checkInitialized();

    final String regionNamesToLog = RegionInfo.getShortNameToLog(regionsToMerge);

    if (!isSplitOrMergeEnabled(MasterSwitchType.MERGE)) {
      LOG.warn("Merge switch is off! skip merge of " + regionNamesToLog);
      throw new DoNotRetryIOException(
        "Merge of " + regionNamesToLog + " failed because merge switch is off");
    }

    if (!getTableDescriptors().get(regionsToMerge[0].getTable()).isMergeEnabled()) {
      LOG.warn("Merge is disabled for the table! Skipping merge of {}", regionNamesToLog);
      throw new DoNotRetryIOException(
        "Merge of " + regionNamesToLog + " failed as region merge is disabled for the table");
    }

    return MasterProcedureUtil.submitProcedure(new NonceProcedureRunnable(this, ng, nonce) {
      @Override
      protected void run() throws IOException {
        getMaster().getMasterCoprocessorHost().preMergeRegions(regionsToMerge);
        String aid = getClientIdAuditPrefix();
        LOG.info("{} merge regions {}", aid, regionNamesToLog);
        submitProcedure(new MergeTableRegionsProcedure(procedureExecutor.getEnvironment(),
          regionsToMerge, forcible));
        getMaster().getMasterCoprocessorHost().postMergeRegions(regionsToMerge);
      }

      @Override
      protected String getDescription() {
        return "MergeTableProcedure";
      }
    });
  }
Switch for the background CatalogJanitor thread. Used for testing. The thread will continue to
run. It will just be a noop if disabled.
@param b If false, the catalog janitor won't do anything.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java