@Override
    public long append(ByteBuffer buf, long leftTime, long rightTime) throws IOException {
        if (!this.mutable) {
            if (this.segmentType == SegmentType.DATA) {
                throw new UnsupportedOperationException("[File Store] Data Segment is immutable!");
            } else {
                throw new UnsupportedOperationException(
                        "[File Store] Index Segment is immutable!");
            }
        }
        if (this.closed.get()) {
            throw new UnsupportedOperationException("[File Store] Segment is closed!");
        }
        final long offset = this.cachedSize.get();
        int sizeInBytes = 0;
        while (buf.hasRemaining()) {
            sizeInBytes += this.channel.write(buf);
        }
        this.cachedSize.addAndGet(sizeInBytes);
        if (segmentType == SegmentType.INDEX) {
            this.rightAppendTime.set(rightTime);
            if (offset == 0) {
                this.leftAppendTime.set(leftTime);
            }
        }
        return this.start + offset;
    }
Messages can only be appended to the last FileSegment.
The last FileSegment is writable, the others are mutable.

@param buf            data buffer
@param leftTime       the first record timestamp
@param rightTime      the latest record timestamp
@return               latest writable position
@throws IOException   exception while force data to disk
inlong-tubemq/tubemq-server/src/main/java/org/apache/inlong/tubemq/server/broker/msgstore/disk/FileSegment.java