pointer and ping misses
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m49s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m49s
This commit is contained in:
@@ -55,9 +55,10 @@ type Quorum interface {
|
||||
}
|
||||
|
||||
type RemoteHost struct {
|
||||
Host string
|
||||
Pool *RemoteGrainPool
|
||||
connection net.Conn
|
||||
Host string
|
||||
MissedPings int
|
||||
Pool *RemoteGrainPool
|
||||
connection net.Conn
|
||||
}
|
||||
|
||||
type SyncedPool struct {
|
||||
@@ -65,7 +66,7 @@ type SyncedPool struct {
|
||||
listener net.Listener
|
||||
Hostname string
|
||||
local *GrainLocalPool
|
||||
remotes []RemoteHost
|
||||
remotes []*RemoteHost
|
||||
remoteIndex map[CartId]*RemoteGrainPool
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ func NewSyncedPool(local *GrainLocalPool, hostname string, d Discovery) (*Synced
|
||||
Hostname: hostname,
|
||||
local: local,
|
||||
listener: l,
|
||||
remotes: make([]RemoteHost, 0),
|
||||
remotes: make([]*RemoteHost, 0),
|
||||
remoteIndex: make(map[CartId]*RemoteGrainPool),
|
||||
}
|
||||
if d != nil {
|
||||
@@ -126,6 +127,13 @@ func NewSyncedPool(local *GrainLocalPool, hostname string, d Discovery) (*Synced
|
||||
log.Printf("Error adding undiscovered remote %s: %v\n", h, err)
|
||||
}
|
||||
}
|
||||
for _, 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)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
go func() {
|
||||
@@ -324,7 +332,7 @@ func (p *SyncedPool) AddRemoteWithConnection(address string, connection net.Conn
|
||||
Pool: pool,
|
||||
Host: address,
|
||||
}
|
||||
return p.addRemoteHost(address, remote)
|
||||
return p.addRemoteHost(address, &remote)
|
||||
}
|
||||
|
||||
func DoPing(connection net.Conn) error {
|
||||
@@ -341,7 +349,7 @@ func DoPing(connection net.Conn) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *SyncedPool) addRemoteHost(address string, remote RemoteHost) error {
|
||||
func (p *SyncedPool) addRemoteHost(address string, remote *RemoteHost) error {
|
||||
for _, r := range p.remotes {
|
||||
if r.Host == address {
|
||||
log.Printf("Remote %s already exists\n", address)
|
||||
@@ -376,7 +384,7 @@ func (p *SyncedPool) AddRemote(address string) error {
|
||||
Host: address,
|
||||
}
|
||||
|
||||
return p.addRemoteHost(address, remote)
|
||||
return p.addRemoteHost(address, &remote)
|
||||
}
|
||||
|
||||
func (p *SyncedPool) Process(id CartId, messages ...Message) ([]byte, error) {
|
||||
|
||||
Reference in New Issue
Block a user