chore(cluster_config): rename SyncClusterInterval to SyncInterval

for better naming
This commit is contained in:
Yicheng Qin
2014-05-09 13:28:21 -07:00
parent 765cd5d8b3
commit 6d4f018887
7 changed files with 32 additions and 32 deletions

View File

@@ -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,
}
}

View File

@@ -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)

View File

@@ -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.

View File

@@ -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")

View File

@@ -96,7 +96,7 @@ func TestKillLeaderWithStandbys(t *testing.T) {
c.SyncCluster()
// Reconfigure with a small active size.
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"activeSize":3, "removeDelay":2, "syncClusterInterval":1}`))
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"activeSize":3, "removeDelay":2, "syncInterval":1}`))
if !assert.Equal(t, resp.StatusCode, 200) {
t.FailNow()
}

View File

@@ -29,7 +29,7 @@ func TestRemoveNode(t *testing.T) {
c.SyncCluster()
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"syncClusterInterval":1}`))
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"syncInterval":1}`))
if !assert.Equal(t, resp.StatusCode, 200) {
t.FailNow()
}

View File

@@ -22,7 +22,7 @@ func TestStandby(t *testing.T) {
}
defer DestroyCluster(etcds)
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"syncClusterInterval":1}`))
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"syncInterval":1}`))
if !assert.Equal(t, resp.StatusCode, 200) {
t.FailNow()
}
@@ -37,7 +37,7 @@ func TestStandby(t *testing.T) {
assert.Equal(t, len(result.Node.Nodes), 9)
fmt.Println("Reconfigure with a smaller active size")
resp, _ = tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"activeSize":7, "syncClusterInterval":1}`))
resp, _ = tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"activeSize":7, "syncInterval":1}`))
if !assert.Equal(t, resp.StatusCode, 200) {
t.FailNow()
}
@@ -70,7 +70,7 @@ func TestStandby(t *testing.T) {
}
fmt.Println("Reconfigure with larger active size and wait for join")
resp, _ = tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"activeSize":8, "syncClusterInterval":1}`))
resp, _ = tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"activeSize":8, "syncInterval":1}`))
if !assert.Equal(t, resp.StatusCode, 200) {
t.FailNow()
}
@@ -107,7 +107,7 @@ func TestStandbyAutoJoin(t *testing.T) {
assert.Equal(t, len(result.Node.Nodes), 5)
// Reconfigure with a short promote delay (2 second).
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"activeSize":4, "removeDelay":2, "syncClusterInterval":1}`))
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(`{"activeSize":4, "removeDelay":2, "syncInterval":1}`))
if !assert.Equal(t, resp.StatusCode, 200) {
t.FailNow()
}
@@ -174,7 +174,7 @@ func TestStandbyGradualChange(t *testing.T) {
}
fmt.Println("Reconfigure with active size", num)
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(fmt.Sprintf(`{"activeSize":%d, "syncClusterInterval":1}`, num)))
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(fmt.Sprintf(`{"activeSize":%d, "syncInterval":1}`, num)))
if !assert.Equal(t, resp.StatusCode, 200) {
t.FailNow()
}
@@ -242,7 +242,7 @@ func TestStandbyDramaticChange(t *testing.T) {
}
fmt.Println("Reconfigure with active size", num)
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(fmt.Sprintf(`{"activeSize":%d, "syncClusterInterval":1}`, num)))
resp, _ := tests.Put("http://localhost:7001/v2/admin/config", "application/json", bytes.NewBufferString(fmt.Sprintf(`{"activeSize":%d, "syncInterval":1}`, num)))
if !assert.Equal(t, resp.StatusCode, 200) {
t.FailNow()
}