Interface SegmentMetadataClient

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface SegmentMetadataClient
    extends java.lang.AutoCloseable
    A client for looking at and editing the metadata related to a specific segment.
    • Method Detail

      • getSegmentInfo

        SegmentInfo getSegmentInfo()
        Returns info for the current segment.
        Returns:
        Metadata about the segment.
      • fetchCurrentSegmentLength

        long fetchCurrentSegmentLength()
        Returns the length of the current segment. i.e. the total length of all data written to the segment.
        Returns:
        The length of the current segment.
      • fetchProperty

        long fetchProperty​(SegmentAttribute attribute)
        Gets the current value of the provided attribute.
        Parameters:
        attribute - The attribute to get the value of.
        Returns:
        The value of the attribute or SegmentAttribute.NULL_VALUE if it is not set.
      • compareAndSetAttribute

        boolean compareAndSetAttribute​(SegmentAttribute attribute,
                                       long expectedValue,
                                       long newValue)
        Atomically replaces the value of attribute with newValue if it is expectedValue.
        Parameters:
        attribute - The attribute to set
        expectedValue - The value the attribute is expected to be
        newValue - The new value for the attribute
        Returns:
        If the replacement occurred. (False if the attribute was not expectedValue)
      • truncateSegment

        void truncateSegment​(long offset)
        Deletes all data before the offset of the provided segment. This data will no longer be readable. Existing offsets are not affected by this operations. The new startingOffset will be reflected in getSegmentInfo().SegmentInfo.getStartingOffset().
        Parameters:
        offset - The offset the segment should be truncated at.
      • sealSegment

        void sealSegment()
        Seals the segment so that no more writes can go to it.
      • close

        void close()
        Specified by:
        close in interface java.lang.AutoCloseable