chore(standby): minor changes based on comments

This commit is contained in:
Yicheng Qin
2014-05-09 15:38:03 -07:00
parent c6b1a738c3
commit 5367c1c998
7 changed files with 23 additions and 24 deletions

View File

@@ -11,10 +11,10 @@ const (
// MinActiveSize is the minimum active size allowed.
MinActiveSize = 3
// DefaultRemoveDelay is the default elapsed time before promotion.
// DefaultRemoveDelay is the default elapsed time before removal.
DefaultRemoveDelay = int((30 * time.Minute) / time.Second)
// MinRemoveDelay is the minimum promote delay allowed.
// MinRemoveDelay is the minimum remove delay allowed.
MinRemoveDelay = int((2 * time.Second) / time.Second)
// DefaultSyncInterval is the default interval for cluster sync.

View File

@@ -372,8 +372,8 @@ func (s *PeerServer) ClusterConfig() *ClusterConfig {
}
// SetClusterConfig updates the current cluster configuration.
// Adjusting the active size will cause the PeerServer to demote peers or
// promote standbys to match the new size.
// Adjusting the active size will cause cluster to add or remove machines
// to match the new size.
func (s *PeerServer) SetClusterConfig(c *ClusterConfig) {
// Set minimums.
if c.ActiveSize < MinActiveSize {
@@ -820,7 +820,7 @@ func (s *PeerServer) monitorPeerActivity() {
removeDelay := time.Duration(s.ClusterConfig().RemoveDelay) * time.Second
peers := s.raftServer.Peers()
for _, peer := range peers {
// If the last response from the peer is longer than the promote delay
// If the last response from the peer is longer than the remove delay
// then automatically demote the peer.
if !peer.LastActivity().IsZero() && now.Sub(peer.LastActivity()) > removeDelay {
log.Infof("%s: removing node: %v; last activity %v ago", s.Config.Name, peer.Name, now.Sub(peer.LastActivity()))

View File

@@ -221,7 +221,6 @@ func (ps *PeerServer) setClusterConfigHttpHandler(w http.ResponseWriter, req *ht
}
// Retrieves a list of peers and standbys.
// If leader exists, it is at the first place.
func (ps *PeerServer) getMachinesHttpHandler(w http.ResponseWriter, req *http.Request) {
machines := make([]*machineMessage, 0)
leader := ps.raftServer.Leader()