etcd/server/cluster_config.go
Yicheng Qin baadf63912 feat: implement standby mode
Change log:
1. PeerServer
- estimate initial mode from its log through removedInLog variable
- refactor FindCluster to return the estimation
- refactor Start to call FindCluster explicitly
- move raftServer start and cluster init from FindCluster to Start
- remove stopNotify from PeerServer because it is not used anymore
2. Etcd
- refactor Run logic to fit the specification
3. ClusterConfig
- rename promoteDelay to removeDelay for better naming
- add SyncClusterInterval field to ClusterConfig
- commit command to set default cluster config when cluster is created
- store cluster config info into key space for consistency
- reload cluster config when reboot
4. add StandbyServer
5. Error
- remove unused EcodePromoteError
2014-05-09 01:56:55 -07:00

51 lines
1.6 KiB
Go

package server
import (
"time"
)
const (
// DefaultActiveSize is the default number of active followers allowed.
DefaultActiveSize = 9
// MinActiveSize is the minimum active size allowed.
MinActiveSize = 3
// DefaultRemoveDelay is the default elapsed time before promotion.
DefaultRemoveDelay = int((30 * time.Minute) / time.Second)
// MinRemoveDelay is the minimum promote delay allowed.
MinRemoveDelay = int((2 * time.Second) / time.Second)
// DefaultSyncClusterInterval is the default interval for cluster sync.
DefaultSyncClusterInterval = int((30 * time.Minute) / time.Second)
// MinSyncClusterInterval is the minimum sync interval allowed.
MinSyncClusterInterval = int((1 * time.Second) / time.Second)
)
// ClusterConfig represents cluster-wide configuration settings.
// These settings can only be changed through Raft.
type ClusterConfig struct {
// ActiveSize is the maximum number of node that can join as Raft followers.
// Nodes that join the cluster after the limit is reached are standbys.
ActiveSize int `json:"activeSize"`
// RemoveDelay is the amount of time, in seconds, after a node is
// unreachable that it will be swapped out as a standby node.
RemoveDelay int `json:"removeDelay"`
// SyncClusterInterval is the amount of time, in seconds, between
// cluster sync when it runs in standby mode.
SyncClusterInterval int `json:"syncClusterInterval"`
}
// NewClusterConfig returns a cluster configuration with default settings.
func NewClusterConfig() *ClusterConfig {
return &ClusterConfig{
ActiveSize: DefaultActiveSize,
RemoveDelay: DefaultRemoveDelay,
SyncClusterInterval: DefaultSyncClusterInterval,
}
}