This commit is contained in:
@@ -85,6 +85,27 @@ func NewSyncedPool(local *GrainLocalPool, hostname string, d Discovery) (*Synced
|
|||||||
remotes: make([]*RemoteHost, 0),
|
remotes: make([]*RemoteHost, 0),
|
||||||
remoteIndex: make(map[CartId]*RemoteGrainPool),
|
remoteIndex: make(map[CartId]*RemoteGrainPool),
|
||||||
}
|
}
|
||||||
|
pingTimer := time.NewTicker(time.Second)
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
<-pingTimer.C
|
||||||
|
for i, r := range pool.remotes {
|
||||||
|
err := DoPing(r.connection)
|
||||||
|
if err != nil {
|
||||||
|
r.MissedPings++
|
||||||
|
log.Printf("Error pinging remote %s: %v\n, missed pings: %d", r.Host, err, r.MissedPings)
|
||||||
|
if r.MissedPings > 3 {
|
||||||
|
log.Printf("Removing remote %s\n", r.Host)
|
||||||
|
|
||||||
|
pool.remotes = append(pool.remotes[:i], pool.remotes[i+1:]...)
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
r.MissedPings = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
if d != nil {
|
if d != nil {
|
||||||
discoveryTimer := time.NewTicker(time.Second * 5)
|
discoveryTimer := time.NewTicker(time.Second * 5)
|
||||||
go func() {
|
go func() {
|
||||||
@@ -127,21 +148,7 @@ func NewSyncedPool(local *GrainLocalPool, hostname string, d Discovery) (*Synced
|
|||||||
log.Printf("Error adding undiscovered remote %s: %v\n", h, err)
|
log.Printf("Error adding undiscovered remote %s: %v\n", h, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i, r := range pool.remotes {
|
|
||||||
err := DoPing(r.connection)
|
|
||||||
if err != nil {
|
|
||||||
r.MissedPings++
|
|
||||||
log.Printf("Error pinging remote %s: %v\n, missed pings: %d", r.Host, err, r.MissedPings)
|
|
||||||
if r.MissedPings > 3 {
|
|
||||||
log.Printf("Removing remote %s\n", r.Host)
|
|
||||||
|
|
||||||
pool.remotes = append(pool.remotes[:i], pool.remotes[i+1:]...)
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
r.MissedPings = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user