code: private void processWritesSync() {
          if (this.closed.get()) {
              // BookKeeperLog is closed. No point in trying anything else.
              return;
          }
  
          if (getWriteLedger().ledger.isClosed()) {
              // Current ledger is closed. Execute the rollover processor to safely create a new ledger. This will reinvoke
              // the write processor upon finish, so the writes can be reattempted.
              this.rolloverProcessor.runAsync();
          } else if (!processPendingWrites() && !this.closed.get()) {
              // We were not able to complete execution of all writes. Try again.
              this.writeProcessor.runAsync();
          }
      }
docs: Write Processor main loop. This method is not thread safe and should only be invoked as part of the Write Processor.