core

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GRANTED_OK           int32 = 1
	GRANTED_TERM_OLD     int32 = 2
	GRANTED_ID_LITTLE    int32 = 3
	GRANTED_DATA_OLD     int32 = 4
	GRANTED_LEADER_ALIVE int32 = 5
	GRANTED_VOTEOTHER    int32 = 6
)
View Source
const (
	HEARTBEAT_OK        int32 = 1
	HEARTBEAT_TERM_OLD  int32 = 2
	HEARTBEAT_PARTITION int32 = 3
)
View Source
const (
	NODEINFO_SYNCID  int32 = 1
	NODEINFO_ADDPEER int32 = 2
	NODEINFO_DELPEER int32 = 3
	NODEINFO_NOTIFY  int32 = 4
)
View Source
const (
	SYNC_OK         int32 = 1
	SYNC_NOTFOUND   int32 = 2
	SYNC_NOT_LEADER int32 = 3
	SYNC_ERROR      int32 = 4
	SYNC_PREPARE    int32 = 5
)
View Source
const (
	SYNCTYPE_MISS  int32 = 1
	SYNCTYPE_EMPTY int32 = 2
	SYNCTYPE_EXIST int32 = 3
)
View Source
const (
	SYSVAR     byte = 1
	RX         byte = 2
	LOG        byte = 3
	ROLLBACK   byte = 4
	TOROLLBACK byte = 5
)
View Source
const (
	Ping byte
	Pong
	Chap
	ChapAck
	Auth
	AuthAck
	Vote
	VoteAck
	Commit
	CommitAck
	RollBack
	RollBackAck
	AppendEntries
	AppendEntriesAck
	ReqLogEntries
	ReqLogEntriesAck
	HeartBeat
	HeartBeatAck
	Proxy
	ProxyAck
	NodeInfo
	NodeInfoAck
	ProxyRead
	ProxyReadAck
	RxSync
	RxSyncAck
	MemApply
	MemApplyAck
	MemSync
	MemSyncAck
	MemProxy
	MemProxyAck
	MemProxyRead
	MemProxyReadAck
)
View Source
const (
	KEYSYS keySys = 0
	KEY    key    = 0
)

Variables

View Source
var (
	TERM                 = []byte("TERM")
	NODEID               = []byte("NODE_ID")
	RX_EXEC_CURSOR       = []byte("RX_EXEC_CURSOR")
	RX_MAX_ID            = []byte("RX_MAX_ID")
	RX_TOTAL             = []byte("RX_TOTAL")
	LOG_MAX_ID           = []byte("LOG_MAX_ID")
	ROLLBACK_INCREMENT   = []byte("ROLLBACK_INCREMENT")
	ROLLBACK_CURSOR      = []byte("ROLLBACK_CURSOR")
	TOROLLBACK_INCREMENT = []byte("TOROLLBACK_INCREMENT")
	TOROLLBACK_CURSOR    = []byte("TOROLLBACK_CURSOR")
	TOROLLBACK_MAX       = []byte("TOROLLBACK_MAX")
)

Functions

This section is empty.

Types

type Bat

type Bat struct {
	RxExecCustor        atomic.Int64
	RxMax               atomic.Int64
	RxTotal             atomic.Int64
	LogMax              atomic.Int64
	RollbackIncrement   atomic.Int64
	RollbacCustor       atomic.Int64
	ToRollbackIncrement atomic.Int64
	ToRollbacCustor     atomic.Int64
	ToRollbacMax        atomic.Int64
	// contains filtered or unexported fields
}

type KV

type KV struct {
	// contains filtered or unexported fields
}

type Lock

type Lock struct {
	FollowerTl   sync.Mutex
	CandidateTl  sync.Mutex
	LeaderTl     sync.Mutex
	VoteTl       sync.Mutex
	SyncDataTl   sync.Mutex
	RollBackTl   sync.Mutex
	ToRollBackTl sync.Mutex

	PeercsMux     sync.Mutex
	HeartBeatMux  sync.Mutex
	VoteSyncMux   sync.Mutex
	RollBackMux   sync.Mutex
	ToRollBackMux sync.Mutex
	NodeInfoMux   sync.Mutex
	MemMux        sync.RWMutex
	MemSyncMux    sync.Mutex
	RaftxSyncMux  sync.Mutex
	RxTotalTL     sync.Mutex
	RxCustorTL    sync.Mutex
	// contains filtered or unexported fields
}

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node represents a single node in a Raft cluster, encapsulating the core logic for consensus.

func NewNode

func NewNode(config *raft.Config) *Node

NewNode initializes a new instance of Node with the provided configuration.

func (*Node) AddNode

func (n *Node) AddNode(address string) error

func (*Node) Close

func (n *Node) Close() (err error)

Close shuts down the node gracefully.

func (*Node) Command

func (n *Node) Command(cmd []byte) (err error)

func (*Node) GetLeaderId

func (n *Node) GetLeaderId() (s string, i int64)

func (*Node) GetLocalMemMultiValue

func (n *Node) GetLocalMemMultiValue(key []byte) (value [][]byte)

func (*Node) GetLocalMemMultiValueList

func (n *Node) GetLocalMemMultiValueList(key [][]byte) (result [][2][]byte)

func (*Node) GetLocalMemValue

func (n *Node) GetLocalMemValue(key []byte) (value []byte)

func (*Node) GetLocalMemValueList

func (n *Node) GetLocalMemValueList(key [][]byte) (result [][2][]byte)

func (*Node) GetLocalValue

func (n *Node) GetLocalValue(key []byte) (value []byte, err error)

func (*Node) GetLocalValueList

func (n *Node) GetLocalValueList(key [][]byte) (result [][2][]byte, err error)

func (*Node) GetMemMultiValue

func (n *Node) GetMemMultiValue(key []byte) (value [][]byte, err error)

func (*Node) GetMemValue

func (n *Node) GetMemValue(key []byte) (value []byte, err error)

func (*Node) GetMemValueList

func (n *Node) GetMemValueList(keys [][]byte) (result [][2][]byte, err error)

func (*Node) GetMetrics

func (n *Node) GetMetrics() *raft.Metrics

func (*Node) GetMultiValueList

func (n *Node) GetMultiValueList(keys [][]byte) (result [][2][]byte, err error)

func (*Node) GetNodeId

func (n *Node) GetNodeId() int64

func (*Node) GetNodeTime

func (n *Node) GetNodeTime() (int64, int64)

func (*Node) GetPeerInfo

func (n *Node) GetPeerInfo() map[string]int64

func (*Node) GetPeers

func (n *Node) GetPeers() []string

func (*Node) GetState

func (n *Node) GetState() raft.STATE

func (*Node) GetTerm

func (n *Node) GetTerm() int64

func (*Node) GetValue

func (n *Node) GetValue(key []byte) (value []byte, err error)

func (*Node) GetValueList

func (n *Node) GetValueList(key [][]byte) (result [][2][]byte, err error)

func (*Node) LastCommitTxId

func (n *Node) LastCommitTxId() int64

LastCommitTxId The transaction ID has been committed

func (*Node) LastTransactionId

func (n *Node) LastTransactionId() int64

LastTransactionId last transaction ID

func (*Node) LogStoreBatchDel

func (n *Node) LogStoreBatchDel(fromId, toId int64) error

func (*Node) LogStoreDel

func (n *Node) LogStoreDel(logId int64) error

func (*Node) LogStoreGet

func (n *Node) LogStoreGet(logId int64) *stub.LogEntryBat

func (*Node) LogStoreMaxId

func (n *Node) LogStoreMaxId() int64

func (*Node) MemCommand

func (n *Node) MemCommand(key, value []byte, ttl uint64, ptype raft.MTYPE) (err error)

func (*Node) MemLen

func (n *Node) MemLen() int64

MemLen returns the number of active MemBean items currently stored in fsm

func (*Node) Open

func (n *Node) Open() (err error)

Open initializes the node and starts its operation.

func (*Node) RemoveByAddr

func (n *Node) RemoveByAddr(addr string) (r bool)

func (*Node) RemoveById

func (n *Node) RemoveById(nodeId int64) (r bool)

func (*Node) RemoveNode

func (n *Node) RemoveNode(address string) bool

func (*Node) RemoveRx

func (n *Node) RemoveRx(fromId, toId int64) error

func (*Node) RestoreSnapshot

func (n *Node) RestoreSnapshot(snapshotData []byte) (err error)

func (*Node) Running

func (n *Node) Running() bool

func (*Node) SetId

func (n *Node) SetId(id int64) (prev int64)

func (*Node) StateMachineGetRx

func (n *Node) StateMachineGetRx(rxId int64) (*stub.MvccCell, error)

func (*Node) String

func (n *Node) String() string

func (*Node) TakeSnapshot

func (n *Node) TakeSnapshot(fromTransactionId, toTransactionId int64) (r []byte, err error)

func (*Node) UnWatch

func (n *Node) UnWatch(key []byte)

func (*Node) UnWatchWithType

func (n *Node) UnWatchWithType(key []byte, wt raft.WatchType)

func (*Node) WaitRun

func (n *Node) WaitRun() error

func (*Node) Watch

func (n *Node) Watch(key []byte, watchTypes []raft.WatchType, isSync bool, watchFunc func(key, value []byte, watchType raft.WatchType))

Jump to

Keyboard shortcuts

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