consul: swap over to raft-boltdb

This commit is contained in:
Ryan Uber 2015-01-29 21:55:11 -08:00
parent 9104dd9b86
commit 41aa5aeb09
1 changed files with 9 additions and 20 deletions

View File

@ -10,7 +10,6 @@ import (
"os"
"path/filepath"
"reflect"
"runtime"
"strconv"
"sync"
"time"
@ -18,7 +17,7 @@ import (
"github.com/hashicorp/consul/acl"
"github.com/hashicorp/golang-lru"
"github.com/hashicorp/raft"
"github.com/hashicorp/raft-mdb"
"github.com/hashicorp/raft-boltdb"
"github.com/hashicorp/serf/serf"
)
@ -31,13 +30,11 @@ const (
)
const (
serfLANSnapshot = "serf/local.snapshot"
serfWANSnapshot = "serf/remote.snapshot"
raftState = "raft/"
tmpStatePath = "tmp/"
snapshotsRetained = 2
raftDBSize32bit uint64 = 64 * 1024 * 1024 // Limit Raft log to 64MB
raftDBSize64bit uint64 = 8 * 1024 * 1024 * 1024 // Limit Raft log to 8GB
serfLANSnapshot = "serf/local.snapshot"
serfWANSnapshot = "serf/remote.snapshot"
raftState = "raft/"
tmpStatePath = "tmp/"
snapshotsRetained = 2
// serverRPCCache controls how long we keep an idle connection
// open to a server
@ -108,7 +105,7 @@ type Server struct {
raft *raft.Raft
raftLayer *RaftLayer
raftPeers raft.PeerStore
raftStore *raftmdb.MDBStore
raftStore *raftboltdb.BoltStore
raftTransport *raft.NetworkTransport
// reconcileCh is used to pass events from the serf handler
@ -349,22 +346,14 @@ func (s *Server) setupRaft() error {
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
path := filepath.Join(s.config.DataDir, raftState)
if err := ensurePath(path, true); err != nil {
return err
}
// Create the MDB store for logs and stable storage
store, err := raftmdb.NewMDBStoreWithSize(path, dbSize)
// Create the backend raft store for logs and stable storage
store, err := raftboltdb.NewBoltStore(filepath.Join(path, "raft.db"))
if err != nil {
return err
}