Documentation ¶
Index ¶
- Constants
- Variables
- func GetEntrySliceInMemSize(ents []Entry) uint64
- func GetEntrySliceSize(ents []Entry) uint64
- func IsEmptySnapshot(s Snapshot) bool
- func IsEmptyState(st State) bool
- func IsStateEqual(a State, b State) bool
- func MustMarshal(m Marshaler) []byte
- func MustMarshalTo(m Marshaler, result []byte) []byte
- func MustUnmarshal(m Unmarshaler, data []byte)
- type Bootstrap
- type ChecksumType
- type Chunk
- type ColferError
- type ColferMax
- type ColferTail
- type CompressionType
- type ConfigChange
- type ConfigChangeType
- type Entry
- func (m *Entry) IsConfigChange() bool
- func (m *Entry) IsEmpty() bool
- func (m *Entry) IsEndOfSessionRequest() bool
- func (m *Entry) IsNewSessionRequest() bool
- func (m *Entry) IsNoOPSession() bool
- func (m *Entry) IsProposal() bool
- func (m *Entry) IsSessionManaged() bool
- func (m *Entry) IsUpdateEntry() bool
- func (m *Entry) Marshal() (dAtA []byte, err error)
- func (m *Entry) MarshalTo(buf []byte) (int, error)
- func (m *Entry) Size() int
- func (m *Entry) SizeUpperLimit() int
- func (m *Entry) Unmarshal(data []byte) error
- type EntryBatch
- type EntryType
- type IChunkSink
- type ICompactor
- type Marshaler
- type Membership
- type Message
- type MessageBatch
- type MessageType
- type RaftDataStatus
- type ReadyToRead
- type Snapshot
- func (m *Snapshot) Load(c ICompactor)
- func (m *Snapshot) Marshal() (dAtA []byte, err error)
- func (m *Snapshot) MarshalTo(dAtA []byte) (int, error)
- func (m *Snapshot) Ref()
- func (m *Snapshot) Size() (n int)
- func (m *Snapshot) Unmarshal(dAtA []byte) error
- func (m *Snapshot) Unref() error
- func (snapshot *Snapshot) Validate(fs vfs.IFS) bool
- type SnapshotFile
- type SnapshotHeader
- type State
- type StateMachineType
- type SystemCtx
- type Unmarshaler
- type Update
- type UpdateCommit
Constants ¶
const ( // NoNode is the flag used to indicate that the node id field is not set. NoNode uint64 = 0 )
const (
// RaftEntryEncodingScheme is the scheme name of the codec.
RaftEntryEncodingScheme = "colfer"
)
Variables ¶
var ( ErrInvalidLengthRaft = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowRaft = fmt.Errorf("proto: integer overflow") )
var ( // LastChunkCount is the special chunk count value used to indicate that the // chunk is the last one. LastChunkCount uint64 = math.MaxUint64 // PoisonChunkCount is the special chunk count value used to indicate that // the processing goroutine should return. PoisonChunkCount uint64 = math.MaxUint64 - 1 )
var ChecksumType_name = map[int32]string{
0: "CRC32IEEE",
1: "HIGHWAY",
}
var ChecksumType_value = map[string]int32{
"CRC32IEEE": 0,
"HIGHWAY": 1,
}
var ( // ColferSizeMax is the upper limit for serial byte sizes ColferSizeMax uint64 = 8 * 1024 * 1024 * 1024 * 1024 )
Colfer configuration attributes
var CompressionType_name = map[int32]string{
0: "NoCompression",
1: "Snappy",
}
var CompressionType_value = map[string]int32{
"NoCompression": 0,
"Snappy": 1,
}
var ConfigChangeType_name = map[int32]string{
0: "AddNode",
1: "RemoveNode",
2: "AddNonVoting",
3: "AddWitness",
}
var ConfigChangeType_value = map[string]int32{
"AddNode": 0,
"RemoveNode": 1,
"AddNonVoting": 2,
"AddWitness": 3,
}
var EntryType_name = map[int32]string{
0: "ApplicationEntry",
1: "ConfigChangeEntry",
2: "EncodedEntry",
3: "MetadataEntry",
}
var EntryType_value = map[string]int32{
"ApplicationEntry": 0,
"ConfigChangeEntry": 1,
"EncodedEntry": 2,
"MetadataEntry": 3,
}
var MessageType_name = map[int32]string{
0: "LocalTick",
1: "Election",
2: "LeaderHeartbeat",
3: "ConfigChangeEvent",
4: "NoOP",
5: "Ping",
6: "Pong",
7: "Propose",
8: "SnapshotStatus",
9: "Unreachable",
10: "CheckQuorum",
11: "BatchedReadIndex",
12: "Replicate",
13: "ReplicateResp",
14: "RequestVote",
15: "RequestVoteResp",
16: "InstallSnapshot",
17: "Heartbeat",
18: "HeartbeatResp",
19: "ReadIndex",
20: "ReadIndexResp",
21: "Quiesce",
22: "SnapshotReceived",
23: "LeaderTransfer",
24: "TimeoutNow",
25: "RateLimit",
26: "RequestPreVote",
27: "RequestPreVoteResp",
}
var MessageType_value = map[string]int32{
"LocalTick": 0,
"Election": 1,
"LeaderHeartbeat": 2,
"ConfigChangeEvent": 3,
"NoOP": 4,
"Ping": 5,
"Pong": 6,
"Propose": 7,
"SnapshotStatus": 8,
"Unreachable": 9,
"CheckQuorum": 10,
"BatchedReadIndex": 11,
"Replicate": 12,
"ReplicateResp": 13,
"RequestVote": 14,
"RequestVoteResp": 15,
"InstallSnapshot": 16,
"Heartbeat": 17,
"HeartbeatResp": 18,
"ReadIndex": 19,
"ReadIndexResp": 20,
"Quiesce": 21,
"SnapshotReceived": 22,
"LeaderTransfer": 23,
"TimeoutNow": 24,
"RateLimit": 25,
"RequestPreVote": 26,
"RequestPreVoteResp": 27,
}
var StateMachineType_name = map[int32]string{
0: "UnknownStateMachine",
1: "RegularStateMachine",
2: "ConcurrentStateMachine",
3: "OnDiskStateMachine",
}
var StateMachineType_value = map[string]int32{
"UnknownStateMachine": 0,
"RegularStateMachine": 1,
"ConcurrentStateMachine": 2,
"OnDiskStateMachine": 3,
}
Functions ¶
func GetEntrySliceInMemSize ¶
GetEntrySliceInMemSize returns the in memory size of the specified entry slice. Size 24 bytes used to hold ents itself is not counted.
func GetEntrySliceSize ¶
GetEntrySliceSize returns the upper limit of the entry slice size.
func IsEmptySnapshot ¶
IsEmptySnapshot returns a boolean flag indicating whether the given snapshot is and empty dummy record.
func IsEmptyState ¶
IsEmptyState returns a boolean flag indicating whether the given State is empty.
func IsStateEqual ¶
IsStateEqual returns whether two input state instances are equal.
func MustMarshal ¶
MustMarshal marshals the input object or panic if there is any error.
func MustMarshalTo ¶
MustMarshalTo marshals the input object to the specified buffer or panic if there is any error.
func MustUnmarshal ¶
func MustUnmarshal(m Unmarshaler, data []byte)
MustUnmarshal unmarshals the specified object using the provided marshalled data. MustUnmarshal will panic if there is any error.
Types ¶
type Bootstrap ¶
type Bootstrap struct { Addresses map[uint64]string Join bool Type StateMachineType }
func NewBootstrapInfo ¶
func NewBootstrapInfo(join bool, smType StateMachineType, nodes map[uint64]string) Bootstrap
NewBootstrapInfo creates and returns a new bootstrap record.
type ChecksumType ¶
type ChecksumType int32
const ( CRC32IEEE ChecksumType = 0 HIGHWAY ChecksumType = 1 )
func (ChecksumType) String ¶
func (x ChecksumType) String() string
type Chunk ¶
type Chunk struct { ClusterId uint64 NodeId uint64 From uint64 ChunkId uint64 ChunkSize uint64 ChunkCount uint64 Data []byte Index uint64 Term uint64 Membership Membership Filepath string FileSize uint64 DeploymentId uint64 FileChunkId uint64 FileChunkCount uint64 HasFileInfo bool FileInfo SnapshotFile BinVer uint32 OnDiskIndex uint64 Witness bool }
func (Chunk) IsLastChunk ¶
IsLastChunk returns a boolean value indicating whether the chunk is the last chunk of a snapshot.
func (Chunk) IsLastFileChunk ¶
IsLastFileChunk returns a boolean value indicating whether the chunk is the last chunk of a snapshot file.
func (Chunk) IsPoisonChunk ¶
IsPoisonChunk returns a boolean value indicating whether the chunk is a special poison chunk.
type CompressionType ¶
type CompressionType int32
const ( NoCompression CompressionType = 0 Snappy CompressionType = 1 )
func (CompressionType) String ¶
func (x CompressionType) String() string
type ConfigChange ¶
type ConfigChange struct { ConfigChangeId uint64 Type ConfigChangeType NodeID uint64 Address string Initialize bool }
func (*ConfigChange) Marshal ¶
func (m *ConfigChange) Marshal() (dAtA []byte, err error)
func (*ConfigChange) Size ¶
func (m *ConfigChange) Size() (n int)
func (*ConfigChange) Unmarshal ¶
func (m *ConfigChange) Unmarshal(dAtA []byte) error
type ConfigChangeType ¶
type ConfigChangeType int32
const ( AddNode ConfigChangeType = 0 RemoveNode ConfigChangeType = 1 AddNonVoting ConfigChangeType = 2 AddWitness ConfigChangeType = 3 )
func (ConfigChangeType) String ¶
func (x ConfigChangeType) String() string
type Entry ¶
type Entry struct { Term uint64 Index uint64 Type EntryType Key uint64 ClientID uint64 SeriesID uint64 RespondedTo uint64 Cmd []byte }
func (*Entry) IsConfigChange ¶
IsConfigChange returns a boolean value indicating whether the entry is for config change.
func (*Entry) IsEndOfSessionRequest ¶
IsEndOfSessionRequest returns a boolean value indicating whether the entry is for requesting the session to come to an end.
func (*Entry) IsNewSessionRequest ¶
IsNewSessionRequest returns a boolean value indicating whether the entry is for reqeusting a new client.
func (*Entry) IsNoOPSession ¶
IsNoOPSession returns a boolean value indicating whether the entry is NoOP session managed.
func (*Entry) IsProposal ¶
IsProposal returns a boolean value indicating whether the entry is a regular update entry.
func (*Entry) IsSessionManaged ¶
IsSessionManaged returns a boolean value indicating whether the entry is session managed.
func (*Entry) IsUpdateEntry ¶
IsUpdateEntry returns a boolean flag indicating whether the entry is a regular application entry not used for session management.
func (*Entry) SizeUpperLimit ¶
SizeUpperLimit returns the upper limit size of an entry.
type EntryBatch ¶
type EntryBatch struct {
Entries []Entry
}
func (*EntryBatch) Marshal ¶
func (m *EntryBatch) Marshal() (dAtA []byte, err error)
func (*EntryBatch) Size ¶
func (m *EntryBatch) Size() (n int)
func (*EntryBatch) SizeUpperLimit ¶
func (m *EntryBatch) SizeUpperLimit() (n int)
SizeUpperLimit returns the upper limit size of the entry batch.
func (*EntryBatch) Unmarshal ¶
func (m *EntryBatch) Unmarshal(dAtA []byte) error
type IChunkSink ¶
type IChunkSink interface { // return (sent, stopped) Receive(chunk Chunk) (bool, bool) Close() error ClusterID() uint64 ToNodeID() uint64 }
IChunkSink is the snapshot chunk sink for handling snapshot chunks being streamed.
type ICompactor ¶
type Membership ¶
type Membership struct { ConfigChangeId uint64 Addresses map[uint64]string Removed map[uint64]bool NonVotings map[uint64]string Witnesses map[uint64]string }
func (*Membership) Marshal ¶
func (m *Membership) Marshal() (dAtA []byte, err error)
func (*Membership) Size ¶
func (m *Membership) Size() (n int)
func (*Membership) Unmarshal ¶
func (m *Membership) Unmarshal(dAtA []byte) error
type Message ¶
type Message struct { Type MessageType To uint64 From uint64 ClusterId uint64 Term uint64 LogTerm uint64 LogIndex uint64 Commit uint64 Reject bool Hint uint64 Entries []Entry Snapshot Snapshot HintHigh uint64 }
func (*Message) CanDrop ¶
CanDrop returns a boolean value indicating whether the message can be safely dropped.
func (*Message) SizeUpperLimit ¶
SizeUpperLimit returns the upper limit size of the message.
type MessageBatch ¶
type MessageBatch struct { Requests []*Message DeploymentId uint64 SourceAddress string BinVer uint32 }
func (*MessageBatch) Marshal ¶
func (m *MessageBatch) Marshal() (dAtA []byte, err error)
func (*MessageBatch) Size ¶
func (m *MessageBatch) Size() (n int)
func (*MessageBatch) SizeUpperLimit ¶
func (m *MessageBatch) SizeUpperLimit() int
SizeUpperLimit returns the upper limit size of the message batch.
func (*MessageBatch) Unmarshal ¶
func (m *MessageBatch) Unmarshal(dAtA []byte) error
Unmarshal unmarshals the message batch instance using the input byte slice.
type MessageType ¶
type MessageType int32
const ( LocalTick MessageType = 0 Election MessageType = 1 LeaderHeartbeat MessageType = 2 ConfigChangeEvent MessageType = 3 NoOP MessageType = 4 Ping MessageType = 5 Pong MessageType = 6 Propose MessageType = 7 SnapshotStatus MessageType = 8 Unreachable MessageType = 9 CheckQuorum MessageType = 10 BatchedReadIndex MessageType = 11 Replicate MessageType = 12 ReplicateResp MessageType = 13 RequestVote MessageType = 14 RequestVoteResp MessageType = 15 InstallSnapshot MessageType = 16 Heartbeat MessageType = 17 HeartbeatResp MessageType = 18 ReadIndex MessageType = 19 ReadIndexResp MessageType = 20 Quiesce MessageType = 21 SnapshotReceived MessageType = 22 LeaderTransfer MessageType = 23 TimeoutNow MessageType = 24 RateLimit MessageType = 25 RequestPreVote MessageType = 26 RequestPreVoteResp MessageType = 27 )
func (MessageType) String ¶
func (x MessageType) String() string
type RaftDataStatus ¶
type RaftDataStatus struct { Address string BinVer uint32 HardHash uint64 LogdbType string Hostname string DeploymentId uint64 StepWorkerCount uint64 LogdbShardCount uint64 MaxSessionCount uint64 EntryBatchSize uint64 AddressByNodeHostId bool }
func (*RaftDataStatus) Marshal ¶
func (m *RaftDataStatus) Marshal() (dAtA []byte, err error)
func (*RaftDataStatus) Size ¶
func (m *RaftDataStatus) Size() (n int)
func (*RaftDataStatus) Unmarshal ¶
func (m *RaftDataStatus) Unmarshal(dAtA []byte) error
type ReadyToRead ¶
ReadyToRead is used to indicate that a previous batch of ReadIndex requests are now ready for read once the entry specified by the Index value is applied in the state machine.
type Snapshot ¶
type Snapshot struct { Filepath string FileSize uint64 Index uint64 Term uint64 Membership Membership Files []*SnapshotFile Checksum []byte Dummy bool ClusterId uint64 Type StateMachineType Imported bool OnDiskIndex uint64 Witness bool // contains filtered or unexported fields }
func (*Snapshot) Load ¶
func (m *Snapshot) Load(c ICompactor)
type SnapshotFile ¶
func (*SnapshotFile) Filename ¶
func (m *SnapshotFile) Filename() string
Filename returns the filename of the external snapshot file.
func (*SnapshotFile) Marshal ¶
func (m *SnapshotFile) Marshal() (dAtA []byte, err error)
func (*SnapshotFile) Size ¶
func (m *SnapshotFile) Size() (n int)
func (*SnapshotFile) Unmarshal ¶
func (m *SnapshotFile) Unmarshal(dAtA []byte) error
type SnapshotHeader ¶
type SnapshotHeader struct { SessionSize uint64 DataStoreSize uint64 UnreliableTime uint64 GitVersion string HeaderChecksum []byte PayloadChecksum []byte ChecksumType ChecksumType Version uint64 CompressionType CompressionType }
func (*SnapshotHeader) Marshal ¶
func (m *SnapshotHeader) Marshal() (dAtA []byte, err error)
func (*SnapshotHeader) Size ¶
func (m *SnapshotHeader) Size() (n int)
func (*SnapshotHeader) Unmarshal ¶
func (m *SnapshotHeader) Unmarshal(dAtA []byte) error
type State ¶
func (*State) SizeUpperLimit ¶
SizeUpperLimit returns the upper limit size of the state instance.
type StateMachineType ¶
type StateMachineType int32
const ( UnknownStateMachine StateMachineType = 0 RegularStateMachine StateMachineType = 1 ConcurrentStateMachine StateMachineType = 2 OnDiskStateMachine StateMachineType = 3 )
func (StateMachineType) String ¶
func (x StateMachineType) String() string
type Unmarshaler ¶
Unmarshaler is the interface for instances that can be unmarshalled.
type Update ¶
type Update struct { ClusterID uint64 NodeID uint64 // The current persistent state of a raft node. It must be stored onto // persistent storage before any non-replication can be sent to other nodes. // isStateEqual(emptyState) returns true when the state is empty. State // whether CommittedEntries can be applied without waiting for the Update // to be persisted to disk FastApply bool // EntriesToSave are entries waiting to be stored onto persistent storage. EntriesToSave []Entry // CommittedEntries are entries already committed in raft and ready to be // applied by dragonboat applications. CommittedEntries []Entry // Whether there are more committed entries ready to be applied. MoreCommittedEntries bool // Snapshot is the metadata of the snapshot ready to be applied. Snapshot Snapshot // ReadyToReads provides a list of ReadIndex requests ready for local read. ReadyToReads []ReadyToRead // Messages is a list of outgoing messages to be sent to remote nodes. // As stated above, replication messages can be immediately sent, all other // messages must be sent after the persistent state and entries are saved // onto persistent storage. Messages []*Message // LastApplied is the actual last applied index reported by the RSM. LastApplied uint64 // UpdateCommit contains info on how the Update instance can be committed // to actually progress the state of raft. UpdateCommit UpdateCommit // DroppedEntries is a list of entries dropped when no leader is available DroppedEntries []Entry // DroppedReadIndexes is a list of read index requests dropped when no leader // is available. DroppedReadIndexes []SystemCtx }
Update is a collection of state, entries and messages that are expected to be processed by raft's upper layer to progress the raft node modelled as state machine.
func (*Update) HasUpdate ¶
HasUpdate returns a boolean value indicating whether the returned Update instance actually has any update to be processed.
func (*Update) MarshalTo ¶
MarshalTo encodes the fields that need to be persisted to the specified buffer.
func (*Update) SizeUpperLimit ¶
SizeUpperLimit returns the upper limit of the estimated size of marshalled Update instance.
type UpdateCommit ¶
type UpdateCommit struct { // the last index known to be pushed to rsm for execution. Processed uint64 // the last index confirmed to be executed. LastApplied uint64 StableLogTo uint64 StableLogTerm uint64 StableSnapshotTo uint64 ReadyToRead uint64 }
UpdateCommit is used to describe how to commit the Update instance to progress the state of raft.