Documentation ¶
Overview ¶
Copyright 2018 The tiglabs raft Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2018 The tiglabs raft Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2018 The tiglabs raft Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- type Config
- type ErrCorrupt
- type Storage
- func (s *Storage) ApplySnapshot(meta proto.SnapshotMeta) error
- func (s *Storage) Close()
- func (s *Storage) Entries(lo, hi uint64, maxSize uint64) (entries []*proto.Entry, isCompact bool, err error)
- func (s *Storage) FirstIndex() (index uint64, err error)
- func (s *Storage) InitialState() (proto.HardState, error)
- func (s *Storage) LastIndex() (index uint64, err error)
- func (s *Storage) StoreEntries(entries []*proto.Entry) error
- func (s *Storage) StoreHardState(st proto.HardState) error
- func (s *Storage) Term(index uint64) (term uint64, isCompact bool, err error)
- func (s *Storage) Truncate(index uint64) error
Constants ¶
const ( DefaultFileCacheCapacity = 2 DefaultFileSize = 32 * util.MB DefaultSync = false )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // FileCacheCapacity 缓存多少个打开的日志文件(包括index等) FileCacheCapacity int // FileSize 日志文件的大小 FileSize int Sync bool // TruncateFirstDummy 初始化时添加一条日志然后截断 TruncateFirstDummy bool }
Config wal config
func (*Config) GetFileCacheCapacity ¶
func (*Config) GetFileSize ¶
func (*Config) GetTruncateFirstDummy ¶
type ErrCorrupt ¶
type ErrCorrupt struct {
// contains filtered or unexported fields
}
ErrCorrupt error
func NewCorruptError ¶
func NewCorruptError(filename string, offset int64, reason string) *ErrCorrupt
NewCorruptError new
func (*ErrCorrupt) Error ¶
func (e *ErrCorrupt) Error() string
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage the storage
func (*Storage) ApplySnapshot ¶
func (s *Storage) ApplySnapshot(meta proto.SnapshotMeta) error
ApplySnapshot Sync snapshot status.
func (*Storage) Entries ¶
func (s *Storage) Entries(lo, hi uint64, maxSize uint64) (entries []*proto.Entry, isCompact bool, err error)
Entries returns a slice of log entries in the range [lo,hi), the hi is not inclusive. MaxSize limits the total size of the log entries returned, but Entries returns at least one entry if any. If lo <= CompactIndex,then return isCompact true. If no entries,then return entries nil. Note: math.MaxUint32 is no limit.
func (*Storage) FirstIndex ¶
FirstIndex returns the index of the first log entry that is possibly available via Entries (older entries have been incorporated into the latest Snapshot; if storage only contains the dummy entry the first log entry is not available).
func (*Storage) InitialState ¶
InitialState returns the saved HardState information to init the repl state.
func (*Storage) StoreEntries ¶
StoreEntries store the log entries to the repository. If first index of entries > LastIndex,then append all entries, Else write entries at first index and truncate the redundant log entries.
func (*Storage) StoreHardState ¶
StoreHardState store the raft state to the repository.