mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
chore(cluster_config): rename SyncClusterInterval to SyncInterval
for better naming
This commit is contained in:
@@ -17,11 +17,11 @@ const (
|
||||
// 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)
|
||||
// DefaultSyncInterval is the default interval for cluster sync.
|
||||
DefaultSyncInterval = int((30 * time.Minute) / time.Second)
|
||||
|
||||
// MinSyncClusterInterval is the minimum sync interval allowed.
|
||||
MinSyncClusterInterval = int((1 * time.Second) / time.Second)
|
||||
// MinSyncInterval is the minimum sync interval allowed.
|
||||
MinSyncInterval = int((1 * time.Second) / time.Second)
|
||||
)
|
||||
|
||||
// ClusterConfig represents cluster-wide configuration settings.
|
||||
@@ -35,16 +35,16 @@ type ClusterConfig struct {
|
||||
// unreachable that it will be swapped out as a standby node.
|
||||
RemoveDelay int `json:"removeDelay"`
|
||||
|
||||
// SyncClusterInterval is the amount of time, in seconds, between
|
||||
// SyncInterval is the amount of time, in seconds, between
|
||||
// cluster sync when it runs in standby mode.
|
||||
SyncClusterInterval int `json:"syncClusterInterval"`
|
||||
SyncInterval int `json:"syncInterval"`
|
||||
}
|
||||
|
||||
// NewClusterConfig returns a cluster configuration with default settings.
|
||||
func NewClusterConfig() *ClusterConfig {
|
||||
return &ClusterConfig{
|
||||
ActiveSize: DefaultActiveSize,
|
||||
RemoveDelay: DefaultRemoveDelay,
|
||||
SyncClusterInterval: DefaultSyncClusterInterval,
|
||||
ActiveSize: DefaultActiveSize,
|
||||
RemoveDelay: DefaultRemoveDelay,
|
||||
SyncInterval: DefaultSyncInterval,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,8 +382,8 @@ func (s *PeerServer) SetClusterConfig(c *ClusterConfig) {
|
||||
if c.RemoveDelay < MinRemoveDelay {
|
||||
c.RemoveDelay = MinRemoveDelay
|
||||
}
|
||||
if c.SyncClusterInterval < MinSyncClusterInterval {
|
||||
c.SyncClusterInterval = MinSyncClusterInterval
|
||||
if c.SyncInterval < MinSyncInterval {
|
||||
c.SyncInterval = MinSyncInterval
|
||||
}
|
||||
|
||||
log.Debugf("set cluster config as %v", c)
|
||||
|
||||
@@ -208,8 +208,8 @@ func (ps *PeerServer) setClusterConfigHttpHandler(w http.ResponseWriter, req *ht
|
||||
if removeDelay, ok := m["removeDelay"].(float64); ok {
|
||||
config.RemoveDelay = int(removeDelay)
|
||||
}
|
||||
if syncClusterInterval, ok := m["syncClusterInterval"].(float64); ok {
|
||||
config.SyncClusterInterval = int(syncClusterInterval)
|
||||
if syncInterval, ok := m["syncInterval"].(float64); ok {
|
||||
config.SyncInterval = int(syncInterval)
|
||||
}
|
||||
|
||||
// Issue command to update.
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/coreos/etcd/store"
|
||||
)
|
||||
|
||||
const UninitedSyncClusterInterval = time.Duration(5) * time.Second
|
||||
const UninitedSyncInterval = time.Duration(5) * time.Second
|
||||
|
||||
type StandbyServerConfig struct {
|
||||
Name string
|
||||
@@ -28,9 +28,9 @@ type StandbyServer struct {
|
||||
Config StandbyServerConfig
|
||||
client *Client
|
||||
|
||||
cluster []*machineMessage
|
||||
syncClusterInterval time.Duration
|
||||
joinIndex uint64
|
||||
cluster []*machineMessage
|
||||
syncInterval time.Duration
|
||||
joinIndex uint64
|
||||
|
||||
removeNotify chan bool
|
||||
started bool
|
||||
@@ -42,9 +42,9 @@ type StandbyServer struct {
|
||||
|
||||
func NewStandbyServer(config StandbyServerConfig, client *Client) *StandbyServer {
|
||||
return &StandbyServer{
|
||||
Config: config,
|
||||
client: client,
|
||||
syncClusterInterval: UninitedSyncClusterInterval,
|
||||
Config: config,
|
||||
client: client,
|
||||
syncInterval: UninitedSyncInterval,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ func (s *StandbyServer) SyncCluster(peers []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *StandbyServer) SetSyncClusterInterval(second int) {
|
||||
s.syncClusterInterval = time.Duration(second) * time.Second
|
||||
func (s *StandbyServer) SetSyncInterval(second int) {
|
||||
s.syncInterval = time.Duration(second) * time.Second
|
||||
}
|
||||
|
||||
func (s *StandbyServer) ClusterLeader() *machineMessage {
|
||||
@@ -148,7 +148,7 @@ func (s *StandbyServer) redirectRequests(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
func (s *StandbyServer) monitorCluster() {
|
||||
for {
|
||||
timer := time.NewTimer(s.syncClusterInterval)
|
||||
timer := time.NewTimer(s.syncInterval)
|
||||
defer timer.Stop()
|
||||
select {
|
||||
case <-s.closeChan:
|
||||
@@ -199,7 +199,7 @@ func (s *StandbyServer) syncCluster(peerURLs []string) error {
|
||||
}
|
||||
|
||||
s.setCluster(machines)
|
||||
s.SetSyncClusterInterval(config.SyncClusterInterval)
|
||||
s.SetSyncInterval(config.SyncInterval)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unreachable cluster")
|
||||
|
||||
Reference in New Issue
Block a user