Class OffsetCheckpoint
- java.lang.Object
-
- org.apache.kafka.streams.state.internals.OffsetCheckpoint
-
public class OffsetCheckpoint extends 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(File file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete()
Map<TopicPartition,Long>
read()
Reads the offsets from the local checkpoint file, skipping any negative offsets it finds.String
toString()
void
write(Map<TopicPartition,Long> offsets)
Write the given offsets to the checkpoint file.
-
-
-
Field Detail
-
OFFSET_UNKNOWN
public static final long OFFSET_UNKNOWN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OffsetCheckpoint
public OffsetCheckpoint(File file)
-
-
Method Detail
-
write
public void write(Map<TopicPartition,Long> offsets) throws IOException
Write the given offsets to the checkpoint file. All offsets should be non-negative.- Throws:
IOException
- if any file operation fails with an IO exception
-
read
public Map<TopicPartition,Long> read() throws IOException
Reads the offsets from the local checkpoint file, skipping any negative offsets it finds.- Throws:
IOException
- if any file operation fails with an IO exceptionIllegalArgumentException
- if the offset checkpoint version is unknown
-
delete
public void delete() throws IOException
- Throws:
IOException
- if there is any IO exception during delete
-
-