private void validateAppendSize(long size) {
    if (endOffset.get() + size > capacityInBytes) {
      metrics.overflowWriteError.inc();
      throw new IllegalArgumentException(
          "Cannot append to segment [" + file.getAbsolutePath() + "] because size requested exceeds the capacity ["
              + capacityInBytes + "]");
    }
  }
Make sure the size for append is legal.
@param size The amount of data in bytes to append.
ambry-store/src/main/java/com/github/ambry/store/LogSegment.java