Class OffsetCheckpoint


  • public class OffsetCheckpoint
    extends java.lang.Object
    This class saves out a map of topic/partition=>offsets to a file. The format of the file is UTF-8 text containing the following:
       <version>
       <n>
       <topic_name_1> <partition_1> <offset_1>
       .
       .
       .
       <topic_name_n> <partition_n> <offset_n>
     
    The first line contains a number designating the format version (currently 0), the get line contains a number giving the total number of offsets. Each successive line gives a topic/partition/offset triple separated by spaces.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long OFFSET_UNKNOWN  
    • Constructor Summary

      Constructors 
      Constructor Description
      OffsetCheckpoint​(java.io.File file)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete()  
      java.util.Map<org.apache.kafka.common.TopicPartition,​java.lang.Long> read()
      Reads the offsets from the local checkpoint file, skipping any negative offsets it finds.
      java.lang.String toString()  
      void write​(java.util.Map<org.apache.kafka.common.TopicPartition,​java.lang.Long> offsets)
      Write the given offsets to the checkpoint file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • OffsetCheckpoint

        public OffsetCheckpoint​(java.io.File file)
    • Method Detail

      • write

        public void write​(java.util.Map<org.apache.kafka.common.TopicPartition,​java.lang.Long> offsets)
                   throws java.io.IOException
        Write the given offsets to the checkpoint file. All offsets should be non-negative.
        Throws:
        java.io.IOException - if any file operation fails with an IO exception
      • read

        public java.util.Map<org.apache.kafka.common.TopicPartition,​java.lang.Long> read()
                                                                                        throws java.io.IOException
        Reads the offsets from the local checkpoint file, skipping any negative offsets it finds.
        Throws:
        java.io.IOException - if any file operation fails with an IO exception
        java.lang.IllegalArgumentException - if the offset checkpoint version is unknown
      • delete

        public void delete()
                    throws java.io.IOException
        Throws:
        java.io.IOException - if there is any IO exception during delete
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object