Documentation ¶
Index ¶
Constants ¶
View Source
const ( MetadataType int64 = iota + 1 EntryType StateType SnapshotType CrcType )
Variables ¶
View Source
var (
SegmentSizeBytes int64 = 64 * 1000 * 1000 // 64MB
)
Functions ¶
Types ¶
type FileWAL ¶
type FileWAL struct {
// contains filtered or unexported fields
}
func NewFileWAL ¶
func NewReadOnlyFileWal ¶
type LogFileLCM ¶
type LogFileLCM struct {
// contains filtered or unexported fields
}
LogFileLCM is responsible for log file life cycle manage
func NewLogFileLCM ¶
func NewLogFileLCM(dir string, fileSize int64) (*LogFileLCM, error)
func (*LogFileLCM) Cut ¶
func (llcm *LogFileLCM) Cut(preCut func() error, initNew func(file *os.File) error, postCut func(file *os.File) error, index uint64) error
Cut will Cut the file as it reach to the pre-defined size limit
func (*LogFileLCM) SetTail ¶
func (llcm *LogFileLCM) SetTail(file *os.File)
func (*LogFileLCM) Stop ¶
func (llcm *LogFileLCM) Stop() error
type LogFileReader ¶
type LogFileReader struct {
// contains filtered or unexported fields
}
func NewLogFileReader ¶
func NewLogFileReader(dir string, snapshot raftpb.SnapshotMetadata) (*LogFileReader, error)
func (*LogFileReader) Close ¶
func (lr *LogFileReader) Close() error
func (*LogFileReader) Tail ¶
func (lr *LogFileReader) Tail() *os.File
func (*LogFileReader) TailOffset ¶
func (lr *LogFileReader) TailOffset() int64
type LogFileWriter ¶
type LogFileWriter struct {
// contains filtered or unexported fields
}
func NewLogFileWriter ¶
func NewLogFileWriter(f *os.File, offset int64) (*LogFileWriter, error)
func (*LogFileWriter) Close ¶
func (lw *LogFileWriter) Close() error
func (*LogFileWriter) CurOffset ¶
func (lw *LogFileWriter) CurOffset() (int64, error)
func (*LogFileWriter) Flush ¶
func (lw *LogFileWriter) Flush() error
func (*LogFileWriter) Sync ¶
func (lw *LogFileWriter) Sync() error
type PageWriter ¶
type PageWriter struct {
// contains filtered or unexported fields
}
PageWriter implements the io.Writer interface so that writes will either be in page chunks or from flushing.
func NewPageWriter ¶
func NewPageWriter(w io.Writer, pageBytes, pageOffset int) *PageWriter
NewPageWriter creates a new PageWriter. pageBytes is the number of bytes to write per page. pageOffset is the starting offset of io.Writer.
type WAL ¶
type WAL interface { SaveLog(h raftpb.HardState, entries []raftpb.Entry) error SaveSnapshot(s *raftpb.Snapshot) error // Read will read all the data that walpb contains, it will overwrite itself if conflict Read(s *raftpb.Snapshot) (h raftpb.HardState, e []raftpb.Entry, err error) Start() error Close() error }
WAL has two purposes: - first is to write data to the log file. - second is to read out all the log records to help the raft node upon restart/start
Click to show internal directories.
Click to hide internal directories.