void preProcessOperation(StreamSegmentAppendOperation operation) throws StreamSegmentSealedException, StreamSegmentMergedException,
            BadOffsetException, BadAttributeUpdateException {
        ensureSegmentId(operation);
        if (this.merged) {
            // We do not allow any operation after merging (since after merging the Segment disappears).
            throw new StreamSegmentMergedException(this.name);
        }

        if (this.sealed) {
            throw new StreamSegmentSealedException(this.name);
        }

        if (!this.recoveryMode) {
            // Offset check (if append-with-offset).
            long operationOffset = operation.getStreamSegmentOffset();
            if (operationOffset >= 0) {
                // If the Operation already has an offset assigned, verify that it matches the current end offset of the Segment.
                if (operationOffset != this.length) {
                    throw new BadOffsetException(this.name, this.length, operationOffset);
                }
            } else {
                // No pre-assigned offset. Put the Append at the end of the Segment.
                operation.setStreamSegmentOffset(this.length);
            }

            // Attribute validation.
            preProcessAttributes(operation.getAttributeUpdates());
        }
    }
void preProcessOperation ( StreamSegmentAppendOperation operation ) throws StreamSegmentSealedException , StreamSegmentMergedException , BadOffsetException , BadAttributeUpdateException { ensureSegmentId ( operation ) ; if ( this . merged ) { throw new StreamSegmentMergedException ( this . name ) ; } if ( this . sealed ) { throw new StreamSegmentSealedException ( this . name ) ; } if ( ! this . recoveryMode ) { long operationOffset = operation . getStreamSegmentOffset ( ) ; if ( operationOffset >= 0 ) { if ( operationOffset != this . length ) { throw new BadOffsetException ( this . name , this . length , operationOffset ) ; } } else { operation . setStreamSegmentOffset ( this . length ) ; } preProcessAttributes ( operation . getAttributeUpdates ( ) ) ; } }
Pre-processes a StreamSegmentAppendOperation.
After this method returns, the given operation will have its SegmentOffset property set to the current
SegmentLength, and all AttributeUpdates will be set to the current values.

@param operation The operation to pre-process.
@throws StreamSegmentSealedException If the Segment is sealed.
@throws StreamSegmentMergedException If the Segment is merged into another.
@throws BadOffsetException           If the operation has an assigned offset, but it doesn't match the current
Segment DurableLogOffset.
@throws IllegalArgumentException     If the operation is for a different Segment.
@throws BadAttributeUpdateException  If at least one of the AttributeUpdates is invalid given the current attribute
values of the segment.