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 Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()  
      java.util.concurrent.CompletableFuture<java.lang.Boolean> compareAndSetAttribute​(SegmentAttribute attribute, long expectedValue, long newValue)
      Atomically replaces the value of attribute with newValue if it is expectedValue.
      java.util.concurrent.CompletableFuture<java.lang.Long> fetchCurrentSegmentLength()
      Returns the length of the current segment.
      java.util.concurrent.CompletableFuture<java.lang.Long> fetchProperty​(SegmentAttribute attribute)
      Gets the current value of the provided attribute.
      java.util.concurrent.CompletableFuture<SegmentInfo> getSegmentInfo()
      Returns info for the current segment.
      java.util.concurrent.CompletableFuture<java.lang.Void> sealSegment()
      Seals the segment so that no more writes can go to it.
      java.util.concurrent.CompletableFuture<java.lang.Void> truncateSegment​(long offset)
      Deletes all data before the offset of the provided segment.
    • Method Detail

      • getSegmentInfo

        java.util.concurrent.CompletableFuture<SegmentInfo> getSegmentInfo()
        Returns info for the current segment.
        Returns:
        a future containing the Metadata about the segment.
      • fetchCurrentSegmentLength

        java.util.concurrent.CompletableFuture<java.lang.Long> fetchCurrentSegmentLength()
        Returns the length of the current segment. i.e. the total length of all data written to the segment.
        Returns:
        a future containing the length of the current segment.
      • fetchProperty

        java.util.concurrent.CompletableFuture<java.lang.Long> fetchProperty​(SegmentAttribute attribute)
        Gets the current value of the provided attribute.
        Parameters:
        attribute - The attribute to get the value of.
        Returns:
        a future containing the value of the attribute or SegmentAttribute.NULL_VALUE if it is not set.
      • compareAndSetAttribute

        java.util.concurrent.CompletableFuture<java.lang.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

        java.util.concurrent.CompletableFuture<java.lang.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

        java.util.concurrent.CompletableFuture<java.lang.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