private void flushLoop() {
    recordLastFlushTime();
    while (!closed) {
      flushLock.lock();
      try {
        while (!flushRequest) {
          long waitTimeMs = lastFlushTime + flushIntervalMs - EnvironmentEdgeManager.currentTime();
          if (waitTimeMs <= 0) {
            flushRequest = true;
            break;
          }
          flushCond.await(waitTimeMs, TimeUnit.MILLISECONDS);
          if (closed) {
            return;
          }
        }
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        continue;
      } finally {
        flushLock.unlock();
      }
      assert flushRequest;
      resetChangesAfterLastFlush();
      try {
        region.flush(true);
        recordLastFlushTime();
      } catch (IOException e) {
        LOG.error(HBaseMarkers.FATAL, "Failed to flush master local region, aborting...", e);
        abortable.abort("Failed to flush master local region", e);
        return;
      }
      compactLock.lock();
      try {
        if (!compactRequest && needCompaction()) {
          compactRequest = true;
          compactExecutor.execute(this::compact);
        }
      } finally {
        compactLock.unlock();
      }
      flushLock.lock();
      try {
        // reset the flushRequest flag
        if (!shouldFlush(changesAfterLastFlush.get())) {
          flushRequest = false;
        }
      } finally {
        flushLock.unlock();
      }
    }
  }
As long as there is no RegionServerServices for a master local region, we need implement the
flush and compaction logic by our own.
<p/>
The flush logic is very simple, every time after calling a modification method in
{@link RegionProcedureStore}, we will call the {@link #onUpdate()} method below, and in this
method, we will check the memstore size and if it is above the flush size, we will call
{@link HRegion#flush(boolean)} to force flush all stores.
<p/>
And for compaction, the logic is also very simple. After flush, we will check the store file
count, if it is above the compactMin, we will do a major compaction.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFlusherAndCompactor.java