mirror of
https://github.com/status-im/consul.git
synced 2025-02-08 20:05:09 +00:00
consul: swap over to raft-boltdb
This commit is contained in:
parent
c6d45430f1
commit
ed67f6593f
@ -10,7 +10,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -18,7 +17,7 @@ import (
|
|||||||
"github.com/hashicorp/consul/acl"
|
"github.com/hashicorp/consul/acl"
|
||||||
"github.com/hashicorp/golang-lru"
|
"github.com/hashicorp/golang-lru"
|
||||||
"github.com/hashicorp/raft"
|
"github.com/hashicorp/raft"
|
||||||
"github.com/hashicorp/raft-mdb"
|
"github.com/hashicorp/raft-boltdb"
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,13 +30,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
serfLANSnapshot = "serf/local.snapshot"
|
serfLANSnapshot = "serf/local.snapshot"
|
||||||
serfWANSnapshot = "serf/remote.snapshot"
|
serfWANSnapshot = "serf/remote.snapshot"
|
||||||
raftState = "raft/"
|
raftState = "raft/"
|
||||||
tmpStatePath = "tmp/"
|
tmpStatePath = "tmp/"
|
||||||
snapshotsRetained = 2
|
snapshotsRetained = 2
|
||||||
raftDBSize32bit uint64 = 64 * 1024 * 1024 // Limit Raft log to 64MB
|
|
||||||
raftDBSize64bit uint64 = 8 * 1024 * 1024 * 1024 // Limit Raft log to 8GB
|
|
||||||
|
|
||||||
// serverRPCCache controls how long we keep an idle connection
|
// serverRPCCache controls how long we keep an idle connection
|
||||||
// open to a server
|
// open to a server
|
||||||
@ -108,7 +105,7 @@ type Server struct {
|
|||||||
raft *raft.Raft
|
raft *raft.Raft
|
||||||
raftLayer *RaftLayer
|
raftLayer *RaftLayer
|
||||||
raftPeers raft.PeerStore
|
raftPeers raft.PeerStore
|
||||||
raftStore *raftmdb.MDBStore
|
raftStore *raftboltdb.BoltStore
|
||||||
raftTransport *raft.NetworkTransport
|
raftTransport *raft.NetworkTransport
|
||||||
|
|
||||||
// reconcileCh is used to pass events from the serf handler
|
// reconcileCh is used to pass events from the serf handler
|
||||||
@ -349,22 +346,14 @@ func (s *Server) setupRaft() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the maximum raft size based on 32/64bit. Since we are
|
|
||||||
// doing an mmap underneath, we need to limit our use of virtual
|
|
||||||
// address space on 32bit, but don't have to care on 64bit.
|
|
||||||
dbSize := raftDBSize32bit
|
|
||||||
if runtime.GOARCH == "amd64" {
|
|
||||||
dbSize = raftDBSize64bit
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the base raft path
|
// Create the base raft path
|
||||||
path := filepath.Join(s.config.DataDir, raftState)
|
path := filepath.Join(s.config.DataDir, raftState)
|
||||||
if err := ensurePath(path, true); err != nil {
|
if err := ensurePath(path, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the MDB store for logs and stable storage
|
// Create the backend raft store for logs and stable storage
|
||||||
store, err := raftmdb.NewMDBStoreWithSize(path, dbSize)
|
store, err := raftboltdb.NewBoltStore(filepath.Join(path, "raft.db"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user