make the raft election timeout configurable
parent
82105161f0
commit
1fd64f984b
|
@ -41,6 +41,8 @@ port = 8090
|
|||
# Where the raft logs are stored. The user running InfluxDB will need read/write access.
|
||||
dir = "/tmp/influxdb/development/raft"
|
||||
|
||||
# election-timeout = "1s"
|
||||
|
||||
[storage]
|
||||
dir = "/tmp/influxdb/development/db"
|
||||
# How many requests to potentially buffer in memory. If the buffer gets filled then writes
|
||||
|
|
|
@ -38,6 +38,8 @@ port = 8090
|
|||
# Where the raft logs are stored. The user running InfluxDB will need read/write access.
|
||||
dir = "/tmp/influxdb/development/raft"
|
||||
|
||||
# election-timeout = "2s"
|
||||
|
||||
[storage]
|
||||
dir = "/tmp/influxdb/development/db"
|
||||
# How many requests to potentially buffer in memory. If the buffer gets filled then writes
|
||||
|
|
|
@ -69,8 +69,9 @@ type GraphiteConfig struct {
|
|||
}
|
||||
|
||||
type RaftConfig struct {
|
||||
Port int
|
||||
Dir string
|
||||
Port int
|
||||
Dir string
|
||||
Timeout duration `toml:"election-timeout"`
|
||||
}
|
||||
|
||||
type StorageConfig struct {
|
||||
|
@ -189,6 +190,7 @@ type Configuration struct {
|
|||
GraphitePort int
|
||||
GraphiteDatabase string
|
||||
RaftServerPort int
|
||||
RaftTimeout duration
|
||||
SeedServers []string
|
||||
DataDir string
|
||||
RaftDir string
|
||||
|
@ -257,6 +259,10 @@ func parseTomlConfiguration(filename string) (*Configuration, error) {
|
|||
defaultQueryShardBufferSize = tomlConfiguration.Cluster.QueryShardBufferSize
|
||||
}
|
||||
|
||||
if tomlConfiguration.Raft.Timeout.Duration == 0 {
|
||||
tomlConfiguration.Raft.Timeout = duration{time.Second}
|
||||
}
|
||||
|
||||
config := &Configuration{
|
||||
AdminHttpPort: tomlConfiguration.Admin.Port,
|
||||
AdminAssetsDir: tomlConfiguration.Admin.Assets,
|
||||
|
@ -267,6 +273,7 @@ func parseTomlConfiguration(filename string) (*Configuration, error) {
|
|||
GraphitePort: tomlConfiguration.InputPlugins.Graphite.Port,
|
||||
GraphiteDatabase: tomlConfiguration.InputPlugins.Graphite.Database,
|
||||
RaftServerPort: tomlConfiguration.Raft.Port,
|
||||
RaftTimeout: tomlConfiguration.Raft.Timeout,
|
||||
RaftDir: tomlConfiguration.Raft.Dir,
|
||||
ProtobufPort: tomlConfiguration.Cluster.ProtobufPort,
|
||||
ProtobufTimeout: tomlConfiguration.Cluster.ProtobufTimeout,
|
||||
|
|
|
@ -40,6 +40,7 @@ func (self *LoadConfigurationSuite) TestConfig(c *C) {
|
|||
|
||||
c.Assert(config.RaftDir, Equals, "/tmp/influxdb/development/raft")
|
||||
c.Assert(config.RaftServerPort, Equals, 8090)
|
||||
c.Assert(config.RaftTimeout.Duration, Equals, time.Second)
|
||||
|
||||
c.Assert(config.DataDir, Equals, "/tmp/influxdb/development/db")
|
||||
|
||||
|
|
|
@ -327,7 +327,7 @@ func (s *RaftServer) startRaft() error {
|
|||
return err
|
||||
}
|
||||
|
||||
s.raftServer.SetElectionTimeout(time.Second)
|
||||
s.raftServer.SetElectionTimeout(s.config.RaftTimeout.Duration)
|
||||
s.raftServer.LoadSnapshot() // ignore errors
|
||||
|
||||
s.raftServer.AddEventListener(raft.StateChangeEventType, s.raftEventHandler)
|
||||
|
|
Loading…
Reference in New Issue