|
|
@ -112,7 +112,7 @@ func (b *Bootstrapper) SetBasicAuth(username, password string) {
|
|
|
|
func (b *Bootstrapper) Boot(id, raftAddr string, done func() bool, timeout time.Duration) error {
|
|
|
|
func (b *Bootstrapper) Boot(id, raftAddr string, done func() bool, timeout time.Duration) error {
|
|
|
|
timeoutT := time.NewTimer(timeout)
|
|
|
|
timeoutT := time.NewTimer(timeout)
|
|
|
|
defer timeoutT.Stop()
|
|
|
|
defer timeoutT.Stop()
|
|
|
|
tickerT := time.NewTimer(jitter(time.Millisecond))
|
|
|
|
tickerT := time.NewTimer(random.Jitter(time.Millisecond))
|
|
|
|
defer tickerT.Stop()
|
|
|
|
defer tickerT.Stop()
|
|
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
for {
|
|
|
@ -127,7 +127,7 @@ func (b *Bootstrapper) Boot(id, raftAddr string, done func() bool, timeout time.
|
|
|
|
b.setBootStatus(BootDone)
|
|
|
|
b.setBootStatus(BootDone)
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tickerT.Reset(jitter(b.Interval)) // Move to longer-period polling
|
|
|
|
tickerT.Reset(random.Jitter(b.Interval)) // Move to longer-period polling
|
|
|
|
|
|
|
|
|
|
|
|
targets, err := b.provider.Lookup()
|
|
|
|
targets, err := b.provider.Lookup()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -251,10 +251,3 @@ func (s *stringAddressProvider) Lookup() ([]string, error) {
|
|
|
|
func NewAddressProviderString(ss []string) AddressProvider {
|
|
|
|
func NewAddressProviderString(ss []string) AddressProvider {
|
|
|
|
return &stringAddressProvider{ss}
|
|
|
|
return &stringAddressProvider{ss}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// jitter adds a little bit of randomness to a given duration. This is
|
|
|
|
|
|
|
|
// useful to prevent nodes across the cluster performing certain operations
|
|
|
|
|
|
|
|
// all at the same time.
|
|
|
|
|
|
|
|
func jitter(duration time.Duration) time.Duration {
|
|
|
|
|
|
|
|
return duration + time.Duration(random.Float64()*float64(duration))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|