code: private void waitForCompletion() {
          for (ListenableFuture<?> future : pendingTasks.values()) {
              try {
                  future.get();
              } catch (InterruptedException | ExecutionException e) {
                  LOG.error("[" + this + "] Error waiting for writes to complete: " + e.getMessage());
              }
          }
      }
docs: Waits until all pending tasks completed.