mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: change import paths to "go.etcd.io/etcd"
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
This commit is contained in:
parent
47c04b959d
commit
bb60f8ab1d
@ -13,7 +13,7 @@ To keep the codebase small as well as provide flexibility, the library only impl
|
|||||||
|
|
||||||
In order to easily test the Raft library, its behavior should be deterministic. To achieve this determinism, the library models Raft as a state machine. The state machine takes a `Message` as input. A message can either be a local timer update or a network message sent from a remote peer. The state machine's output is a 3-tuple `{[]Messages, []LogEntries, NextState}` consisting of an array of `Messages`, `log entries`, and `Raft state changes`. For state machines with the same state, the same state machine input should always generate the same state machine output.
|
In order to easily test the Raft library, its behavior should be deterministic. To achieve this determinism, the library models Raft as a state machine. The state machine takes a `Message` as input. A message can either be a local timer update or a network message sent from a remote peer. The state machine's output is a 3-tuple `{[]Messages, []LogEntries, NextState}` consisting of an array of `Messages`, `log entries`, and `Raft state changes`. For state machines with the same state, the same state machine input should always generate the same state machine output.
|
||||||
|
|
||||||
A simple example application, _raftexample_, is also available to help illustrate how to use this package in practice: https://github.com/coreos/etcd/tree/master/contrib/raftexample
|
A simple example application, _raftexample_, is also available to help illustrate how to use this package in practice: https://github.com/etcd-io/etcd/tree/master/contrib/raftexample
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ This raft implementation is a full feature implementation of Raft protocol. Feat
|
|||||||
|
|
||||||
- Leader election
|
- Leader election
|
||||||
- Log replication
|
- Log replication
|
||||||
- Log compaction
|
- Log compaction
|
||||||
- Membership changes
|
- Membership changes
|
||||||
- Leadership transfer extension
|
- Leadership transfer extension
|
||||||
- Efficient linearizable read-only queries served by both the leader and followers
|
- Efficient linearizable read-only queries served by both the leader and followers
|
||||||
@ -40,13 +40,13 @@ This raft implementation also includes a few optional enhancements:
|
|||||||
- Batching log entries to reduce disk synchronized I/O
|
- Batching log entries to reduce disk synchronized I/O
|
||||||
- Writing to leader's disk in parallel
|
- Writing to leader's disk in parallel
|
||||||
- Internal proposal redirection from followers to leader
|
- Internal proposal redirection from followers to leader
|
||||||
- Automatic stepping down when the leader loses quorum
|
- Automatic stepping down when the leader loses quorum
|
||||||
|
|
||||||
## Notable Users
|
## Notable Users
|
||||||
|
|
||||||
- [cockroachdb](https://github.com/cockroachdb/cockroach) A Scalable, Survivable, Strongly-Consistent SQL Database
|
- [cockroachdb](https://github.com/cockroachdb/cockroach) A Scalable, Survivable, Strongly-Consistent SQL Database
|
||||||
- [dgraph](https://github.com/dgraph-io/dgraph) A Scalable, Distributed, Low Latency, High Throughput Graph Database
|
- [dgraph](https://github.com/dgraph-io/dgraph) A Scalable, Distributed, Low Latency, High Throughput Graph Database
|
||||||
- [etcd](https://github.com/coreos/etcd) A distributed reliable key-value store
|
- [etcd](https://github.com/etcd-io/etcd) A distributed reliable key-value store
|
||||||
- [tikv](https://github.com/pingcap/tikv) A Distributed transactional key value database powered by Rust and Raft
|
- [tikv](https://github.com/pingcap/tikv) A Distributed transactional key value database powered by Rust and Raft
|
||||||
- [swarmkit](https://github.com/docker/swarmkit) A toolkit for orchestrating distributed systems at any scale.
|
- [swarmkit](https://github.com/docker/swarmkit) A toolkit for orchestrating distributed systems at any scale.
|
||||||
- [chain core](https://github.com/chain/chain) Software for operating permissioned, multi-asset blockchain networks
|
- [chain core](https://github.com/chain/chain) Software for operating permissioned, multi-asset blockchain networks
|
||||||
@ -166,7 +166,7 @@ To propose changes to the state machine from the node to take application data,
|
|||||||
n.Propose(ctx, data)
|
n.Propose(ctx, data)
|
||||||
```
|
```
|
||||||
|
|
||||||
If the proposal is committed, data will appear in committed entries with type raftpb.EntryNormal. There is no guarantee that a proposed command will be committed; the command may have to be reproposed after a timeout.
|
If the proposal is committed, data will appear in committed entries with type raftpb.EntryNormal. There is no guarantee that a proposed command will be committed; the command may have to be reproposed after a timeout.
|
||||||
|
|
||||||
To add or remove node in a cluster, build ConfChange struct 'cc' and call:
|
To add or remove node in a cluster, build ConfChange struct 'cc' and call:
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ For more details on Raft, see "In Search of an Understandable Consensus Algorith
|
|||||||
|
|
||||||
A simple example application, _raftexample_, is also available to help illustrate
|
A simple example application, _raftexample_, is also available to help illustrate
|
||||||
how to use this package in practice:
|
how to use this package in practice:
|
||||||
https://github.com/coreos/etcd/tree/master/contrib/raftexample
|
https://go.etcd.io/etcd/tree/master/contrib/raftexample
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package raft
|
package raft
|
||||||
|
|
||||||
import (
|
import (
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func applyToStore(ents []pb.Entry) {}
|
func applyToStore(ents []pb.Entry) {}
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type raftLog struct {
|
type raftLog struct {
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFindConflict(t *testing.T) {
|
func TestFindConflict(t *testing.T) {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package raft
|
package raft
|
||||||
|
|
||||||
import pb "github.com/coreos/etcd/raft/raftpb"
|
import pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
|
|
||||||
// unstable.entries[i] has raft log position i+unstable.offset.
|
// unstable.entries[i] has raft log position i+unstable.offset.
|
||||||
// Note that unstable.offset may be less than the highest log
|
// Note that unstable.offset may be less than the highest log
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUnstableMaybeFirstIndex(t *testing.T) {
|
func TestUnstableMaybeFirstIndex(t *testing.T) {
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SnapshotStatus int
|
type SnapshotStatus int
|
||||||
|
@ -22,8 +22,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/pkg/testutil"
|
"go.etcd.io/etcd/pkg/testutil"
|
||||||
"github.com/coreos/etcd/raft/raftpb"
|
"go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// readyWithTimeout selects from n.Ready() with a 1-second timeout. It
|
// readyWithTimeout selects from n.Ready() with a 1-second timeout. It
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// None is a placeholder node ID used when there is no leader.
|
// None is a placeholder node ID used when there is no leader.
|
||||||
|
@ -17,7 +17,7 @@ package raft
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestMsgAppFlowControlFull ensures:
|
// TestMsgAppFlowControlFull ensures:
|
||||||
|
@ -33,7 +33,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFollowerUpdateTermFromMessage(t *testing.T) {
|
func TestFollowerUpdateTermFromMessage(t *testing.T) {
|
||||||
|
@ -17,7 +17,7 @@ package raft
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// nextEnts returns the appliable entries and updates the applied index
|
// nextEnts returns the appliable entries and updates the applied index
|
||||||
@ -1439,7 +1439,7 @@ func TestHandleHeartbeatResp(t *testing.T) {
|
|||||||
|
|
||||||
// TestRaftFreesReadOnlyMem ensures raft will free read request from
|
// TestRaftFreesReadOnlyMem ensures raft will free read request from
|
||||||
// readOnly readIndexQueue and pendingReadIndex map.
|
// readOnly readIndexQueue and pendingReadIndex map.
|
||||||
// related issue: https://github.com/coreos/etcd/issues/7571
|
// related issue: https://go.etcd.io/etcd/issues/7571
|
||||||
func TestRaftFreesReadOnlyMem(t *testing.T) {
|
func TestRaftFreesReadOnlyMem(t *testing.T) {
|
||||||
sm := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())
|
sm := newTestRaft(1, []uint64{1, 2}, 5, 1, NewMemoryStorage())
|
||||||
sm.becomeCandidate()
|
sm.becomeCandidate()
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/raft/raftpb"
|
"go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// a network interface
|
// a network interface
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/raft/raftpb"
|
"go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNetworkDrop(t *testing.T) {
|
func TestNetworkDrop(t *testing.T) {
|
||||||
|
@ -20,8 +20,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/raft"
|
"go.etcd.io/etcd/raft"
|
||||||
"github.com/coreos/etcd/raft/raftpb"
|
"go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type node struct {
|
type node struct {
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/raft"
|
"go.etcd.io/etcd/raft"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BenchmarkProposal3Nodes(b *testing.B) {
|
func BenchmarkProposal3Nodes(b *testing.B) {
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/etcd/raft"
|
"go.etcd.io/etcd/raft"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBasicProgress(t *testing.T) {
|
func TestBasicProgress(t *testing.T) {
|
||||||
|
@ -17,7 +17,7 @@ package raft
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrStepLocalMsg is returned when try to step a local raft message
|
// ErrStepLocalMsg is returned when try to step a local raft message
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/coreos/etcd/raft/raftpb"
|
"go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestRawNodeStep ensures that RawNode.Step ignore local message.
|
// TestRawNodeStep ensures that RawNode.Step ignore local message.
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package raft
|
package raft
|
||||||
|
|
||||||
import pb "github.com/coreos/etcd/raft/raftpb"
|
import pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
|
|
||||||
// ReadState provides state for read only query.
|
// ReadState provides state for read only query.
|
||||||
// It's caller's responsibility to call ReadIndex first before getting
|
// It's caller's responsibility to call ReadIndex first before getting
|
||||||
|
@ -17,7 +17,7 @@ package raft
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Status struct {
|
type Status struct {
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrCompacted is returned by Storage.Entries/Compact when a requested
|
// ErrCompacted is returned by Storage.Entries/Compact when a requested
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestStorageTerm(t *testing.T) {
|
func TestStorageTerm(t *testing.T) {
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (st StateType) MarshalJSON() ([]byte, error) {
|
func (st StateType) MarshalJSON() ([]byte, error) {
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
pb "github.com/coreos/etcd/raft/raftpb"
|
pb "go.etcd.io/etcd/raft/raftpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testFormatter EntryFormatter = func(data []byte) string {
|
var testFormatter EntryFormatter = func(data []byte) string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user