docs: @Override
    public synchronized void write(final Collection<BatchPoints> collection) {
      // empty the cached data first
      ListIterator<BatchPoints> batchQueueIterator = batchQueue.listIterator();
      while (batchQueueIterator.hasNext()) {
        BatchPoints entry = batchQueueIterator.next();
        WriteResult result = tryToWrite(entry);
        if (result.outcome == WriteResultOutcome.WRITTEN
                || result.outcome == WriteResultOutcome.FAILED_RETRY_IMPOSSIBLE) {
          batchQueueIterator.remove();
          usedRetryBufferCapacity -= entry.getPoints().size();
          // we are throwing out data, notify the client
          if (result.outcome == WriteResultOutcome.FAILED_RETRY_IMPOSSIBLE) {
            exceptionHandler.accept(entry.getPoints(), result.throwable);
          }
        } else {
          // we cannot send more data otherwise we would write them in different
          // order than in which were submitted
          for (BatchPoints batchPoints : collection) {
            addToBatchQueue(batchPoints);
          }
          return;
        }
      }
      // write the last given batch last so that duplicate data points get overwritten correctly
      Iterator<BatchPoints> collectionIterator = collection.iterator();
      while (collectionIterator.hasNext()) {
        BatchPoints batchPoints = collectionIterator.next();
        WriteResult result = tryToWrite(batchPoints);
        switch (result.outcome) {
          case FAILED_RETRY_POSSIBLE:
            addToBatchQueue(batchPoints);
            while (collectionIterator.hasNext()) {
              addToBatchQueue(collectionIterator.next());
            }
            break;
          case FAILED_RETRY_IMPOSSIBLE:
            exceptionHandler.accept(batchPoints.getPoints(), result.throwable);
            break;
          default:
  
        }
      }
    }