raftpb

package
v0.0.0-...-649f594 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EntryType_name = map[int32]string{
		0: "EntryNormal",
		1: "EntryConfChangeV2",
	}
	EntryType_value = map[string]int32{
		"EntryNormal":       0,
		"EntryConfChangeV2": 1,
	}
)

Enum value maps for EntryType.

View Source
var (
	MessageType_name = map[int32]string{
		0:  "MsgHup",
		1:  "MsgBeat",
		2:  "MsgProp",
		3:  "MsgApp",
		4:  "MsgAppResp",
		5:  "MsgVote",
		6:  "MsgVoteResp",
		7:  "MsgSnap",
		8:  "MsgHeartbeat",
		9:  "MsgHeartbeatResp",
		10: "MsgUnreachable",
		11: "MsgSnapStatus",
		12: "MsgCheckQuorum",
		13: "MsgTransferLeader",
		14: "MsgTimeoutNow",
		15: "MsgReadIndex",
		16: "MsgReadIndexResp",
		17: "MsgPreVote",
		18: "MsgPreVoteResp",
	}
	MessageType_value = map[string]int32{
		"MsgHup":            0,
		"MsgBeat":           1,
		"MsgProp":           2,
		"MsgApp":            3,
		"MsgAppResp":        4,
		"MsgVote":           5,
		"MsgVoteResp":       6,
		"MsgSnap":           7,
		"MsgHeartbeat":      8,
		"MsgHeartbeatResp":  9,
		"MsgUnreachable":    10,
		"MsgSnapStatus":     11,
		"MsgCheckQuorum":    12,
		"MsgTransferLeader": 13,
		"MsgTimeoutNow":     14,
		"MsgReadIndex":      15,
		"MsgReadIndexResp":  16,
		"MsgPreVote":        17,
		"MsgPreVoteResp":    18,
	}
)

Enum value maps for MessageType.

View Source
var (
	ConfChangeTransition_name = map[int32]string{
		0: "ConfChangeTransitionAuto",
		1: "ConfChangeTransitionJointImplicit",
		2: "ConfChangeTransitionJointExplicit",
	}
	ConfChangeTransition_value = map[string]int32{
		"ConfChangeTransitionAuto":          0,
		"ConfChangeTransitionJointImplicit": 1,
		"ConfChangeTransitionJointExplicit": 2,
	}
)

Enum value maps for ConfChangeTransition.

View Source
var (
	ConfChangeType_name = map[int32]string{
		0: "ConfChangeAddNode",
		1: "ConfChangeRemoveNode",
		2: "ConfChangeUpdateNode",
		3: "ConfChangeAddLearnerNode",
	}
	ConfChangeType_value = map[string]int32{
		"ConfChangeAddNode":        0,
		"ConfChangeRemoveNode":     1,
		"ConfChangeUpdateNode":     2,
		"ConfChangeAddLearnerNode": 3,
	}
)

Enum value maps for ConfChangeType.

Functions

This section is empty.

Types

type ConfChange

type ConfChange struct {
	Type    *ConfChangeType `protobuf:"varint,2,opt,name=type,proto3,enum=raftpb.ConfChangeType,oneof" json:"type,omitempty"`
	NodeId  *uint64         `protobuf:"varint,3,opt,name=node_id,json=nodeId,proto3,oneof" json:"node_id,omitempty"`
	Context []byte          `protobuf:"bytes,4,opt,name=context,proto3,oneof" json:"context,omitempty"`
	// NB: this is used only by etcd to thread through a unique identifier.
	// Ideally it should really use the Context instead. No counterpart to
	// this field exists in ConfChangeV2.
	Id *uint64 `protobuf:"varint,1,opt,name=id,proto3,oneof" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*ConfChange) Descriptor deprecated

func (*ConfChange) Descriptor() ([]byte, []int)

Deprecated: Use ConfChange.ProtoReflect.Descriptor instead.

func (*ConfChange) GetContext

func (x *ConfChange) GetContext() []byte

func (*ConfChange) GetId

func (x *ConfChange) GetId() uint64

func (*ConfChange) GetNodeId

func (x *ConfChange) GetNodeId() uint64

func (*ConfChange) GetType

func (x *ConfChange) GetType() ConfChangeType

func (*ConfChange) ProtoMessage

func (*ConfChange) ProtoMessage()

func (*ConfChange) ProtoReflect

func (x *ConfChange) ProtoReflect() protoreflect.Message

func (*ConfChange) Reset

func (x *ConfChange) Reset()

func (*ConfChange) String

func (x *ConfChange) String() string

type ConfChangeSingle

type ConfChangeSingle struct {
	Type   *ConfChangeType `protobuf:"varint,1,opt,name=type,proto3,enum=raftpb.ConfChangeType,oneof" json:"type,omitempty"`
	NodeId *uint64         `protobuf:"varint,2,opt,name=node_id,json=nodeId,proto3,oneof" json:"node_id,omitempty"`
	// contains filtered or unexported fields
}

ConfChangeSingle is an individual configuration change operation. Multiple such operations can be carried out atomically via a ConfChangeV2.

func (*ConfChangeSingle) Descriptor deprecated

func (*ConfChangeSingle) Descriptor() ([]byte, []int)

Deprecated: Use ConfChangeSingle.ProtoReflect.Descriptor instead.

func (*ConfChangeSingle) GetNodeId

func (x *ConfChangeSingle) GetNodeId() uint64

func (*ConfChangeSingle) GetType

func (x *ConfChangeSingle) GetType() ConfChangeType

func (*ConfChangeSingle) ProtoMessage

func (*ConfChangeSingle) ProtoMessage()

func (*ConfChangeSingle) ProtoReflect

func (x *ConfChangeSingle) ProtoReflect() protoreflect.Message

func (*ConfChangeSingle) Reset

func (x *ConfChangeSingle) Reset()

func (*ConfChangeSingle) String

func (x *ConfChangeSingle) String() string

type ConfChangeTransition

type ConfChangeTransition int32

ConfChangeTransition specifies the behavior of a configuration change with respect to joint consensus.

const (
	// Automatically use the simple protocol if possible, otherwise fall back
	// to ConfChangeJointImplicit. Most applications will want to use this.
	ConfChangeTransition_ConfChangeTransitionAuto ConfChangeTransition = 0
	// Use joint consensus unconditionally, and transition out of them
	// automatically (by proposing a zero configuration change).
	//
	// This option is suitable for applications that want to minimize the time
	// spent in the joint configuration and do not store the joint configuration
	// in the state machine (outside of InitialState).
	ConfChangeTransition_ConfChangeTransitionJointImplicit ConfChangeTransition = 1
	// Use joint consensus and remain in the joint configuration until the
	// application proposes a no-op configuration change. This is suitable for
	// applications that want to explicitly control the transitions, for example
	// to use a custom payload (via the Context field).
	ConfChangeTransition_ConfChangeTransitionJointExplicit ConfChangeTransition = 2
)

func (ConfChangeTransition) Descriptor

func (ConfChangeTransition) Enum

func (ConfChangeTransition) EnumDescriptor deprecated

func (ConfChangeTransition) EnumDescriptor() ([]byte, []int)

Deprecated: Use ConfChangeTransition.Descriptor instead.

func (ConfChangeTransition) Number

func (ConfChangeTransition) String

func (x ConfChangeTransition) String() string

func (ConfChangeTransition) Type

type ConfChangeType

type ConfChangeType int32
const (
	ConfChangeType_ConfChangeAddNode        ConfChangeType = 0
	ConfChangeType_ConfChangeRemoveNode     ConfChangeType = 1
	ConfChangeType_ConfChangeUpdateNode     ConfChangeType = 2
	ConfChangeType_ConfChangeAddLearnerNode ConfChangeType = 3
)

func (ConfChangeType) Descriptor

func (ConfChangeType) Enum

func (x ConfChangeType) Enum() *ConfChangeType

func (ConfChangeType) EnumDescriptor deprecated

func (ConfChangeType) EnumDescriptor() ([]byte, []int)

Deprecated: Use ConfChangeType.Descriptor instead.

func (ConfChangeType) Number

func (ConfChangeType) String

func (x ConfChangeType) String() string

func (ConfChangeType) Type

type ConfChangeV2

type ConfChangeV2 struct {
	Transition *ConfChangeTransition `protobuf:"varint,1,opt,name=transition,proto3,enum=raftpb.ConfChangeTransition,oneof" json:"transition,omitempty"`
	Changes    []*ConfChangeSingle   `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"`
	Context    []byte                `protobuf:"bytes,3,opt,name=context,proto3,oneof" json:"context,omitempty"`
	// contains filtered or unexported fields
}

ConfChangeV2 messages initiate configuration changes. They support both the simple "one at a time" membership change protocol and full Joint Consensus allowing for arbitrary changes in membership.

The supplied context is treated as an opaque payload and can be used to attach an action on the state machine to the application of the config change proposal. Note that contrary to Joint Consensus as outlined in the Raft paper1, configuration changes become active when they are *applied* to the state machine (not when they are appended to the log).

The simple protocol can be used whenever only a single change is made.

Non-simple changes require the use of Joint Consensus, for which two configuration changes are run. The first configuration change specifies the desired changes and transitions the Raft group into the joint configuration, in which quorum requires a majority of both the pre-changes and post-changes configuration. Joint Consensus avoids entering fragile intermediate configurations that could compromise survivability. For example, without the use of Joint Consensus and running across three availability zones with a replication factor of three, it is not possible to replace a voter without entering an intermediate configuration that does not survive the outage of one availability zone.

The provided ConfChangeTransition specifies how (and whether) Joint Consensus is used, and assigns the task of leaving the joint configuration either to Raft or the application. Leaving the joint configuration is accomplished by proposing a ConfChangeV2 with only and optionally the Context field populated.

For details on Raft membership changes, see:

func (*ConfChangeV2) Descriptor deprecated

func (*ConfChangeV2) Descriptor() ([]byte, []int)

Deprecated: Use ConfChangeV2.ProtoReflect.Descriptor instead.

func (*ConfChangeV2) GetChanges

func (x *ConfChangeV2) GetChanges() []*ConfChangeSingle

func (*ConfChangeV2) GetContext

func (x *ConfChangeV2) GetContext() []byte

func (*ConfChangeV2) GetTransition

func (x *ConfChangeV2) GetTransition() ConfChangeTransition

func (*ConfChangeV2) ProtoMessage

func (*ConfChangeV2) ProtoMessage()

func (*ConfChangeV2) ProtoReflect

func (x *ConfChangeV2) ProtoReflect() protoreflect.Message

func (*ConfChangeV2) Reset

func (x *ConfChangeV2) Reset()

func (*ConfChangeV2) String

func (x *ConfChangeV2) String() string

type ConfState

type ConfState struct {

	// The voters in the incoming config. (If the configuration is not joint,
	// then the outgoing config is empty).
	Voters []uint64 `protobuf:"varint,1,rep,packed,name=voters,proto3" json:"voters,omitempty"`
	// The learners in the incoming config.
	Learners []uint64 `protobuf:"varint,2,rep,packed,name=learners,proto3" json:"learners,omitempty"`
	// The voters in the outgoing config.
	VotersOutgoing []uint64 `protobuf:"varint,3,rep,packed,name=voters_outgoing,json=votersOutgoing,proto3" json:"voters_outgoing,omitempty"`
	// The nodes that will become learners when the outgoing config is removed.
	// These nodes are necessarily currently in nodes_joint (or they would have
	// been added to the incoming config right away).
	LearnersNext []uint64 `protobuf:"varint,4,rep,packed,name=learners_next,json=learnersNext,proto3" json:"learners_next,omitempty"`
	// If set, the config is joint and Raft will automatically transition into
	// the final config (i.e. remove the outgoing config) when this is safe.
	AutoLeave *bool `protobuf:"varint,5,opt,name=auto_leave,json=autoLeave,proto3,oneof" json:"auto_leave,omitempty"`
	// contains filtered or unexported fields
}

func (*ConfState) Descriptor deprecated

func (*ConfState) Descriptor() ([]byte, []int)

Deprecated: Use ConfState.ProtoReflect.Descriptor instead.

func (*ConfState) GetAutoLeave

func (x *ConfState) GetAutoLeave() bool

func (*ConfState) GetLearners

func (x *ConfState) GetLearners() []uint64

func (*ConfState) GetLearnersNext

func (x *ConfState) GetLearnersNext() []uint64

func (*ConfState) GetVoters

func (x *ConfState) GetVoters() []uint64

func (*ConfState) GetVotersOutgoing

func (x *ConfState) GetVotersOutgoing() []uint64

func (*ConfState) ProtoMessage

func (*ConfState) ProtoMessage()

func (*ConfState) ProtoReflect

func (x *ConfState) ProtoReflect() protoreflect.Message

func (*ConfState) Reset

func (x *ConfState) Reset()

func (*ConfState) String

func (x *ConfState) String() string

type Entry

type Entry struct {
	Term  *uint64    `protobuf:"varint,2,opt,name=Term,proto3,oneof" json:"Term,omitempty"`   // must be 64-bit aligned for atomic operations
	Index *uint64    `protobuf:"varint,3,opt,name=Index,proto3,oneof" json:"Index,omitempty"` // must be 64-bit aligned for atomic operations
	Type  *EntryType `protobuf:"varint,1,opt,name=Type,proto3,enum=raftpb.EntryType,oneof" json:"Type,omitempty"`
	Data  []byte     `protobuf:"bytes,4,opt,name=Data,proto3,oneof" json:"Data,omitempty"`
	// contains filtered or unexported fields
}

func (*Entry) Descriptor deprecated

func (*Entry) Descriptor() ([]byte, []int)

Deprecated: Use Entry.ProtoReflect.Descriptor instead.

func (*Entry) GetData

func (x *Entry) GetData() []byte

func (*Entry) GetIndex

func (x *Entry) GetIndex() uint64

func (*Entry) GetTerm

func (x *Entry) GetTerm() uint64

func (*Entry) GetType

func (x *Entry) GetType() EntryType

func (*Entry) ProtoMessage

func (*Entry) ProtoMessage()

func (*Entry) ProtoReflect

func (x *Entry) ProtoReflect() protoreflect.Message

func (*Entry) Reset

func (x *Entry) Reset()

func (*Entry) String

func (x *Entry) String() string

type EntryType

type EntryType int32
const (
	EntryType_EntryNormal       EntryType = 0
	EntryType_EntryConfChangeV2 EntryType = 1 // corresponds to pb.ConfChangeV2
)

func (EntryType) Descriptor

func (EntryType) Descriptor() protoreflect.EnumDescriptor

func (EntryType) Enum

func (x EntryType) Enum() *EntryType

func (EntryType) EnumDescriptor deprecated

func (EntryType) EnumDescriptor() ([]byte, []int)

Deprecated: Use EntryType.Descriptor instead.

func (EntryType) Number

func (x EntryType) Number() protoreflect.EnumNumber

func (EntryType) String

func (x EntryType) String() string

func (EntryType) Type

type HardState

type HardState struct {
	Term   *uint64 `protobuf:"varint,1,opt,name=term,proto3,oneof" json:"term,omitempty"`
	Vote   *uint64 `protobuf:"varint,2,opt,name=vote,proto3,oneof" json:"vote,omitempty"`
	Commit *uint64 `protobuf:"varint,3,opt,name=commit,proto3,oneof" json:"commit,omitempty"`
	// contains filtered or unexported fields
}

func (*HardState) Descriptor deprecated

func (*HardState) Descriptor() ([]byte, []int)

Deprecated: Use HardState.ProtoReflect.Descriptor instead.

func (*HardState) GetCommit

func (x *HardState) GetCommit() uint64

func (*HardState) GetTerm

func (x *HardState) GetTerm() uint64

func (*HardState) GetVote

func (x *HardState) GetVote() uint64

func (*HardState) ProtoMessage

func (*HardState) ProtoMessage()

func (*HardState) ProtoReflect

func (x *HardState) ProtoReflect() protoreflect.Message

func (*HardState) Reset

func (x *HardState) Reset()

func (*HardState) String

func (x *HardState) String() string

type Message

type Message struct {
	Type *MessageType `protobuf:"varint,1,opt,name=type,proto3,enum=raftpb.MessageType,oneof" json:"type,omitempty"`
	To   *uint64      `protobuf:"varint,2,opt,name=to,proto3,oneof" json:"to,omitempty"`
	From *uint64      `protobuf:"varint,3,opt,name=from,proto3,oneof" json:"from,omitempty"`
	Term *uint64      `protobuf:"varint,4,opt,name=term,proto3,oneof" json:"term,omitempty"`
	// logTerm is generally used for appending Raft logs to followers. For example,
	// (type=MsgApp,index=100,logTerm=5) means leader appends entries starting at
	// index=101, and the term of entry at index 100 is 5.
	// (type=MsgAppResp,reject=true,index=100,logTerm=5) means follower rejects some
	// entries from its leader as it already has an entry with term 5 at index 100.
	LogTerm    *uint64   `protobuf:"varint,5,opt,name=logTerm,proto3,oneof" json:"logTerm,omitempty"`
	Index      *uint64   `protobuf:"varint,6,opt,name=index,proto3,oneof" json:"index,omitempty"`
	Entries    []*Entry  `protobuf:"bytes,7,rep,name=entries,proto3" json:"entries,omitempty"`
	Commit     *uint64   `protobuf:"varint,8,opt,name=commit,proto3,oneof" json:"commit,omitempty"`
	Snapshot   *Snapshot `protobuf:"bytes,9,opt,name=snapshot,proto3,oneof" json:"snapshot,omitempty"`
	Reject     *bool     `protobuf:"varint,10,opt,name=reject,proto3,oneof" json:"reject,omitempty"`
	RejectHint *uint64   `protobuf:"varint,11,opt,name=rejectHint,proto3,oneof" json:"rejectHint,omitempty"`
	Context    []byte    `protobuf:"bytes,12,opt,name=context,proto3,oneof" json:"context,omitempty"`
	// contains filtered or unexported fields
}

func (*Message) Descriptor deprecated

func (*Message) Descriptor() ([]byte, []int)

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetCommit

func (x *Message) GetCommit() uint64

func (*Message) GetContext

func (x *Message) GetContext() []byte

func (*Message) GetEntries

func (x *Message) GetEntries() []*Entry

func (*Message) GetFrom

func (x *Message) GetFrom() uint64

func (*Message) GetIndex

func (x *Message) GetIndex() uint64

func (*Message) GetLogTerm

func (x *Message) GetLogTerm() uint64

func (*Message) GetReject

func (x *Message) GetReject() bool

func (*Message) GetRejectHint

func (x *Message) GetRejectHint() uint64

func (*Message) GetSnapshot

func (x *Message) GetSnapshot() *Snapshot

func (*Message) GetTerm

func (x *Message) GetTerm() uint64

func (*Message) GetTo

func (x *Message) GetTo() uint64

func (*Message) GetType

func (x *Message) GetType() MessageType

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Reset

func (x *Message) Reset()

func (*Message) String

func (x *Message) String() string

type MessageType

type MessageType int32

For description of different message types

const (
	MessageType_MsgHup            MessageType = 0
	MessageType_MsgBeat           MessageType = 1
	MessageType_MsgProp           MessageType = 2
	MessageType_MsgApp            MessageType = 3
	MessageType_MsgAppResp        MessageType = 4
	MessageType_MsgVote           MessageType = 5
	MessageType_MsgVoteResp       MessageType = 6
	MessageType_MsgSnap           MessageType = 7
	MessageType_MsgHeartbeat      MessageType = 8
	MessageType_MsgHeartbeatResp  MessageType = 9
	MessageType_MsgUnreachable    MessageType = 10
	MessageType_MsgSnapStatus     MessageType = 11
	MessageType_MsgCheckQuorum    MessageType = 12
	MessageType_MsgTransferLeader MessageType = 13
	MessageType_MsgTimeoutNow     MessageType = 14
	MessageType_MsgReadIndex      MessageType = 15
	MessageType_MsgReadIndexResp  MessageType = 16
	MessageType_MsgPreVote        MessageType = 17
	MessageType_MsgPreVoteResp    MessageType = 18
)

func (MessageType) Descriptor

func (MessageType) Enum

func (x MessageType) Enum() *MessageType

func (MessageType) EnumDescriptor deprecated

func (MessageType) EnumDescriptor() ([]byte, []int)

Deprecated: Use MessageType.Descriptor instead.

func (MessageType) Number

func (x MessageType) Number() protoreflect.EnumNumber

func (MessageType) String

func (x MessageType) String() string

func (MessageType) Type

type Snapshot

type Snapshot struct {
	Data     []byte            `protobuf:"bytes,1,opt,name=data,proto3,oneof" json:"data,omitempty"`
	Metadata *SnapshotMetadata `protobuf:"bytes,2,opt,name=metadata,proto3,oneof" json:"metadata,omitempty"`
	// contains filtered or unexported fields
}

func (*Snapshot) Descriptor deprecated

func (*Snapshot) Descriptor() ([]byte, []int)

Deprecated: Use Snapshot.ProtoReflect.Descriptor instead.

func (*Snapshot) GetData

func (x *Snapshot) GetData() []byte

func (*Snapshot) GetMetadata

func (x *Snapshot) GetMetadata() *SnapshotMetadata

func (*Snapshot) ProtoMessage

func (*Snapshot) ProtoMessage()

func (*Snapshot) ProtoReflect

func (x *Snapshot) ProtoReflect() protoreflect.Message

func (*Snapshot) Reset

func (x *Snapshot) Reset()

func (*Snapshot) String

func (x *Snapshot) String() string

type SnapshotMetadata

type SnapshotMetadata struct {
	ConfState *ConfState `protobuf:"bytes,1,opt,name=conf_state,json=confState,proto3,oneof" json:"conf_state,omitempty"`
	Index     *uint64    `protobuf:"varint,2,opt,name=index,proto3,oneof" json:"index,omitempty"`
	Term      *uint64    `protobuf:"varint,3,opt,name=term,proto3,oneof" json:"term,omitempty"`
	// contains filtered or unexported fields
}

func (*SnapshotMetadata) Descriptor deprecated

func (*SnapshotMetadata) Descriptor() ([]byte, []int)

Deprecated: Use SnapshotMetadata.ProtoReflect.Descriptor instead.

func (*SnapshotMetadata) GetConfState

func (x *SnapshotMetadata) GetConfState() *ConfState

func (*SnapshotMetadata) GetIndex

func (x *SnapshotMetadata) GetIndex() uint64

func (*SnapshotMetadata) GetTerm

func (x *SnapshotMetadata) GetTerm() uint64

func (*SnapshotMetadata) ProtoMessage

func (*SnapshotMetadata) ProtoMessage()

func (*SnapshotMetadata) ProtoReflect

func (x *SnapshotMetadata) ProtoReflect() protoreflect.Message

func (*SnapshotMetadata) Reset

func (x *SnapshotMetadata) Reset()

func (*SnapshotMetadata) String

func (x *SnapshotMetadata) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL