1
0
Fork 0

Merge pull request #151 from rqlite/config_raft

Support setting Raft heartbeat timeout
master
Philip O'Toole 8 years ago
commit 7896a31642

@ -1,4 +1,5 @@
## 3.3.0 (unreleased) ## 3.3.0 (unreleased)
- [PR #151](https://github.com/rqlite/rqlite/pull/151): Support configurable Raft heartbeat timeout.
- [PR #149](https://github.com/rqlite/rqlite/pull/149): Support configurable Raft snapshot thresholds. - [PR #149](https://github.com/rqlite/rqlite/pull/149): Support configurable Raft snapshot thresholds.
- [PR #148](https://github.com/rqlite/rqlite/pull/148): Support pprof information over HTTP. - [PR #148](https://github.com/rqlite/rqlite/pull/148): Support pprof information over HTTP.

@ -78,6 +78,7 @@ var dsn string
var onDisk bool var onDisk bool
var noVerifySelect bool var noVerifySelect bool
var raftSnapThreshold uint64 var raftSnapThreshold uint64
var raftHeartbeatTimeout string
var showVersion bool var showVersion bool
var cpuprofile string var cpuprofile string
@ -99,6 +100,7 @@ func init() {
flag.BoolVar(&onDisk, "ondisk", false, "Use an on-disk SQLite database") flag.BoolVar(&onDisk, "ondisk", false, "Use an on-disk SQLite database")
flag.BoolVar(&noVerifySelect, "nosel", false, "Don't verify that all queries begin with SELECT") flag.BoolVar(&noVerifySelect, "nosel", false, "Don't verify that all queries begin with SELECT")
flag.BoolVar(&showVersion, "version", false, "Show version information and exit") flag.BoolVar(&showVersion, "version", false, "Show version information and exit")
flag.StringVar(&raftHeartbeatTimeout, "rafttimeout", "1s", "Raft heartbeat timeout")
flag.Uint64Var(&raftSnapThreshold, "raftsnap", 8192, "Number of outstanding log entries to trigger snapshot") flag.Uint64Var(&raftSnapThreshold, "raftsnap", 8192, "Number of outstanding log entries to trigger snapshot")
flag.StringVar(&cpuprofile, "cpuprofile", "", "Write CPU profile to file") flag.StringVar(&cpuprofile, "cpuprofile", "", "Write CPU profile to file")
flag.Usage = func() { flag.Usage = func() {
@ -189,6 +191,10 @@ func main() {
log.Fatalf("failed to open store: %s", err.Error()) log.Fatalf("failed to open store: %s", err.Error())
} }
store.SnapshotThreshold = raftSnapThreshold store.SnapshotThreshold = raftSnapThreshold
store.HeartbeatTimeout, err = time.ParseDuration(raftHeartbeatTimeout)
if err != nil {
log.Fatalf("failed to parse Raft heartbeat timeout %s: %s", raftHeartbeatTimeout, err.Error())
}
// Create and configure cluster service. // Create and configure cluster service.
tn := mux.Listen(muxMetaHeader) tn := mux.Listen(muxMetaHeader)

@ -165,6 +165,7 @@ type Store struct {
logger *log.Logger logger *log.Logger
SnapshotThreshold uint64 SnapshotThreshold uint64
HeartbeatTimeout time.Duration
} }
// New returns a new Store. // New returns a new Store.
@ -213,6 +214,9 @@ func (s *Store) Open(enableSingle bool) error {
if s.SnapshotThreshold != 0 { if s.SnapshotThreshold != 0 {
config.SnapshotThreshold = s.SnapshotThreshold config.SnapshotThreshold = s.SnapshotThreshold
} }
if s.HeartbeatTimeout != 0 {
config.HeartbeatTimeout = s.HeartbeatTimeout
}
// Check for any existing peers. // Check for any existing peers.
peers, err := readPeersJSON(filepath.Join(s.raftDir, "peers.json")) peers, err := readPeersJSON(filepath.Join(s.raftDir, "peers.json"))

Loading…
Cancel
Save