public class FileOffsetWriter extends Object implements OffsetWriter
OffsetWriter which tracks the progress of events
being processed by the SnapshotProcessor and CommitLogProcessor to
property files, snapshot_offset.properties and commitlog_offset.properties, respectively.
The property key is the table for the offset, and is serialized in the format of | Modifier and Type | Field and Description |
|---|---|
static String |
COMMITLOG_OFFSET_FILE |
private File |
commitLogOffsetFile |
private FileLock |
commitLogOffsetFileLock |
private Properties |
commitLogProps |
private static org.slf4j.Logger |
LOGGER |
private File |
offsetDir |
static String |
SNAPSHOT_OFFSET_FILE |
private File |
snapshotOffsetFile |
private FileLock |
snapshotOffsetFileLock |
private Properties |
snapshotProps |
| Constructor and Description |
|---|
FileOffsetWriter(String offsetDir) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close all resources used by this class.
|
void |
flush()
Flush latest offsets to disk.
|
private FileLock |
init(File offsetFile) |
boolean |
isOffsetProcessed(String sourceTable,
String sourceOffset,
boolean isSnapshot)
Determine if an offset has been processed based on the table name, offset position, and whether
it is from snapshot or not.
|
private void |
loadOffset(File offsetFile,
Properties props) |
void |
markOffset(String sourceTable,
String sourceOffset,
boolean isSnapshot)
Update the offset in memory if the provided offset is greater than the existing offset.
|
private static void |
saveOffset(File offsetFile,
Properties props) |
private static final org.slf4j.Logger LOGGER
public static final String SNAPSHOT_OFFSET_FILE
public static final String COMMITLOG_OFFSET_FILE
private final Properties snapshotProps
private final Properties commitLogProps
private final File offsetDir
private final File snapshotOffsetFile
private final File commitLogOffsetFile
private final FileLock snapshotOffsetFileLock
private final FileLock commitLogOffsetFileLock
public FileOffsetWriter(String offsetDir) throws IOException
IOExceptionpublic void markOffset(String sourceTable, String sourceOffset, boolean isSnapshot)
OffsetWritermarkOffset in interface OffsetWritersourceTable - string in the format of